Skip to content

Commit c286a22

Browse files
committed
Add debug startup parameter -fastprune for more effective pruning tests
1 parent 5e11226 commit c286a22

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/chainparams.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ class CRegTestParams : public CChainParams {
406406
pchMessageStart[2] = 0xb5;
407407
pchMessageStart[3] = 0xda;
408408
nDefaultPort = 18444;
409-
nPruneAfterHeight = 1000;
409+
nPruneAfterHeight = gArgs.GetBoolArg("-fastprune", false) ? 100 : 1000;
410410
m_assumed_blockchain_size = 0;
411411
m_assumed_chain_state_size = 0;
412412

src/init.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ void SetupServerArgs(NodeContext& node)
386386
#endif
387387
argsman.AddArg("-assumevalid=<hex>", strprintf("If this block is in the chain assume that it and its ancestors are valid and potentially skip their script verification (0 to verify all, default: %s, testnet: %s, signet: %s)", defaultChainParams->GetConsensus().defaultAssumeValid.GetHex(), testnetChainParams->GetConsensus().defaultAssumeValid.GetHex(), signetChainParams->GetConsensus().defaultAssumeValid.GetHex()), ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
388388
argsman.AddArg("-blocksdir=<dir>", "Specify directory to hold blocks subdirectory for *.dat files (default: <datadir>)", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
389+
argsman.AddArg("-fastprune", "Use smaller block files and lower minimum prune height for testing purposes", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::DEBUG_TEST);
389390
#if HAVE_SYSTEM
390391
argsman.AddArg("-blocknotify=<cmd>", "Execute command when the best block changes (%s in cmd is replaced by block hash)", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
391392
#endif

src/validation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3212,7 +3212,7 @@ static bool FindBlockPos(FlatFilePos &pos, unsigned int nAddSize, unsigned int n
32123212

32133213
bool finalize_undo = false;
32143214
if (!fKnown) {
3215-
while (vinfoBlockFile[nFile].nSize + nAddSize >= MAX_BLOCKFILE_SIZE) {
3215+
while (vinfoBlockFile[nFile].nSize + nAddSize >= (gArgs.GetBoolArg("-fastprune", false) ? 0x10000 /* 64kb */ : MAX_BLOCKFILE_SIZE)) {
32163216
// when the undo file is keeping up with the block file, we want to flush it explicitly
32173217
// when it is lagging behind (more blocks arrive than are being connected), we let the
32183218
// undo block write case handle it
@@ -4004,7 +4004,7 @@ void BlockManager::FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPr
40044004

40054005
static FlatFileSeq BlockFileSeq()
40064006
{
4007-
return FlatFileSeq(GetBlocksDir(), "blk", BLOCKFILE_CHUNK_SIZE);
4007+
return FlatFileSeq(GetBlocksDir(), "blk", gArgs.GetBoolArg("-fastprune", false) ? 0x4000 /* 16kb */ : BLOCKFILE_CHUNK_SIZE);
40084008
}
40094009

40104010
static FlatFileSeq UndoFileSeq()

0 commit comments

Comments
 (0)