34 #include <validation.h>
37 #if defined(HAVE_CONFIG_H)
43 #include <boost/signals2/signal.hpp>
48 class NodeImpl :
public Node
51 NodeImpl(
NodeContext* context) { setContext(context); }
56 bool baseInitialize()
override
65 void appShutdown()
override
70 void startShutdown()
override
80 void mapPort(
bool use_upnp)
override
94 bool getNodesStats(NodesStats& stats)
override
99 std::vector<CNodeStats> stats_temp;
102 stats.reserve(stats_temp.size());
103 for (
auto& node_stats_temp : stats_temp) {
104 stats.emplace_back(std::move(node_stats_temp),
false,
CNodeStateStats());
110 for (
auto& node_stats : stats) {
111 std::get<1>(node_stats) =
119 bool getBanned(
banmap_t& banmap)
override
127 bool ban(
const CNetAddr& net_addr, int64_t ban_time_offset)
override
135 bool unban(
const CSubNet& ip)
override
143 bool disconnectByAddress(
const CNetAddr& net_addr)
override
150 bool disconnectById(
NodeId id)
override
161 bool getHeaderTip(
int& height, int64_t& block_time)
override
171 int getNumBlocks()
override
176 uint256 getBestBlockHash()
override
181 int64_t getLastBlockTime()
override
189 double getVerificationProgress()
override
201 void setNetworkActive(
bool active)
override
208 CFeeRate estimateSmartFee(
int num_blocks,
bool conservative,
int* returned_target =
nullptr)
override
212 if (returned_target) {
218 UniValue executeRpc(
const std::string& command,
const UniValue& params,
const std::string& uri)
override
222 req.strMethod = command;
229 bool getUnspentOutput(
const COutPoint& output,
Coin& coin)
override
234 WalletClient& walletClient()
override
238 std::unique_ptr<Handler> handleInitMessage(InitMessageFn fn)
override
242 std::unique_ptr<Handler> handleMessageBox(MessageBoxFn fn)
override
246 std::unique_ptr<Handler> handleQuestion(QuestionFn fn)
override
250 std::unique_ptr<Handler> handleShowProgress(ShowProgressFn fn)
override
254 std::unique_ptr<Handler> handleNotifyNumConnectionsChanged(NotifyNumConnectionsChangedFn fn)
override
258 std::unique_ptr<Handler> handleNotifyNetworkActiveChanged(NotifyNetworkActiveChangedFn fn)
override
262 std::unique_ptr<Handler> handleNotifyAlertChanged(NotifyAlertChangedFn fn)
override
266 std::unique_ptr<Handler> handleBannedListChanged(BannedListChangedFn fn)
override
270 std::unique_ptr<Handler> handleNotifyBlockTip(NotifyBlockTipFn fn)
override
273 fn(sync_state, BlockTip{block->nHeight, block->GetBlockTime(), block->GetBlockHash()},
277 std::unique_ptr<Handler> handleNotifyHeaderTip(NotifyHeaderTipFn fn)
override
281 fn(sync_state, BlockTip{block->nHeight, block->GetBlockTime(), block->GetBlockHash()},
UniValue execute(const JSONRPCRequest &request) const
Execute a method.
std::vector< std::string > listCommands() const
Returns a list of registered commands.
void InitLogging(const ArgsManager &args)
Initialize global loggers.
SynchronizationState
Current sync state passed to tip changed callbacks.
BCLog::Logger & LogInstance()
#define TRY_LOCK(cs, name)
void Shutdown(NodeContext &node)
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
CChain & ChainActive()
Please prefer the identical ChainstateManager::ActiveChain.
std::unique_ptr< BanMan > banman
std::unique_ptr< CTxMemPool > mempool
uint32_t GetCategoryMask() const
bool IsInitialBlockDownload() const
Check whether we are doing an initial block download (synchronizing from disk or network) ...
std::unique_ptr< Handler > MakeHandler(boost::signals2::connection connection)
Return handler wrapping a boost signal connection.
void RPCUnsetTimerInterface(RPCTimerInterface *iface)
Unset factory function for timers.
CBlockPolicyEstimator feeEstimator
CBlockIndex * Tip() const
Returns the index entry for the tip of this chain, or nullptr if none.
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats)
Get statistics from node state.
int Height() const
Return the maximal height in the chain.
bool AppInitSanityChecks()
Initialization sanity checks: ecc init, sanity checks, dir lock.
NodeContext struct containing references to chain state and connection state.
CFeeRate estimateSmartFee(int confTarget, FeeCalculation *feeCalc, bool conservative) const
Estimate feerate needed to get be included in a block within confTarget blocks.
std::unique_ptr< CConnman > connman
void Interrupt(NodeContext &node)
Interrupt threads.
CBlockIndex * pindexBestHeader
Best header we've seen so far (used for getheaders queries' starting points).
interfaces::WalletClient * wallet_client
Reference to chain client that should used to load or create wallets opened by the gui...
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
Block and header tip information.
std::atomic_bool fImporting
An outpoint - a combination of a transaction hash and an index n into its vout.
#define WITH_LOCK(cs, code)
Run code while locking a mutex.
Type-safe dynamic reference.
void RPCSetTimerInterfaceIfUnset(RPCTimerInterface *iface)
Set the factory function for timer, but only, if unset.
std::atomic_bool fReindex
CChainState & ChainstateActive()
Please prefer the identical ChainstateManager::ActiveChainstate.
bilingual_str GetWarnings(bool verbose)
Format a string that describes several potential problems detected by the core.
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override
Retrieve the Coin (unspent transaction output) for a given outpoint.
bool AppInitParameterInteraction(const ArgsManager &args)
Initialization: parameter interaction.
The block chain is a tree shaped structure starting with the genesis block at the root...
const CBlock & GenesisBlock() const
const CChainParams & Params()
Return the currently selected parameters.
double GuessVerificationProgress(const ChainTxData &data, const CBlockIndex *pindex)
Guess how far we are in the verification process at the given block index require cs_main if pindex h...
bool AppInitBasicSetup(ArgsManager &args)
Initialize bitcoin core: Basic context setup.
Fee rate in satoshis per kilobyte: CAmount / kB.
CCoinsViewCache & CoinsTip() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
std::map< CSubNet, CBanEntry > banmap_t
bool GetProxy(enum Network net, proxyType &proxyInfoOut)
bool AppInitInterfaces(NodeContext &node)
Initialize node and wallet interface pointers.
bool AppInitLockDataDirectory()
Lock bitcoin core data directory.
bool AppInitMain(const util::Ref &context, NodeContext &node, interfaces::BlockAndHeaderTipInfo *tip_info)
Bitcoin core main initialization.
CClientUIInterface uiInterface
int nHeight
height of the entry in the chain. The genesis block has height 0
int64_t GetBlockTime() const
std::unique_ptr< Node > MakeNode(NodeContext *context)
Return implementation of Node interface.
void InitParameterInteraction(ArgsManager &args)
Parameter interaction: change current parameters depending on various rules.
#define Assert(val)
Identity function.
uint256 GetBlockHash() const