1
1
mirror of https://github.com/bitcoin/bitcoin.git synced 2024-05-17 23:56:39 +00:00

rpc: add missing lock around chainman.ActiveTip()

This commit is contained in:
Andrew Toth 2022-10-26 11:46:39 -04:00
parent 88502ecf08
commit f5ff3d773c

View File

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