aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2024-01-17 16:42:15 +0100
committerMarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>2024-01-17 16:48:42 +0100
commitfa9108941fa1a0e83484114e2d8a99d264c2ad09 (patch)
tree9946557f0cd8fd5e56308d9ee4ee2dd69b6d347b
parentc818607ed59eb87be65b558f34bd6df049f6b238 (diff)
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.
-rw-r--r--src/rpc/blockchain.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 7d04fb06d5..34d308211b 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -2785,12 +2785,11 @@ static RPCHelpMan loadtxoutset()
if (!chainman.ActivateSnapshot(afile, metadata, false)) {
throw JSONRPCError(RPC_INTERNAL_ERROR, "Unable to load UTXO snapshot " + fs::PathToString(path));
}
- CBlockIndex* new_tip{WITH_LOCK(::cs_main, return chainman.ActiveTip())};
UniValue result(UniValue::VOBJ);
result.pushKV("coins_loaded", metadata.m_coins_count);
- result.pushKV("tip_hash", new_tip->GetBlockHash().ToString());
- result.pushKV("base_height", new_tip->nHeight);
+ result.pushKV("tip_hash", snapshot_start_block->GetBlockHash().ToString());
+ result.pushKV("base_height", snapshot_start_block->nHeight);
result.pushKV("path", fs::PathToString(path));
return result;
},