From 8922d7f6b751a3e6b3b9f6fb7961c442877fb65a Mon Sep 17 00:00:00 2001 From: Russell Yanofsky Date: Tue, 17 Sep 2019 18:59:36 -0400 Subject: scripted-diff: Remove g_connman, g_banman globals -BEGIN VERIFY SCRIPT- sed -i 's:#include :#include \n#include \n#include \n#include :' src/node/context.cpp sed -i 's/namespace interfaces {/class BanMan;\nclass CConnman;\nclass PeerLogicValidation;\n&/' src/node/context.h sed -i 's/std::unique_ptr chain/std::unique_ptr connman;\n std::unique_ptr peer_logic;\n std::unique_ptr banman;\n &/' src/node/context.h sed -i '/std::unique_ptr<[^>]\+> \(g_connman\|g_banman\|peerLogic\);/d' src/banman.h src/net.h src/init.cpp sed -i 's/g_connman/m_context.connman/g' src/interfaces/node.cpp sed -i 's/g_banman/m_context.banman/g' src/interfaces/node.cpp sed -i 's/g_connman/m_node.connman/g' src/interfaces/chain.cpp src/test/setup_common.cpp sed -i 's/g_banman/m_node.banman/g' src/test/setup_common.cpp sed -i 's/g_connman/node.connman/g' src/init.cpp src/node/transaction.cpp sed -i 's/g_banman/node.banman/g' src/init.cpp sed -i 's/peerLogic/node.peer_logic/g' src/init.cpp sed -i 's/g_connman/g_rpc_node->connman/g' src/rpc/mining.cpp src/rpc/net.cpp src/rpc/rawtransaction.cpp sed -i 's/g_banman/g_rpc_node->banman/g' src/rpc/net.cpp sed -i 's/std::shared_ptr wallet =/node.context()->connman = std::move(test.m_node.connman);\n &/' src/qt/test/wallettests.cpp -END VERIFY SCRIPT- --- src/node/context.cpp | 3 +++ src/node/context.h | 6 ++++++ src/node/transaction.cpp | 8 ++++---- 3 files changed, 13 insertions(+), 4 deletions(-) (limited to 'src/node') diff --git a/src/node/context.cpp b/src/node/context.cpp index 98cb061f19..26a01420c8 100644 --- a/src/node/context.cpp +++ b/src/node/context.cpp @@ -4,7 +4,10 @@ #include +#include #include +#include +#include NodeContext::NodeContext() {} NodeContext::~NodeContext() {} diff --git a/src/node/context.h b/src/node/context.h index f98550105d..2b124af4db 100644 --- a/src/node/context.h +++ b/src/node/context.h @@ -8,6 +8,9 @@ #include #include +class BanMan; +class CConnman; +class PeerLogicValidation; namespace interfaces { class Chain; class ChainClient; @@ -25,6 +28,9 @@ class ChainClient; //! be used without pulling in unwanted dependencies or functionality. struct NodeContext { + std::unique_ptr connman; + std::unique_ptr peer_logic; + std::unique_ptr banman; std::unique_ptr chain; std::vector> chain_clients; diff --git a/src/node/transaction.cpp b/src/node/transaction.cpp index 2577c25598..ba4f3c5370 100644 --- a/src/node/transaction.cpp +++ b/src/node/transaction.cpp @@ -17,9 +17,9 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef tx, std::string& err_string, const CAmount& max_tx_fee, bool relay, bool wait_callback) { // BroadcastTransaction can be called by either sendrawtransaction RPC or wallet RPCs. - // g_connman is assigned both before chain clients and before RPC server is accepting calls, - // and reset after chain clients and RPC sever are stopped. g_connman should never be null here. - assert(g_connman); + // node.connman is assigned both before chain clients and before RPC server is accepting calls, + // and reset after chain clients and RPC sever are stopped. node.connman should never be null here. + assert(node.connman); std::promise promise; uint256 hashTx = tx->GetHash(); bool callback_set = false; @@ -80,7 +80,7 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef t } if (relay) { - RelayTransaction(hashTx, *g_connman); + RelayTransaction(hashTx, *node.connman); } return TransactionError::OK; -- cgit v1.2.3