aboutsummaryrefslogtreecommitdiff
path: root/src/node/context.h
diff options
context:
space:
mode:
authorRussell Yanofsky <[email protected]>2019-09-17 18:28:03 -0400
committerRussell Yanofsky <[email protected]>2019-10-28 10:30:51 -0400
commite6f4f895d5e42feaf7bfa5f41e80292aaa73cd7d (patch)
tree1c12f814ae2ac88316066d334274354c669d7aa5 /src/node/context.h
parentMOVEONLY: Move NodeContext struct to node/context.h (diff)
downloaddiscoin-e6f4f895d5e42feaf7bfa5f41e80292aaa73cd7d.tar.xz
discoin-e6f4f895d5e42feaf7bfa5f41e80292aaa73cd7d.zip
Pass NodeContext, ConnMan, BanMan references more places
So g_connman and g_banman globals can be removed next commit.
Diffstat (limited to 'src/node/context.h')
-rw-r--r--src/node/context.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/node/context.h b/src/node/context.h
index 3dd90ba96..f98550105 100644
--- a/src/node/context.h
+++ b/src/node/context.h
@@ -13,11 +13,26 @@ class Chain;
class ChainClient;
} // namespace interfaces
-//! Pointers to interfaces used during init and destroyed on shutdown.
+//! NodeContext struct containing references to chain state and connection
+//! state.
+//!
+//! 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. More variables could be added to this struct (particularly
+//! references to validation and mempool objects) to eliminate use of globals
+//! and make code more modular and testable. The struct isn't intended to have
+//! any member functions. It should just be a collection of references that can
+//! be used without pulling in unwanted dependencies or functionality.
struct NodeContext
{
std::unique_ptr<interfaces::Chain> chain;
std::vector<std::unique_ptr<interfaces::ChainClient>> chain_clients;
+
+ //! Declare default constructor and destructor that are not inline, so code
+ //! instantiating the NodeContext struct doesn't need to #include class
+ //! definitions for all the unique_ptr members.
+ NodeContext();
+ ~NodeContext();
};
#endif // BITCOIN_NODE_CONTEXT_H