Skip to content

Commit 5f3a057

Browse files
committed
Merge bitcoin#29262: rpc: Fix race in loadtxoutset
5555d8d test: Use blocks_path where possible (MarcoFalke) fa91089 rpc: Fix race in loadtxoutset (MarcoFalke) Pull request description: The tip may have advanced, also if it did not, there is no reason to have two variables point to the same block. Fixes bitcoin#27596 (comment) ACKs for top commit: achow101: ACK 5555d8d pablomartin4btc: ACK 5555d8d BrandonOdiwuor: Code Review ACK 5555d8d Tree-SHA512: 23a82924a915b61bb1adab8ad20ec8914139c8ee647817af34ca27ee310a2e45833d8b285503e0feebe63e4667193d6d98cfcbbc1509bf40712225e04dd19e8b
2 parents ac3901e + 5555d8d commit 5f3a057

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/rpc/blockchain.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2785,12 +2785,11 @@ static RPCHelpMan loadtxoutset()
27852785
if (!chainman.ActivateSnapshot(afile, metadata, false)) {
27862786
throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to load UTXO snapshot " + fs::PathToString(path));
27872787
}
2788-
CBlockIndex* new_tip{WITH_LOCK(::cs_main, return chainman.ActiveTip())};
27892788

27902789
UniValue result(UniValue::VOBJ);
27912790
result.pushKV("coins_loaded", metadata.m_coins_count);
2792-
result.pushKV("tip_hash", new_tip->GetBlockHash().ToString());
2793-
result.pushKV("base_height", new_tip->nHeight);
2791+
result.pushKV("tip_hash", snapshot_start_block->GetBlockHash().ToString());
2792+
result.pushKV("base_height", snapshot_start_block->nHeight);
27942793
result.pushKV("path", fs::PathToString(path));
27952794
return result;
27962795
},

test/functional/test_framework/test_framework.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,5 +1021,4 @@ def is_bdb_compiled(self):
10211021
return self.config["components"].getboolean("USE_BDB")
10221022

10231023
def has_blockfile(self, node, filenum: str):
1024-
blocksdir = node.datadir_path / self.chain / 'blocks'
1025-
return (blocksdir / f"blk{filenum}.dat").is_file()
1024+
return (node.blocks_path/ f"blk{filenum}.dat").is_file()

0 commit comments

Comments
 (0)