[#node-NodeContext]
= xref:node.adoc[node]::NodeContext
:relfileprefix: ../
:mrdocs:

NodeContext struct containing references to chain state and connection state&period;

== Synopsis

Declared in `&lt;node&sol;context&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
struct NodeContext;
----

== Description

This is used by init, rpc, and test code to pass object references around without needing to declare the same variables and parameters repeatedly, or to use globals&period; More variables could be added to this struct (particularly references to validation objects) to eliminate use of globals and make code more modular and testable&period; The struct isn&apos;t intended to have any member functions&period; It should just be a collection of references that can be used without pulling in unwanted dependencies or functionality&period;

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:node/NodeContext/2constructor.adoc[`NodeContext`]         [.small]#[constructor]#
| Declare default constructor and destructor that are not inline, so code instantiating the NodeContext struct doesn&apos;t need to &num;include class definitions for all the unique&lowbar;ptr members&period;
| xref:node/NodeContext/2destructor.adoc[`&#126;NodeContext`] [.small]#[destructor]#
| Destroy the node context and release its owned members&period;
|===


== Data Members

[cols="1,4"]
|===
| Name| Description
| xref:node/NodeContext/addrman.adoc[`addrman`] 
| Address manager tracking known peer addresses&period;
| xref:node/NodeContext/args.adoc[`args`] 
| Parsed command&hyphen;line and configuration arguments (memory not owned by this struct)&period;
| xref:node/NodeContext/background_init_thread.adoc[`background&lowbar;init&lowbar;thread`] 
| Background thread that performs the remainder of node initialization&period;
| xref:node/NodeContext/banman.adoc[`banman`] 
| Tracks and persists banned and discouraged peers&period;
| xref:node/NodeContext/chain.adoc[`chain`] 
| Interface giving access to the node&apos;s chain state&period;
| xref:node/NodeContext/chain_clients.adoc[`chain&lowbar;clients`] 
| List of all chain clients (wallet processes or other client) connected to node&period;
| xref:node/NodeContext/chainman.adoc[`chainman`] 
| Owns and coordinates the active and background chainstates&period;
| xref:node/NodeContext/connman.adoc[`connman`] 
| Manages the node&apos;s peer&hyphen;to&hyphen;peer network connections&period;
| xref:node/NodeContext/ecc_context.adoc[`ecc&lowbar;context`] 
| Owns the process&hyphen;wide libsecp256k1 signing and verification context&period;
| xref:node/NodeContext/exit_status.adoc[`exit&lowbar;status`] 
| Process exit status, set to a failure value when a fatal error occurs&period;
| xref:node/NodeContext/fee_estimator_man.adoc[`fee&lowbar;estimator&lowbar;man`] 
| Tracks fee&hyphen;rate estimates derived from observed transactions&period;
| xref:node/NodeContext/indexes.adoc[`indexes`] 
| Active optional block&hyphen;chain indexes (memory not owned by this struct)&period;
| xref:node/NodeContext/init.adoc[`init`] 
| Init interface for initializing current process and connecting to other processes&period;
| xref:node/NodeContext/kernel.adoc[`kernel`] 
| libbitcoin&lowbar;kernel context
| xref:node/NodeContext/mempool.adoc[`mempool`] 
| The node&apos;s memory pool of unconfirmed transactions&period;
| xref:node/NodeContext/mining.adoc[`mining`] 
| Reference to chain client that should used to load or create wallets opened by the gui&period;
| xref:node/NodeContext/mining_args.adoc[`mining&lowbar;args`] 
| Mining options used to create block templates&period; This value member is an exception to the dependency guidance above because BlockCreateOptions is a minimal dependency&period; It could be moved to the BlockTemplateCache proposed in bitcoin&sol;bitcoin&num;33421&period;
| xref:node/NodeContext/netgroupman.adoc[`netgroupman`] 
| Maps peer addresses to network groups for connection bucketing&period;
| xref:node/NodeContext/notifications.adoc[`notifications`] 
| Issues blocking calls about sync status, errors and warnings
| xref:node/NodeContext/peerman.adoc[`peerman`] 
| Drives peer&hyphen;to&hyphen;peer message processing and per&hyphen;peer state&period;
| xref:node/NodeContext/rpc_interruption_point.adoc[`rpc&lowbar;interruption&lowbar;point`] 
| Hook invoked at interruption points during long&hyphen;running RPCs&period;
| xref:node/NodeContext/scheduler.adoc[`scheduler`] 
| Runs deferred and recurring background tasks&period;
| xref:node/NodeContext/shutdown_request.adoc[`shutdown&lowbar;request`] 
| Function to request a shutdown&period;
| xref:node/NodeContext/shutdown_signal.adoc[`shutdown&lowbar;signal`] 
| Interrupt object used to track whether node shutdown was requested&period;
| xref:node/NodeContext/tor_controller.adoc[`tor&lowbar;controller`] 
| Manages the node&apos;s Tor hidden service and control connection&period;
| xref:node/NodeContext/validation_signals.adoc[`validation&lowbar;signals`] 
| Issues calls about blocks and transactions
| xref:node/NodeContext/wallet_loader.adoc[`wallet&lowbar;loader`] 
| Interface used to load or create wallets, owned elsewhere&period;
| xref:node/NodeContext/warnings.adoc[`warnings`] 
| Manages all the node warnings
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:node/BroadcastTransaction.adoc[`BroadcastTransaction`]
| Submit a transaction to the mempool and (optionally) relay it to all P2P peers&period;
| xref:node/FindCoins.adoc[`FindCoins`]
| Look up unspent output information&period; Returns coins in the mempool and in the current chain UTXO set&period; Iterates through all the keys in the map and populates the values&period;
| xref:AppInitInterfaces.adoc[`&colon;&colon;AppInitInterfaces`]
| Initialize node and wallet interface pointers&period; Has no prerequisites or side effects besides allocating memory&period;
| xref:AppInitMain.adoc[`&colon;&colon;AppInitMain`]
| Bitcoin core main initialization&period;
| xref:CreateUTXOSnapshot.adoc[`&colon;&colon;CreateUTXOSnapshot`]
| Helper to create UTXO snapshots given a chainstate and a file handle&period;
| xref:EnsureAddrman.adoc[`&colon;&colon;EnsureAddrman`]
| Get the address manager from a node context, asserting it is present&period;
| xref:EnsureAnyNodeContext.adoc[`&colon;&colon;EnsureAnyNodeContext`]
| Extract the node context from an opaque RPC context, asserting it is present&period;
| xref:EnsureArgsman.adoc[`&colon;&colon;EnsureArgsman`]
| Get the argument manager from a node context, asserting it is present&period;
| xref:EnsureBanman.adoc[`&colon;&colon;EnsureBanman`]
| Get the ban manager from a node context, asserting it is present&period;
| xref:EnsureChainman.adoc[`&colon;&colon;EnsureChainman`]
| Get the chainstate manager from a node context, asserting it is present&period;
| xref:EnsureConnman.adoc[`&colon;&colon;EnsureConnman`]
| Get the connection manager from a node context, asserting it is present&period;
| xref:EnsureFeeEstimatorMan.adoc[`&colon;&colon;EnsureFeeEstimatorMan`]
| Get the fee estimator from a node context, asserting it is present&period;
| xref:EnsureMemPool.adoc[`&colon;&colon;EnsureMemPool`]
| Get the mempool from a node context, asserting it is present&period;
| xref:EnsureMining.adoc[`&colon;&colon;EnsureMining`]
| Get the mining interface from a node context, asserting it is present&period;
| xref:EnsurePeerman.adoc[`&colon;&colon;EnsurePeerman`]
| Get the peer manager from a node context, asserting it is present&period;
| xref:InitContext.adoc[`&colon;&colon;InitContext`]
| Initialize node context shutdown and args variables&period;
| xref:Interrupt.adoc[`&colon;&colon;Interrupt`]
| Interrupt threads
| xref:Shutdown.adoc[`&colon;&colon;Shutdown`]
| Shut down the node, stopping threads and releasing resources&period;
| xref:ShutdownRequested.adoc[`&colon;&colon;ShutdownRequested`]
| Return whether node shutdown was requested&period;
| xref:StartIndexBackgroundSync.adoc[`&colon;&colon;StartIndexBackgroundSync`]
| Validates requirements to run the indexes and spawns each index initial sync thread
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
