6 #ifndef BITCOIN_NET_PROCESSING_H
7 #define BITCOIN_NET_PROCESSING_H
88 const std::chrono::microseconds time_received,
const std::atomic<bool>& interruptMsgProc);
95 void Misbehaving(
const NodeId pnode,
const int howmuch,
const std::string& message);
109 bool via_compact_block,
const std::string& message =
"");
134 void AddTxAnnouncement(
const CNode& node,
const GenTxid& gtxid, std::chrono::microseconds current_time)
161 #endif // BITCOIN_NET_PROCESSING_H
bool SendMessages(CNode *pto) override EXCLUSIVE_LOCKS_REQUIRED(pto-> cs_sendProcessing)
Send queued protocol messages to be sent to a give node.
bool MaybeDiscourageAndDisconnect(CNode &pnode)
Maybe disconnect a peer and discourage future connections from its address.
int64_t m_stale_tip_check_time
Next time to check for stale tip.
void InitializeNode(CNode *pnode) override
Initialize a peer by adding it to mapNodeState and pushing a message requesting its version...
RecursiveMutex g_cs_orphans
Guards orphan transactions and extra txs for compact blocks.
Data structure to keep track of, and schedule, transaction downloads from peers.
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
void ProcessOrphanTx(std::set< uint256 > &orphan_work_set) EXCLUSIVE_LOCKS_REQUIRED(cs_main
Reconsider orphan transactions after a parent has been accepted to the mempool.
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats)
Get statistics from node state.
void ReattemptInitialBroadcast(CScheduler &scheduler) const
Retrieve unbroadcast transactions from the mempool and reattempt sending to peers.
Interface for message handling.
bool MaybePunishNodeForBlock(NodeId nodeid, const BlockValidationState &state, bool via_compact_block, const std::string &message="")
Potentially mark a node discouraged based on the contents of a BlockValidationState object...
void ProcessHeadersMessage(CNode &pfrom, const std::vector< CBlockHeader > &headers, bool via_compact_block)
Process a single headers message from a peer.
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system...
PeerManager(const CChainParams &chainparams, CConnman &connman, BanMan *banman, CScheduler &scheduler, ChainstateManager &chainman, CTxMemPool &pool)
Double ended buffer combining vector and stream-like interfaces.
Implement this to subscribe to events generated in validation.
RecursiveMutex cs_sendProcessing
static const bool DEFAULT_PEERBLOCKFILTERS
bool MaybePunishNodeForTx(NodeId nodeid, const TxValidationState &state, const std::string &message="")
Potentially disconnect and discourage a node based on the contents of a TxValidationState object...
void CheckForStaleTipAndEvictPeers()
Evict extra outbound peers.
void BlockConnected(const std::shared_ptr< const CBlock > &pblock, const CBlockIndex *pindexConnected) override
Overridden from CValidationInterface.
void FinalizeNode(const CNode &node, bool &fUpdateConnectionTime) override
Handle removal of a peer by updating various state and removing it from mapNodeState.
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override
Overridden from CValidationInterface.
void BlockDisconnected(const std::shared_ptr< const CBlock > &block, const CBlockIndex *pindex) override
Notifies listeners of a block being disconnected.
bool ProcessMessages(CNode *pfrom, std::atomic< bool > &interrupt) override
Process protocol messages received from a given node.
void ConsiderEviction(CNode &pto, int64_t time_in_seconds) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Consider evicting an outbound peer based on the amount of time they've been behind our tip...
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate...
static const int DISCOURAGEMENT_THRESHOLD
Threshold for marking a node to be discouraged, e.g.
void EvictExtraOutboundPeers(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 SendBlockTransactions(CNode &pfrom, const CBlock &block, const BlockTransactionsRequest &req)
void AddTxAnnouncement(const CNode &node, const GenTxid >xid, std::chrono::microseconds current_time) EXCLUSIVE_LOCKS_REQUIRED(const CChainParams & m_chainparams
Register with TxRequestTracker that an INV has been received from a peer.
void Misbehaving(const NodeId pnode, const int howmuch, const std::string &message)
Increment peer's misbehavior score.
ChainstateManager & m_chainman
void RelayTransaction(const uint256 &txid, const uint256 &wtxid, const CConnman &connman)
Relay transaction to every node.
static const bool DEFAULT_PEERBLOOMFILTERS
#define EXCLUSIVE_LOCKS_REQUIRED(...)
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
The block chain is a tree shaped structure starting with the genesis block at the root...
static const unsigned int DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN
Default number of orphan+recently-replaced txn to keep around for block reconstruction.
Information about a peer.
std::vector< int > vHeightInFlight
Simple class for background tasks that should be run periodically or once "after a while"...
void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr< const CBlock > &pblock) override
Overridden from CValidationInterface.
static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS
Default for -maxorphantx, maximum number of orphan transactions kept in memory.
BanMan *const m_banman
Pointer to this node's banman.
void BlockChecked(const CBlock &block, const BlockValidationState &state) override
Overridden from CValidationInterface.
TxRequestTracker m_txrequest GUARDED_BY(::cs_main)
A generic txid reference (txid or wtxid).
void ProcessMessage(CNode &pfrom, const std::string &msg_type, CDataStream &vRecv, const std::chrono::microseconds time_received, const std::atomic< bool > &interruptMsgProc)
Process a single message from a peer.