Skip to content

Commit ec92d23

Browse files
author
MacroFake
committed
Merge bitcoin/bitcoin#26395: rpc: add missing lock around chainman.ActiveTip()
f5ff3d7 rpc: add missing lock around chainman.ActiveTip() (Andrew Toth) Pull request description: bitcoin/bitcoin#23927 seems to have missed a lock around `chainman.ActiveChain()`. ACKs for top commit: aureleoules: ACK f5ff3d7 Tree-SHA512: 3f116ca44c1b2bc0c7042698249ea3417dfb7c0bb81158a7ceecd087f1e02baa89948f9bb7924b1757798a1691a7de6e886aa72a0a9e227c13a3f512cc59d6c9
2 parents e25de33 + f5ff3d7 commit ec92d23

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/rpc/blockchain.cpp

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

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

0 commit comments

Comments
 (0)