Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

net_processing.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2015 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 #include <consensus/params.h>
12 
14 static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS_SIZE = 10; // this allows around 100 TXs of max size (and many more of normal size)
16 static const int64_t ORPHAN_TX_EXPIRE_TIME = 20 * 60;
18 static const int64_t ORPHAN_TX_EXPIRE_INTERVAL = 5 * 60;
20 static const unsigned int DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN = 100;
21 
24 static constexpr int64_t HEADERS_DOWNLOAD_TIMEOUT_BASE = 15 * 60 * 1000000; // 15 minutes
25 static constexpr int64_t HEADERS_DOWNLOAD_TIMEOUT_PER_HEADER = 1000; // 1ms/header
29 static constexpr int32_t MAX_OUTBOUND_PEERS_TO_PROTECT_FROM_DISCONNECT = 4;
31 static constexpr int64_t CHAIN_SYNC_TIMEOUT = 20 * 60; // 20 minutes
32 
34 static constexpr int64_t STALE_CHECK_INTERVAL = 150; // 2.5 minutes (~block interval)
36 static constexpr int64_t EXTRA_PEER_CHECK_INTERVAL = 45;
38 static constexpr int64_t MINIMUM_CONNECT_TIME = 30;
39 
41 static constexpr bool DEFAULT_ENABLE_BIP61 = true;
43 extern bool g_enable_bip61;
44 
46 private:
47  CConnman* const connman;
48 
49 public:
50  explicit PeerLogicValidation(CConnman* connmanIn, CScheduler &scheduler);
51 
52  void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected, const std::vector<CTransactionRef>& vtxConflicted) override;
53  void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override;
54  void BlockChecked(const CBlock& block, const CValidationState& state) override;
55  void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& pblock) override;
56 
57 
58  void InitializeNode(CNode* pnode) override;
59  void FinalizeNode(NodeId nodeid, bool& fUpdateConnectionTime) override;
61  bool ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt) override;
69  bool SendMessages(CNode* pto, std::atomic<bool>& interrupt) override;
70 
71  void ConsiderEviction(CNode *pto, int64_t time_in_seconds);
72  void CheckForStaleTipAndEvictPeers(const Consensus::Params &consensusParams);
73  void EvictExtraOutboundPeers(int64_t time_in_seconds);
74 
75 private:
77 };
78 
83  std::vector<int> vHeightInFlight;
84 };
85 
87 bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats);
89 void Misbehaving(NodeId nodeid, int howmuch, const std::string& message="");
90 bool IsBanned(NodeId nodeid);
91 
92 void EraseObjectRequest(NodeId nodeId, const CInv& inv);
93 void RequestObject(NodeId nodeId, const CInv& inv, std::chrono::microseconds current_time, bool fForce=false);
94 size_t GetRequestedObjectCount(NodeId nodeId);
95 
96 #endif // BITCOIN_NET_PROCESSING_H
CConnman *const connman
static constexpr bool DEFAULT_ENABLE_BIP61
Default for BIP61 (sending reject messages)
Definition: block.h:72
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override
Notifies listeners of updated block chain tip.
void CheckForStaleTipAndEvictPeers(const Consensus::Params &consensusParams)
bool IsBanned(NodeId nodeid)
inv message data
Definition: protocol.h:429
static constexpr int64_t HEADERS_DOWNLOAD_TIMEOUT_PER_HEADER
void RequestObject(NodeId nodeId, const CInv &inv, std::chrono::microseconds current_time, bool fForce=false)
void EvictExtraOutboundPeers(int64_t time_in_seconds)
Interface for message handling.
Definition: net.h:665
static constexpr int64_t EXTRA_PEER_CHECK_INTERVAL
How frequently to check for extra outbound peers and disconnect, in seconds.
static CScheduler scheduler
Definition: init.cpp:213
static constexpr int64_t MINIMUM_CONNECT_TIME
Minimum time an outbound-peer-eviction candidate must be connected for, in order to evict...
bool ProcessMessages(CNode *pfrom, std::atomic< bool > &interrupt) override
Process protocol messages received from a given node.
size_t GetRequestedObjectCount(NodeId nodeId)
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats)
Get statistics from node state.
void Misbehaving(NodeId nodeid, int howmuch, const std::string &message="")
Increase a node&#39;s misbehavior score.
static const int64_t ORPHAN_TX_EXPIRE_INTERVAL
Minimum time between orphan transactions expire time checks in seconds.
PeerLogicValidation(CConnman *connmanIn, CScheduler &scheduler)
static const int64_t ORPHAN_TX_EXPIRE_TIME
Expiration time for orphan transactions in seconds.
int64_t NodeId
Definition: net.h:109
Definition: net.h:136
Parameters that influence chain consensus.
Definition: params.h:130
static constexpr int64_t HEADERS_DOWNLOAD_TIMEOUT_BASE
Headers download timeout expressed in microseconds Timeout = base + per_header * (expected number of ...
int64_t m_stale_tip_check_time
void BlockConnected(const std::shared_ptr< const CBlock > &pblock, const CBlockIndex *pindexConnected, const std::vector< CTransactionRef > &vtxConflicted) override
Notifies listeners of a block being connected.
Capture information about block/transaction validation.
Definition: validation.h:22
void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr< const CBlock > &pblock) override
Notifies listeners that a block which builds directly on our current tip has been received and connec...
static constexpr int32_t MAX_OUTBOUND_PEERS_TO_PROTECT_FROM_DISCONNECT
Protect at least this many outbound peers from disconnection due to slow/ behind headers chain...
void EraseObjectRequest(NodeId nodeId, const CInv &inv)
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: chain.h:170
static constexpr int64_t CHAIN_SYNC_TIMEOUT
Timeout for (unprotected) outbound peers to sync to our chainwork, in seconds.
static const unsigned int DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN
Default number of orphan+recently-replaced txn to keep around for block reconstruction.
void BlockChecked(const CBlock &block, const CValidationState &state) override
Notifies listeners of a block validation result.
void ConsiderEviction(CNode *pto, int64_t time_in_seconds)
void FinalizeNode(NodeId nodeid, bool &fUpdateConnectionTime) override
Information about a peer.
Definition: net.h:800
std::vector< int > vHeightInFlight
bool g_enable_bip61
Enable BIP61 (sending reject messages)
void InitializeNode(CNode *pnode) override
static constexpr int64_t STALE_CHECK_INTERVAL
How frequently to check for stale tips, in seconds.
bool SendMessages(CNode *pto, std::atomic< bool > &interrupt) override
Send queued protocol messages to be sent to a give node.
static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS_SIZE
Default for -maxorphantxsize, maximum size in megabytes the orphan map can grow before entries are re...
Released under the MIT license