Skip to content

Commit 4524dfd

Browse files
knstMacroFake
andcommitted
Merge bitcoin#26395: rpc: add missing lock around chainman.ActiveTip()
f5ff3d7 rpc: add missing lock around chainman.ActiveTip() (Andrew Toth) Pull request description: bitcoin#23927 seems to have missed a lock around `chainman.ActiveChain()`. ACKs for top commit: aureleoules: ACK f5ff3d7 Tree-SHA512: 3f116ca44c1b2bc0c7042698249ea3417dfb7c0bb81158a7ceecd087f1e02baa89948f9bb7924b1757798a1691a7de6e886aa72a0a9e227c13a3f512cc59d6c9 Co-authored-by: MacroFake <falke.marco@gmail.com>
1 parent 28532b2 commit 4524dfd

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/rpc/blockchain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ static RPCHelpMan getblockfrompeer()
520520

521521
// Fetching blocks before the node has syncing past their height can prevent block files from
522522
// being pruned, so we avoid it if the node is in prune mode.
523-
if (index->nHeight > WITH_LOCK(::cs_main, return chainman.ActiveChain().Tip()->nHeight) && node::fPruneMode) {
523+
if (node::fPruneMode && index->nHeight > WITH_LOCK(chainman.GetMutex(), return chainman.ActiveTip()->nHeight)) {
524524
throw JSONRPCError(RPC_MISC_ERROR, "In prune mode, only blocks that the node has already synced previously can be fetched from a peer");
525525
}
526526

0 commit comments

Comments
 (0)