rpc: Add lock annotations to block{,header}ToJSON

pull/764/head
MarcoFalke 6 years ago
parent fab00a5cb9
commit faea56400d
No known key found for this signature in database
GPG Key ID: CE2B75697E69A548

@ -94,6 +94,8 @@ static int ComputeNextBlockAndDepth(const CBlockIndex* tip, const CBlockIndex* b
UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex) UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex)
{ {
// Serialize passed information without accessing chain state of the active chain! // Serialize passed information without accessing chain state of the active chain!
AssertLockNotHeld(cs_main); // For performance reasons
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
result.pushKV("hash", blockindex->GetBlockHash().GetHex()); result.pushKV("hash", blockindex->GetBlockHash().GetHex());
const CBlockIndex* pnext; const CBlockIndex* pnext;
@ -121,6 +123,8 @@ UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex
UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, bool txDetails) UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, bool txDetails)
{ {
// Serialize passed information without accessing chain state of the active chain! // Serialize passed information without accessing chain state of the active chain!
AssertLockNotHeld(cs_main); // For performance reasons
UniValue result(UniValue::VOBJ); UniValue result(UniValue::VOBJ);
result.pushKV("hash", blockindex->GetBlockHash().GetHex()); result.pushKV("hash", blockindex->GetBlockHash().GetHex());
const CBlockIndex* pnext; const CBlockIndex* pnext;

@ -5,9 +5,13 @@
#ifndef BITCOIN_RPC_BLOCKCHAIN_H #ifndef BITCOIN_RPC_BLOCKCHAIN_H
#define BITCOIN_RPC_BLOCKCHAIN_H #define BITCOIN_RPC_BLOCKCHAIN_H
#include <vector>
#include <stdint.h>
#include <amount.h> #include <amount.h>
#include <sync.h>
#include <stdint.h>
#include <vector>
extern RecursiveMutex cs_main;
class CBlock; class CBlock;
class CBlockIndex; class CBlockIndex;
@ -28,7 +32,7 @@ double GetDifficulty(const CBlockIndex* blockindex);
void RPCNotifyBlockChange(bool ibd, const CBlockIndex *); void RPCNotifyBlockChange(bool ibd, const CBlockIndex *);
/** Block description to JSON */ /** Block description to JSON */
UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, bool txDetails = false); UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, bool txDetails = false) LOCKS_EXCLUDED(cs_main);
/** Mempool information to JSON */ /** Mempool information to JSON */
UniValue MempoolInfoToJSON(const CTxMemPool& pool); UniValue MempoolInfoToJSON(const CTxMemPool& pool);
@ -37,7 +41,7 @@ UniValue MempoolInfoToJSON(const CTxMemPool& pool);
UniValue MempoolToJSON(const CTxMemPool& pool, bool verbose = false); UniValue MempoolToJSON(const CTxMemPool& pool, bool verbose = false);
/** Block header to JSON */ /** Block header to JSON */
UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex); UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex) LOCKS_EXCLUDED(cs_main);
/** Used by getblockstats to get feerates at different percentiles by weight */ /** Used by getblockstats to get feerates at different percentiles by weight */
void CalculatePercentilesByWeight(CAmount result[NUM_GETBLOCKSTATS_PERCENTILES], std::vector<std::pair<CAmount, int64_t>>& scores, int64_t total_weight); void CalculatePercentilesByWeight(CAmount result[NUM_GETBLOCKSTATS_PERCENTILES], std::vector<std::pair<CAmount, int64_t>>& scores, int64_t total_weight);

Loading…
Cancel
Save