Allow fractional fee multipliers (RIPD-626):

* Auto-fill fee maximum is `base * fee_mult_max / fee_div_max`.
* `fee_div_max` defaults to 1 to preserve backward compatibility.
This commit is contained in:
Edward Hennis
2015-12-04 19:14:24 -05:00
committed by seelabs
parent e78b8e4cf3
commit 7728f69100
5 changed files with 184 additions and 3 deletions

View File

@@ -631,6 +631,7 @@ Json::Value checkFee (
return RPC::missing_field_error ("tx_json.Fee");
int mult = Tuning::defaultAutoFillFeeMultiplier;
int div = Tuning::defaultAutoFillFeeDivisor;
if (request.isMember (jss::fee_mult_max))
{
if (request[jss::fee_mult_max].isNumeric ())
@@ -643,6 +644,21 @@ Json::Value checkFee (
RPC::expected_field_message (jss::fee_mult_max, "a number"));
}
}
if (request.isMember(jss::fee_div_max))
{
if (request[jss::fee_div_max].isNumeric())
{
div = request[jss::fee_div_max].asInt();
if (div == 0)
return RPC::make_error(rpcINVALID_PARAMS,
RPC::expected_field_message(jss::fee_div_max, "non-zero"));
}
else
{
return RPC::make_error(rpcHIGH_FEE,
RPC::expected_field_message(jss::fee_div_max, "a number"));
}
}
// Default fee in fee units.
std::uint64_t const feeDefault = config.TRANSACTION_FEE_BASE;
@@ -652,8 +668,9 @@ Json::Value checkFee (
feeTrack.scaleFeeLoad (feeDefault,
ledger->fees().base, ledger->fees().units, isUnlimited (role));
std::uint64_t const limit = mult * feeTrack.scaleFeeBase (
feeDefault, ledger->fees().base, ledger->fees().units);
auto const limit = mulDivThrow(feeTrack.scaleFeeBase (
feeDefault, ledger->fees().base, ledger->fees().units),
mult, div);
if (fee > limit)
{

View File

@@ -44,9 +44,15 @@ namespace RPC {
wants the fee filled in.
"fee_mult_max" A multiplier applied to the current ledger's transaction
fee that caps the maximum the fee server should auto fill.
fee that caps the maximum fee the server should auto fill.
If this optional field is not specified, then a default
multiplier is used.
"fee_div_max" A divider applied to the current ledger's transaction
fee that caps the maximum fee the server should auto fill.
If this optional field is not specified, then a default
divider (1) is used. "fee_mult_max" and "fee_div_max"
are both used such that the maximum fee will be
`base * fee_mult_max / fee_div_max` as an integer.
@param tx The JSON corresponding to the transaction to fill in.
@param ledger A ledger for retrieving the current fee schedule.

View File

@@ -48,6 +48,7 @@ static LimitRange const bookOffers = {0, 0, 400};
static LimitRange const noRippleCheck = {10, 300, 400};
static int const defaultAutoFillFeeMultiplier = 10;
static int const defaultAutoFillFeeDivisor = 1;
static int const maxPathfindsInProgress = 2;
static int const maxPathfindJobCount = 50;
static int const maxJobQueueClients = 500;