Bitcoin ABC  0.22.12
P2P Digital Currency
blockchain.h
Go to the documentation of this file.
1 // Copyright (c) 2017-2019 The Bitcoin developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_RPC_BLOCKCHAIN_H
6 #define BITCOIN_RPC_BLOCKCHAIN_H
7 
8 #include <sync.h>
9 
10 #include <univalue.h>
11 
12 class CBlock;
13 class CBlockIndex;
14 class ChainstateManager;
15 class Config;
16 class CTxMemPool;
17 class JSONRPCRequest;
18 struct NodeContext;
19 namespace util {
20 class Ref;
21 } // namespace util
22 
23 extern RecursiveMutex cs_main;
24 
25 UniValue getblockchaininfo(const Config &config, const JSONRPCRequest &request);
26 
33 double GetDifficulty(const CBlockIndex *blockindex);
34 
36 void RPCNotifyBlockChange(const CBlockIndex *pindex);
37 
39 UniValue blockToJSON(const CBlock &block, const CBlockIndex *tip,
40  const CBlockIndex *blockindex, bool txDetails = false)
41  LOCKS_EXCLUDED(cs_main);
42 
45 
47 UniValue MempoolToJSON(const CTxMemPool &pool, bool verbose = false);
48 
51  const CBlockIndex *blockindex)
52  LOCKS_EXCLUDED(cs_main);
53 
54 NodeContext &EnsureNodeContext(const util::Ref &context);
55 CTxMemPool &EnsureMemPool(const util::Ref &context);
56 ChainstateManager &EnsureChainman(const util::Ref &context);
57 
58 #endif // BITCOIN_RPC_BLOCKCHAIN_H
Definition: httprpc.h:13
UniValue MempoolInfoToJSON(const CTxMemPool &pool)
Mempool information to JSON.
Definition: block.h:62
ChainstateManager & EnsureChainman(const util::Ref &context)
Definition: blockchain.cpp:71
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
Definition: validation.h:1023
double GetDifficulty(const CBlockIndex *blockindex)
Get the required difficulty of the next block w/r/t the given block index.
Definition: blockchain.cpp:82
UniValue blockheaderToJSON(const CBlockIndex *tip, const CBlockIndex *blockindex) LOCKS_EXCLUDED(cs_main)
Block header to JSON.
Definition: blockchain.cpp:111
Definition: config.h:19
NodeContext struct containing references to chain state and connection state.
Definition: context.h:35
UniValue MempoolToJSON(const CTxMemPool &pool, bool verbose=false)
Mempool to JSON.
Definition: blockchain.cpp:577
CTxMemPool & EnsureMemPool(const util::Ref &context)
Definition: blockchain.cpp:62
UniValue getblockchaininfo(const Config &config, const JSONRPCRequest &request)
NodeContext & EnsureNodeContext(const util::Ref &context)
Definition: blockchain.cpp:55
RecursiveMutex cs_main
Global state.
Definition: validation.cpp:95
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:468
#define LOCKS_EXCLUDED(...)
Definition: threadsafety.h:55
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: blockindex.h:23
UniValue blockToJSON(const CBlock &block, const CBlockIndex *tip, const CBlockIndex *blockindex, bool txDetails=false) LOCKS_EXCLUDED(cs_main)
Block description to JSON.
Definition: blockchain.cpp:145
void RPCNotifyBlockChange(const CBlockIndex *pindex)
Callback for when block tip changed.
Definition: blockchain.cpp:246