[net_processing] Pass chainparams to PeerLogicValidation constructor

Keep a references to chainparams, rather than calling the global
Params() function every time it's needed. This is fine, since
globalChainParams does not get updated once it's been set, and it's
available at the point of constructing the PeerLogicValidation object.
This commit is contained in:
John Newbery
2020-08-12 11:48:28 +01:00
parent 824bbd1ffb
commit 2297b26b3c
6 changed files with 40 additions and 34 deletions

View File

@@ -29,7 +29,8 @@ static const int DISCOURAGEMENT_THRESHOLD{100};
class PeerLogicValidation final : public CValidationInterface, public NetEventsInterface {
public:
PeerLogicValidation(CConnman& connman, BanMan* banman, CScheduler& scheduler, ChainstateManager& chainman, CTxMemPool& pool);
PeerLogicValidation(const CChainParams& chainparams, CConnman& connman, BanMan* banman,
CScheduler& scheduler, ChainstateManager& chainman, CTxMemPool& pool);
/**
* Overridden from CValidationInterface.
@@ -79,8 +80,7 @@ public:
/** Process a single message from a peer. Public for fuzz testing */
void ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRecv,
const std::chrono::microseconds time_received, const CChainParams& chainparams,
const std::atomic<bool>& interruptMsgProc);
const std::chrono::microseconds time_received, const std::atomic<bool>& interruptMsgProc);
private:
/** Maybe disconnect a peer and discourage future connections from its address.
@@ -90,6 +90,7 @@ private:
*/
bool MaybeDiscourageAndDisconnect(CNode& pnode);
const CChainParams& m_chainparams;
CConnman& m_connman;
/** Pointer to this node's banman. May be nullptr - check existence before dereferencing. */
BanMan* const m_banman;