From 14ec1016b9b9c859879e07fac751134f1a02ceb5 Mon Sep 17 00:00:00 2001 From: Larry Ruane Date: Fri, 27 Dec 2019 10:21:46 -0700 Subject: [PATCH] insightexplorer: LOCK(cs_main) during rpcs --- src/rpc/blockchain.cpp | 2 ++ src/rpc/misc.cpp | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 0f6c6c760..1fb2d814c 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -471,6 +471,8 @@ UniValue getblockdeltas(const UniValue& params, bool fHelp) std::string strHash = params[0].get_str(); uint256 hash(uint256S(strHash)); + LOCK(cs_main); + if (mapBlockIndex.count(hash) == 0) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 00e76a81d..430623dec 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -1099,8 +1099,11 @@ UniValue getspentinfo(const UniValue& params, bool fHelp) CSpentIndexKey key(txid, outputIndex); CSpentIndexValue value; - if (!GetSpentIndex(key, value)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unable to get spent info"); + { + LOCK(cs_main); + if (!GetSpentIndex(key, value)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Unable to get spent info"); + } } UniValue obj(UniValue::VOBJ); obj.push_back(Pair("txid", value.txid.GetHex()));