Skip to content

Commit b297426

Browse files
committed
Add -stopatheight for benchmarking
1 parent a550f6e commit b297426

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

src/init.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,8 @@ std::string HelpMessage(HelpMessageMode mode)
436436
strUsage += HelpMessageOpt("-dropmessagestest=<n>", "Randomly drop 1 of every <n> network messages");
437437
strUsage += HelpMessageOpt("-fuzzmessagestest=<n>", "Randomly fuzz 1 of every <n> network messages");
438438
strUsage += HelpMessageOpt("-stopafterblockimport", strprintf("Stop running after importing blocks from disk (default: %u)", DEFAULT_STOPAFTERBLOCKIMPORT));
439+
strUsage += HelpMessageOpt("-stopatheight", strprintf("Stop running after reaching the given height in the main chain (default: %u)", DEFAULT_STOPATHEIGHT));
440+
439441
strUsage += HelpMessageOpt("-limitancestorcount=<n>", strprintf("Do not accept transactions if number of in-mempool ancestors is <n> or more (default: %u)", DEFAULT_ANCESTOR_LIMIT));
440442
strUsage += HelpMessageOpt("-limitancestorsize=<n>", strprintf("Do not accept transactions whose size with all in-mempool ancestors exceeds <n> kilobytes (default: %u)", DEFAULT_ANCESTOR_SIZE_LIMIT));
441443
strUsage += HelpMessageOpt("-limitdescendantcount=<n>", strprintf("Do not accept transactions if any ancestor would have <n> or more in-mempool descendants (default: %u)", DEFAULT_DESCENDANT_LIMIT));

src/validation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2537,6 +2537,9 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
25372537
return false;
25382538
}
25392539

2540+
int nStopAtHeight = GetArg("-stopatheight", DEFAULT_STOPATHEIGHT);
2541+
if (nStopAtHeight && pindexNewTip->nHeight >= nStopAtHeight) StartShutdown();
2542+
25402543
return true;
25412544
}
25422545

src/validation.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ static const int MAX_UNCONNECTING_HEADERS = 10;
145145

146146
static const bool DEFAULT_PEERBLOOMFILTERS = true;
147147

148+
/** Default for -stopatheight */
149+
static const int DEFAULT_STOPATHEIGHT = 0;
150+
148151
struct BlockHasher
149152
{
150153
size_t operator()(const uint256& hash) const { return hash.GetCheapHash(); }

0 commit comments

Comments
 (0)