Bitcoin Core  22.0.0
P2P Digital Currency
net_processing.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2020 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_NET_PROCESSING_H
7 #define BITCOIN_NET_PROCESSING_H
8 
9 #include <net.h>
10 #include <validationinterface.h>
11 
12 class CAddrMan;
13 class CChainParams;
14 class CTxMemPool;
15 class ChainstateManager;
16 
18 static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100;
20 static const unsigned int DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN = 100;
21 static const bool DEFAULT_PEERBLOOMFILTERS = false;
22 static const bool DEFAULT_PEERBLOCKFILTERS = false;
24 static const int DISCOURAGEMENT_THRESHOLD{100};
25 
27  int nSyncHeight = -1;
28  int nCommonHeight = -1;
30  std::chrono::microseconds m_ping_wait;
31  std::vector<int> vHeightInFlight;
32  uint64_t m_addr_processed = 0;
33  uint64_t m_addr_rate_limited = 0;
34 };
35 
37 {
38 public:
39  static std::unique_ptr<PeerManager> make(const CChainParams& chainparams, CConnman& connman, CAddrMan& addrman,
40  BanMan* banman, CScheduler& scheduler, ChainstateManager& chainman,
41  CTxMemPool& pool, bool ignore_incoming_txs);
42  virtual ~PeerManager() { }
43 
45  virtual bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) const = 0;
46 
48  virtual bool IgnoresIncomingTxs() = 0;
49 
51  virtual void RelayTransaction(const uint256& txid, const uint256& wtxid) = 0;
52 
54  virtual void SendPings() = 0;
55 
57  virtual void SetBestHeight(int height) = 0;
58 
64  virtual void Misbehaving(const NodeId pnode, const int howmuch, const std::string& message) = 0;
65 
70  virtual void CheckForStaleTipAndEvictPeers() = 0;
71 
73  virtual void ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRecv,
74  const std::chrono::microseconds time_received, const std::atomic<bool>& interruptMsgProc) = 0;
75 };
76 
77 #endif // BITCOIN_NET_PROCESSING_H
virtual void Misbehaving(const NodeId pnode, const int howmuch, const std::string &message)=0
Increment peer&#39;s misbehavior score.
Definition: banman.h:58
uint64_t m_addr_rate_limited
Provides an interface for creating and interacting with one or two chainstates: an IBD chainstate gen...
Definition: validation.h:866
virtual ~PeerManager()
Interface for message handling.
Definition: net.h:712
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system...
Definition: chainparams.h:69
Double ended buffer combining vector and stream-like interfaces.
Definition: streams.h:204
Implement this to subscribe to events generated in validation.
static const bool DEFAULT_PEERBLOCKFILTERS
Stochastical (IP) address manager.
Definition: addrman.h:173
uint64_t m_addr_processed
virtual void ProcessMessage(CNode &pfrom, const std::string &msg_type, CDataStream &vRecv, const std::chrono::microseconds time_received, const std::atomic< bool > &interruptMsgProc)=0
Process a single message from a peer.
virtual bool IgnoresIncomingTxs()=0
Whether this node ignores txs received over p2p.
int64_t NodeId
Definition: net.h:88
Definition: net.h:747
static const int DISCOURAGEMENT_THRESHOLD
Threshold for marking a node to be discouraged, e.g.
std::chrono::microseconds m_ping_wait
256-bit opaque blob.
Definition: uint256.h:124
static const bool DEFAULT_PEERBLOOMFILTERS
virtual void CheckForStaleTipAndEvictPeers()=0
Evict extra outbound peers.
virtual bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats) const =0
Get statistics from node state.
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:477
virtual void SendPings()=0
Send ping message to all peers.
virtual void RelayTransaction(const uint256 &txid, const uint256 &wtxid)=0
Relay transaction to all peers.
static const unsigned int DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN
Default number of orphan+recently-replaced txn to keep around for block reconstruction.
virtual void SetBestHeight(int height)=0
Set the best height.
Information about a peer.
Definition: net.h:394
static std::unique_ptr< PeerManager > make(const CChainParams &chainparams, CConnman &connman, CAddrMan &addrman, BanMan *banman, CScheduler &scheduler, ChainstateManager &chainman, CTxMemPool &pool, bool ignore_incoming_txs)
std::vector< int > vHeightInFlight
Simple class for background tasks that should be run periodically or once "after a while"...
Definition: scheduler.h:33
static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS
Default for -maxorphantx, maximum number of orphan transactions kept in memory.