aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorAndrew Toth <andrewstoth@gmail.com>2022-10-26 11:46:39 -0400
committerAndrew Toth <andrewstoth@gmail.com>2022-10-26 11:46:39 -0400
commitf5ff3d773c2f781016b6b047ea8d4aa029756544 (patch)
treecd1e9c7292f1b5d22e9c1b624eff2261ab8be730 /src/rpc
parent88502ecf08c960864ff0c6ddedcd44ef50a4028d (diff)
downloadbitcoin-f5ff3d773c2f781016b6b047ea8d4aa029756544.tar.xz
rpc: add missing lock around chainman.ActiveTip()
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/blockchain.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 39ee95b939..bc1028aec3 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -461,7 +461,7 @@ static RPCHelpMan getblockfrompeer()
// 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.
- 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");
}