Skip to content

Commit daec955

Browse files
committed
Introduce -blockmintxfee
1 parent 123ea73 commit daec955

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
lines changed

src/init.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ std::string HelpMessage(HelpMessageMode mode)
476476
strUsage += HelpMessageOpt("-blockmaxweight=<n>", strprintf(_("Set maximum BIP141 block weight (default: %d)"), DEFAULT_BLOCK_MAX_WEIGHT));
477477
strUsage += HelpMessageOpt("-blockmaxsize=<n>", strprintf(_("Set maximum block size in bytes (default: %d)"), DEFAULT_BLOCK_MAX_SIZE));
478478
strUsage += HelpMessageOpt("-blockprioritysize=<n>", strprintf(_("Set maximum size of high-priority/low-fee transactions in bytes (default: %d)"), DEFAULT_BLOCK_PRIORITY_SIZE));
479+
strUsage += HelpMessageOpt("-blockmintxfee=<amt>", strprintf(_("Set lowest fee rate (in %s/kB) for transactions to be included in block creation. (default: %s)"), CURRENCY_UNIT, FormatMoney(DEFAULT_BLOCK_MIN_TX_FEE)));
479480
if (showDebug)
480481
strUsage += HelpMessageOpt("-blockversion=<n>", "Override block version to test forking scenarios");
481482

@@ -970,6 +971,15 @@ bool AppInitParameterInteraction()
970971
::minRelayTxFee = CFeeRate(n);
971972
}
972973

974+
// Sanity check argument for min fee for including tx in block
975+
// TODO: Harmonize which arguments need sanity checking and where that happens
976+
if (IsArgSet("-blockmintxfee"))
977+
{
978+
CAmount n = 0;
979+
if (!ParseMoney(GetArg("-blockmintxfee", ""), n))
980+
return InitError(AmountErrMsg("blockmintxfee", GetArg("-blockmintxfee", "")));
981+
}
982+
973983
fRequireStandard = !GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard());
974984
if (chainparams.RequireStandard() && !fRequireStandard)
975985
return InitError(strprintf("acceptnonstdtxn is not currently supported for %s chain", chainparams.NetworkIDString()));

src/miner.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,18 @@ BlockAssembler::BlockAssembler(const CChainParams& _chainparams)
9595
nBlockMaxWeight = nBlockMaxSize * WITNESS_SCALE_FACTOR;
9696
}
9797
}
98+
if (IsArgSet("-blockmintxfee")) {
99+
CAmount n = 0;
100+
ParseMoney(GetArg("-blockmintxfee", ""), n);
101+
blockMinFeeRate = CFeeRate(n);
102+
} else {
103+
blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE);
104+
}
98105

99106
// Limit weight to between 4K and MAX_BLOCK_WEIGHT-4K for sanity:
100107
nBlockMaxWeight = std::max((unsigned int)4000, std::min((unsigned int)(MAX_BLOCK_WEIGHT-4000), nBlockMaxWeight));
101108
// Limit size to between 1K and MAX_BLOCK_SERIALIZED_SIZE-1K for sanity:
102109
nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(MAX_BLOCK_SERIALIZED_SIZE-1000), nBlockMaxSize));
103-
104110
// Whether we need to account for byte usage (in addition to weight usage)
105111
fNeedSizeAccounting = (nBlockMaxSize < MAX_BLOCK_SERIALIZED_SIZE-1000);
106112
}
@@ -460,7 +466,7 @@ void BlockAssembler::addPackageTxs()
460466
packageSigOpsCost = modit->nSigOpCostWithAncestors;
461467
}
462468

463-
if (packageFees < ::minRelayTxFee.GetFee(packageSize)) {
469+
if (packageFees < blockMinFeeRate.GetFee(packageSize)) {
464470
// Everything else we might consider has a lower fee rate
465471
return;
466472
}

src/miner.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ class BlockAssembler
143143
bool fIncludeWitness;
144144
unsigned int nBlockMaxWeight, nBlockMaxSize;
145145
bool fNeedSizeAccounting;
146+
CFeeRate blockMinFeeRate;
146147

147148
// Information on the current status of the block
148149
uint64_t nBlockWeight;

src/policy/policy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 750000;
2020
static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 0;
2121
/** Default for -blockmaxweight, which controls the range of block weights the mining code will create **/
2222
static const unsigned int DEFAULT_BLOCK_MAX_WEIGHT = 3000000;
23+
/** Default for -blockmintxfee, which sets the minimum feerate for a transaction in blocks created by mining code **/
24+
static const unsigned int DEFAULT_BLOCK_MIN_TX_FEE = 1000;
2325
/** The maximum weight for transactions we're willing to relay/mine */
2426
static const unsigned int MAX_STANDARD_TX_WEIGHT = 400000;
2527
/** Maximum number of signature check operations in an IsStandard() P2SH script */

0 commit comments

Comments
 (0)