Skip to content

Commit fa91089

Browse files
author
MarcoFalke
committed
rpc: Fix race in loadtxoutset
The tip may have advanced, also if it did not, there is no reason to have two variables point to the same block.
1 parent c818607 commit fa91089

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
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
},

0 commit comments

Comments
 (0)