aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/blockchain.cpp
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2022-01-19 13:42:32 +0100
committerJon Atack <jon@atack.com>2022-01-25 20:46:52 +0100
commit6ea56827842b9b2bd730edc38f3a7b1f46f6247b (patch)
tree640d733a2bdcd1bce0156f74ff0ff2fd92fef583 /src/rpc/blockchain.cpp
parent5d59ae0ba88849b1eb0d7350871bc19fcd5ef601 (diff)
downloadbitcoin-6ea56827842b9b2bd730edc38f3a7b1f46f6247b.tar.xz
Guard CBlockIndex::nStatus/nFile/nDataPos/nUndoPos by cs_main
Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
Diffstat (limited to 'src/rpc/blockchain.cpp')
-rw-r--r--src/rpc/blockchain.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp
index 8df0aac203..c5697983d5 100644
--- a/src/rpc/blockchain.cpp
+++ b/src/rpc/blockchain.cpp
@@ -818,7 +818,8 @@ static RPCHelpMan getblockfrompeer()
throw JSONRPCError(RPC_MISC_ERROR, "Block header missing");
}
- if (index->nStatus & BLOCK_HAVE_DATA) {
+ const bool block_has_data = WITH_LOCK(::cs_main, return index->nStatus & BLOCK_HAVE_DATA);
+ if (block_has_data) {
throw JSONRPCError(RPC_MISC_ERROR, "Block already downloaded");
}