mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Limit the number of offers that can be consumed during crossing
This commit is contained in:
@@ -224,6 +224,18 @@ CreateOffer::select_path (
|
||||
return std::make_pair (false, bridged_quality);
|
||||
}
|
||||
|
||||
bool
|
||||
CreateOffer::reachedOfferCrossingLimit (Taker const& taker) const
|
||||
{
|
||||
auto const crossings =
|
||||
taker.get_direct_crossings () +
|
||||
(2 * taker.get_bridge_crossings ());
|
||||
|
||||
// The crossing limit is part of the Ripple protocol and
|
||||
// changing it is a transaction-processing change.
|
||||
return crossings >= 850;
|
||||
}
|
||||
|
||||
std::pair<TER, Amounts>
|
||||
CreateOffer::bridged_cross (
|
||||
Taker& taker,
|
||||
@@ -358,6 +370,12 @@ CreateOffer::bridged_cross (
|
||||
break;
|
||||
}
|
||||
|
||||
if (reachedOfferCrossingLimit (taker))
|
||||
{
|
||||
j_.debug << "The offer crossing limit has been exceeded!";
|
||||
break;
|
||||
}
|
||||
|
||||
// Postcondition: If we aren't done, then we *must* have consumed at
|
||||
// least one offer fully.
|
||||
assert (direct_consumed || leg1_consumed || leg2_consumed);
|
||||
@@ -432,6 +450,12 @@ CreateOffer::direct_cross (
|
||||
break;
|
||||
}
|
||||
|
||||
if (reachedOfferCrossingLimit (taker))
|
||||
{
|
||||
j_.debug << "The offer crossing limit has been exceeded!";
|
||||
break;
|
||||
}
|
||||
|
||||
// Postcondition: If we aren't done, then we *must* have consumed the
|
||||
// offer on the books fully!
|
||||
assert (direct_consumed);
|
||||
|
||||
@@ -97,6 +97,11 @@ private:
|
||||
bool
|
||||
step_account (OfferStream& stream, Taker const& taker);
|
||||
|
||||
// True if the number of offers that have been crossed
|
||||
// exceeds the limit.
|
||||
bool
|
||||
reachedOfferCrossingLimit (Taker const& taker) const;
|
||||
|
||||
// Fill offer as much as possible by consuming offers already on the books,
|
||||
// and adjusting account balances accordingly.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user