mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Use Rate to represent transfer rates (RIPD-201, RIPD-983):
The Ripple protocol represent transfer rates and trust line qualities as fractions of one billion. For example, a transfer rate of 1% is represented as 1010000000. Previously, such rates where represented either as std::uint32_t or std::uint64_t. Other, nominally related types, also used an integral representation and could be unintentionally substituted. The new Rate class addresses this by providing a simple, type safe alternative which also helps make the code self-documenting since arithmetic operations now can be clearly understood to involve the scaling of an amount by a rate.
This commit is contained in:
committed by
Miguel Portilla
parent
f060820f3b
commit
a698104c55
@@ -256,18 +256,20 @@ forEachOffer (
|
||||
// Charge a fee even if the owner is the same as the issuer
|
||||
// (the old code does not charge a fee)
|
||||
// Calculate amount that goes to the taker and the amount charged the offer owner
|
||||
auto transferRate = [&](AccountID const& id)->std::uint32_t
|
||||
auto rate = [&](AccountID const& id)->std::uint32_t
|
||||
{
|
||||
if (isXRP (id) || id == dst)
|
||||
return QUALITY_ONE;
|
||||
return rippleTransferRate (sb, id);
|
||||
return transferRate (sb, id).value;
|
||||
};
|
||||
|
||||
std::uint32_t const trIn =
|
||||
prevStepRedeems ? transferRate (book.in.account) : QUALITY_ONE;
|
||||
std::uint32_t const trIn = prevStepRedeems
|
||||
? rate (book.in.account)
|
||||
: QUALITY_ONE;
|
||||
// Always charge the transfer fee, even if the owner is the issuer
|
||||
std::uint32_t const trOut =
|
||||
ownerPaysTransferFee ? transferRate (book.out.account) : QUALITY_ONE;
|
||||
std::uint32_t const trOut = ownerPaysTransferFee
|
||||
? rate (book.out.account)
|
||||
: QUALITY_ONE;
|
||||
|
||||
typename FlowOfferStream<TAmtIn, TAmtOut>::StepCounter counter (limit, j);
|
||||
FlowOfferStream<TAmtIn, TAmtOut> offers (
|
||||
|
||||
Reference in New Issue
Block a user