Skip to content

Commit b281398

Browse files
committed
init: disallow reindex-chainstate when pruning
This fixes a bug where the node would be stuck in an endless loop when combining these parameters.
1 parent 91d1234 commit b281398

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/init.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,12 +853,14 @@ bool AppInitParameterInteraction(const ArgsManager& args)
853853
nLocalServices = ServiceFlags(nLocalServices | NODE_COMPACT_FILTERS);
854854
}
855855

856-
// if using block pruning, then disallow txindex and coinstatsindex
857856
if (args.GetIntArg("-prune", 0)) {
858857
if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX))
859858
return InitError(_("Prune mode is incompatible with -txindex."));
860859
if (args.GetBoolArg("-coinstatsindex", DEFAULT_COINSTATSINDEX))
861860
return InitError(_("Prune mode is incompatible with -coinstatsindex."));
861+
if (args.GetBoolArg("-reindex-chainstate", false)) {
862+
return InitError(_("Prune mode is incompatible with -reindex-chainstate. Use full -reindex instead."));
863+
}
862864
}
863865

864866
// If -forcednsseed is set to true, ensure -dnsseed has not been set to false

test/functional/feature_pruning.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ def test_invalid_command_line_options(self):
141141
expected_msg='Error: Prune mode is incompatible with -coinstatsindex.',
142142
extra_args=['-prune=550', '-coinstatsindex'],
143143
)
144+
self.nodes[0].assert_start_raises_init_error(
145+
expected_msg='Error: Prune mode is incompatible with -reindex-chainstate. Use full -reindex instead.',
146+
extra_args=['-prune=550', '-reindex-chainstate'],
147+
)
144148

145149
def test_height_min(self):
146150
assert os.path.isfile(os.path.join(self.prunedir, "blk00000.dat")), "blk00000.dat is missing, pruning too early"

0 commit comments

Comments
 (0)