|
|
@ -100,41 +100,27 @@ public:
|
|
|
|
CScheduler& scheduler, ChainstateManager& chainman, CTxMemPool& pool,
|
|
|
|
CScheduler& scheduler, ChainstateManager& chainman, CTxMemPool& pool,
|
|
|
|
bool ignore_incoming_txs);
|
|
|
|
bool ignore_incoming_txs);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/** Overridden from CValidationInterface. */
|
|
|
|
* Overridden from CValidationInterface.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected) override;
|
|
|
|
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected) override;
|
|
|
|
void BlockDisconnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex* pindex) override;
|
|
|
|
void BlockDisconnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex* pindex) override;
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Overridden from CValidationInterface.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override;
|
|
|
|
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override;
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Overridden from CValidationInterface.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
void BlockChecked(const CBlock& block, const BlockValidationState& state) override;
|
|
|
|
void BlockChecked(const CBlock& block, const BlockValidationState& state) override;
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Overridden from CValidationInterface.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& pblock) override;
|
|
|
|
void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& pblock) override;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Implement NetEventsInterface */
|
|
|
|
void InitializeNode(CNode* pnode) override;
|
|
|
|
void InitializeNode(CNode* pnode) override;
|
|
|
|
void FinalizeNode(const CNode& node, bool& fUpdateConnectionTime) override;
|
|
|
|
void FinalizeNode(const CNode& node, bool& fUpdateConnectionTime) override;
|
|
|
|
bool ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt) override;
|
|
|
|
bool ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt) override;
|
|
|
|
bool SendMessages(CNode* pto) override EXCLUSIVE_LOCKS_REQUIRED(pto->cs_sendProcessing);
|
|
|
|
bool SendMessages(CNode* pto) override EXCLUSIVE_LOCKS_REQUIRED(pto->cs_sendProcessing);
|
|
|
|
|
|
|
|
|
|
|
|
/** Consider evicting an outbound peer based on the amount of time they've been behind our tip */
|
|
|
|
/** Get statistics from node state */
|
|
|
|
void ConsiderEviction(CNode& pto, int64_t time_in_seconds) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
|
|
|
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats);
|
|
|
|
/** Evict extra outbound peers. If we think our tip may be stale, connect to an extra outbound */
|
|
|
|
|
|
|
|
void CheckForStaleTipAndEvictPeers();
|
|
|
|
|
|
|
|
/** If we have extra outbound peers, try to disconnect the one with the oldest block announcement */
|
|
|
|
|
|
|
|
void EvictExtraOutboundPeers(int64_t time_in_seconds) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
|
|
|
|
|
|
|
/** Retrieve unbroadcast transactions from the mempool and reattempt sending to peers */
|
|
|
|
|
|
|
|
void ReattemptInitialBroadcast(CScheduler& scheduler) const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Process a single message from a peer. Public for fuzz testing */
|
|
|
|
/** Whether this node ignores txs received over p2p. */
|
|
|
|
void ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRecv,
|
|
|
|
bool IgnoresIncomingTxs() { return m_ignore_incoming_txs; };
|
|
|
|
const std::chrono::microseconds time_received, const std::atomic<bool>& interruptMsgProc);
|
|
|
|
|
|
|
|
|
|
|
|
/** Set the best height */
|
|
|
|
|
|
|
|
void SetBestHeight(int height) { m_best_height = height; };
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Increment peer's misbehavior score. If the new value >= DISCOURAGEMENT_THRESHOLD, mark the node
|
|
|
|
* Increment peer's misbehavior score. If the new value >= DISCOURAGEMENT_THRESHOLD, mark the node
|
|
|
@ -143,16 +129,26 @@ public:
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
void Misbehaving(const NodeId pnode, const int howmuch, const std::string& message);
|
|
|
|
void Misbehaving(const NodeId pnode, const int howmuch, const std::string& message);
|
|
|
|
|
|
|
|
|
|
|
|
/** Get statistics from node state */
|
|
|
|
/**
|
|
|
|
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats);
|
|
|
|
* Evict extra outbound peers. If we think our tip may be stale, connect to an extra outbound.
|
|
|
|
|
|
|
|
* Public for unit testing.
|
|
|
|
/** Set the best height */
|
|
|
|
*/
|
|
|
|
void SetBestHeight(int height) { m_best_height = height; };
|
|
|
|
void CheckForStaleTipAndEvictPeers();
|
|
|
|
|
|
|
|
|
|
|
|
/** Whether this node ignores txs received over p2p. */
|
|
|
|
/** Process a single message from a peer. Public for fuzz testing */
|
|
|
|
bool IgnoresIncomingTxs() { return m_ignore_incoming_txs; };
|
|
|
|
void ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRecv,
|
|
|
|
|
|
|
|
const std::chrono::microseconds time_received, const std::atomic<bool>& interruptMsgProc);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
|
|
|
|
/** Consider evicting an outbound peer based on the amount of time they've been behind our tip */
|
|
|
|
|
|
|
|
void ConsiderEviction(CNode& pto, int64_t time_in_seconds) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** If we have extra outbound peers, try to disconnect the one with the oldest block announcement */
|
|
|
|
|
|
|
|
void EvictExtraOutboundPeers(int64_t time_in_seconds) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Retrieve unbroadcast transactions from the mempool and reattempt sending to peers */
|
|
|
|
|
|
|
|
void ReattemptInitialBroadcast(CScheduler& scheduler) const;
|
|
|
|
|
|
|
|
|
|
|
|
/** Get a shared pointer to the Peer object.
|
|
|
|
/** Get a shared pointer to the Peer object.
|
|
|
|
* May return an empty shared_ptr if the Peer object can't be found. */
|
|
|
|
* May return an empty shared_ptr if the Peer object can't be found. */
|
|
|
|
PeerRef GetPeerRef(NodeId id) const;
|
|
|
|
PeerRef GetPeerRef(NodeId id) const;
|
|
|
|