Guard CBlockIndex::nStatus/nFile/nDataPos/nUndoPos by cs_main

Co-authored-by: Vasil Dimov <vd@FreeBSD.org>
This commit is contained in:
Jon Atack
2022-01-19 13:42:32 +01:00
parent 5d59ae0ba8
commit 6ea5682784
5 changed files with 19 additions and 11 deletions

View File

@@ -240,7 +240,8 @@ static RPCHelpMan getrawtransaction()
if (!tx) {
std::string errmsg;
if (blockindex) {
if (!(blockindex->nStatus & BLOCK_HAVE_DATA)) {
const bool block_has_data = WITH_LOCK(::cs_main, return blockindex->nStatus & BLOCK_HAVE_DATA);
if (!block_has_data) {
throw JSONRPCError(RPC_MISC_ERROR, "Block not available");
}
errmsg = "No such transaction found in the provided block";