mirror of
https://github.com/dogecoin/dogecoin.git
synced 2026-02-13 08:48:37 +00:00
-BEGIN VERIFY SCRIPT-
sed -i 's:#include <interfaces/chain.h>:#include <banman.h>\n#include <interfaces/chain.h>\n#include <net.h>\n#include <net_processing.h>:' 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<interfaces::Chain> chain/std::unique_ptr<CConnman> connman;\n std::unique_ptr<PeerLogicValidation> peer_logic;\n std::unique_ptr<BanMan> 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<CWallet> wallet =/node.context()->connman = std::move(test.m_node.connman);\n &/' src/qt/test/wallettests.cpp
-END VERIFY SCRIPT-
45 lines
1.6 KiB
C++
45 lines
1.6 KiB
C++
// Copyright (c) 2019 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#ifndef BITCOIN_NODE_CONTEXT_H
|
|
#define BITCOIN_NODE_CONTEXT_H
|
|
|
|
#include <memory>
|
|
#include <vector>
|
|
|
|
class BanMan;
|
|
class CConnman;
|
|
class PeerLogicValidation;
|
|
namespace interfaces {
|
|
class Chain;
|
|
class ChainClient;
|
|
} // namespace interfaces
|
|
|
|
//! 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<CConnman> connman;
|
|
std::unique_ptr<PeerLogicValidation> peer_logic;
|
|
std::unique_ptr<BanMan> banman;
|
|
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
|