v31.1-roots.1 · Commit 3: [PATCH 03/17] feat(policy): preserve cluster accounting and repair dynamic dust
src/node/mempool_args.cpp
Before: src/node/mempool_args.cpp · After: src/node/mempool_args.cpp
File metadata
index e017d1c27fb87ea46f6a1f9ab53d6dfb3f179bbf..0eac4816b3001457f571bfafd6186b2c9ce31bb5 100644
Download original patch · Release notes
Diff rows 1–107 of 107. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.
src/node/mempool_args.cpp
CHANGED
|
@@ -270,6 +270,13 @@ util::Result<void> ApplyArgsManOptions(const ArgsManager& argsman, const CChainP
|
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
+
if (const auto value = argsman.GetArg("-datacarriercost")) {
|
|
274
|
+
mempool_opts.weight_per_data_byte = *ParseDataCarrierCost(*value);
|
|
275
|
+
}
|
|
276
|
+
mempool_opts.subdustfeepenalty = argsman.GetBoolArg("-subdustfeepenalty", mempool_opts.subdustfeepenalty);
|
|
277
|
+
const auto reuse = argsman.GetArg("-spkreuse", "allow");
|
|
278
|
+
mempool_opts.reject_spk_reuse = reuse != "allow" && !argsman.GetBoolArg("-spkreuse", false);
|
|
279
|
+
|
|
273
280
|
mempool_opts.minrelaycoinblocks = argsman.GetIntArg("-minrelaycoinblocks", 0);
|
|
274
281
|
mempool_opts.minrelaymaturity = argsman.GetIntArg("-minrelaymaturity", 0);
|
|
275
282
|
mempool_opts.maxtxlegacysigops = argsman.GetIntArg("-maxtxlegacysigops", mempool_opts.maxtxlegacysigops);
|
|
@@ -302,6 +309,87 @@ util::Result<void> ApplyArgsManOptions(const ArgsManager& argsman, const CChainP
|
|
|
302
309
|
|
|
303
310
|
mempool_opts.acceptunknownwitness = argsman.GetBoolArg("-acceptunknownwitness", mempool_opts.acceptunknownwitness);
|
|
304
311
|
|
|
312
|
+
if (argsman.IsArgSet("-mempoolreplacement") || argsman.IsArgSet("-mempoolfullrbf")) {
|
|
313
|
+
// Generally, mempoolreplacement overrides mempoolfullrbf, but the latter is used to infer intent in some cases
|
|
314
|
+
std::optional<bool> optin_flag;
|
|
315
|
+
bool fee_flag{false};
|
|
316
|
+
if (argsman.GetBoolArg("-mempoolreplacement", false)) {
|
|
317
|
+
fee_flag = true;
|
|
318
|
+
} else {
|
|
319
|
+
for (auto& opt : util::SplitString(argsman.GetArg("-mempoolreplacement", ""), ",+")) {
|
|
320
|
+
if (opt == "optin") {
|
|
321
|
+
optin_flag = true;
|
|
322
|
+
} else if (opt == "-optin") {
|
|
323
|
+
optin_flag = false;
|
|
324
|
+
} else if (opt == "fee") {
|
|
325
|
+
fee_flag = true;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
if (optin_flag.value_or(false)) {
|
|
330
|
+
// "optin" is explicitly specified
|
|
331
|
+
mempool_opts.rbf_policy = RBFPolicy::OptIn;
|
|
332
|
+
} else if (argsman.GetBoolArg("-mempoolfullrbf", false)) {
|
|
333
|
+
const bool mempoolreplacement_false{argsman.IsArgSet("-mempoolreplacement") && !(fee_flag || optin_flag.has_value())};
|
|
334
|
+
if (mempoolreplacement_false) {
|
|
335
|
+
// This is a contradiction, but override rather than error
|
|
336
|
+
mempool_opts.rbf_policy = RBFPolicy::Never;
|
|
337
|
+
} else {
|
|
338
|
+
mempool_opts.rbf_policy = RBFPolicy::Always;
|
|
339
|
+
}
|
|
340
|
+
} else if (!optin_flag.value_or(true)) {
|
|
341
|
+
// "-optin" is explicitly specified
|
|
342
|
+
mempool_opts.rbf_policy = fee_flag ? RBFPolicy::Always : RBFPolicy::Never;
|
|
343
|
+
} else if (fee_flag) {
|
|
344
|
+
// Just "fee" by itself
|
|
345
|
+
if (!argsman.GetBoolArg("-mempoolfullrbf", true)) {
|
|
346
|
+
mempool_opts.rbf_policy = RBFPolicy::OptIn;
|
|
347
|
+
} else {
|
|
348
|
+
// Fallback to default, unless it's been changed to Never
|
|
349
|
+
if (mempool_opts.rbf_policy == RBFPolicy::Never) {
|
|
350
|
+
mempool_opts.rbf_policy = RBFPolicy::Always;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
} else if (!argsman.IsArgSet("-mempoolreplacement")) {
|
|
354
|
+
// mempoolfullrbf is always explicitly false here
|
|
355
|
+
// Fallback to default, as long as it isn't Always
|
|
356
|
+
if (mempool_opts.rbf_policy == RBFPolicy::Always) {
|
|
357
|
+
mempool_opts.rbf_policy = RBFPolicy::OptIn;
|
|
358
|
+
}
|
|
359
|
+
} else {
|
|
360
|
+
// mempoolreplacement is explicitly false here
|
|
361
|
+
mempool_opts.rbf_policy = RBFPolicy::Never;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if (argsman.IsArgSet("-mempooltruc")) {
|
|
366
|
+
std::optional<bool> accept_flag, enforce_flag;
|
|
367
|
+
if (argsman.GetBoolArg("-mempooltruc", false)) {
|
|
368
|
+
enforce_flag = true;
|
|
369
|
+
}
|
|
370
|
+
for (auto& opt : util::SplitString(argsman.GetArg("-mempooltruc", ""), ",+")) {
|
|
371
|
+
if (opt == "optin" || opt == "enforce") {
|
|
372
|
+
enforce_flag = true;
|
|
373
|
+
} else if (opt == "-optin" || opt == "-enforce") {
|
|
374
|
+
enforce_flag = false;
|
|
375
|
+
} else if (opt == "accept") {
|
|
376
|
+
accept_flag = true;
|
|
377
|
+
} else if (opt == "reject" || opt == "0") {
|
|
378
|
+
accept_flag = false;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
if (accept_flag && !*accept_flag) { // reject
|
|
383
|
+
mempool_opts.truc_policy = TRUCPolicy::Reject;
|
|
384
|
+
} else if (enforce_flag && *enforce_flag) { // enforce
|
|
385
|
+
mempool_opts.truc_policy = TRUCPolicy::Enforce;
|
|
386
|
+
} else if ((!accept_flag) && !enforce_flag) {
|
|
387
|
+
// nothing specified, leave at default
|
|
388
|
+
} else { // accept or -enforce
|
|
389
|
+
mempool_opts.truc_policy = TRUCPolicy::Accept;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
305
393
|
if (argsman.IsArgSet("-permitephemeral")) {
|
|
306
394
|
ApplyPermitEphemeralOption(argsman.GetSetting("-permitephemeral"), mempool_opts);
|
|
307
395
|
}
|
|
@@ -310,6 +398,7 @@ util::Result<void> ApplyArgsManOptions(const ArgsManager& argsman, const CChainP
|
|
|
310
398
|
// additionally validate against the initialized estimator's horizon.
|
|
311
399
|
const auto parsed = ParseDustDynamicOpt(*value, 1008);
|
|
312
400
|
if (!parsed) return util::Error{strprintf(_("Invalid mode for dustdynamic: %s (value: '%s'; expected off or [multiplier*]target:blocks or [multiplier*]mempool:kvB)"), util::ErrorString(parsed), *value)};
|
|
401
|
+
std::tie(mempool_opts.dust_relay_target, mempool_opts.dust_relay_multiplier) = parsed.value();
|
|
313
402
|
}
|
|
314
403
|
|
|
315
404
|
mempool_opts.persist_v1_dat = argsman.GetBoolArg("-persistmempoolv1", mempool_opts.persist_v1_dat);
|