Bugfix: RPC/blockchain: pruneblockchain: Return the height of the actual last pruned block

From 0.14 (2017 Mar) until before 0.19 (2019 Nov), the height of the last
block pruned was returned, subject to a bug if there were blocks left unpruned
due to sharing files with later blocks.

In #15991, this was "fixed" to the current implementation, introducing a new
bug: now, it returns the first *unpruned* block.

Since the user provides the parameter as a block to include in pruning, it
makes more sense to fix the behaviour to match the documentation.
This commit is contained in:
Luke Dashjr
2022-03-21 18:38:54 +00:00
parent 2cf8c2caea
commit e593ae07c4
3 changed files with 5 additions and 5 deletions

View File

@@ -291,7 +291,7 @@ class PruneTest(BitcoinTestFramework):
def prune(index):
ret = node.pruneblockchain(height=height(index))
assert_equal(ret, node.getblockchaininfo()['pruneheight'])
assert_equal(ret + 1, node.getblockchaininfo()['pruneheight'])
def has_block(index):
return os.path.isfile(os.path.join(self.nodes[node_number].datadir, self.chain, "blocks", f"blk{index:05}.dat"))