Raven Core  3.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-2016 The Bitcoin Core developers
3 // Copyright (c) 2017-2019 The Raven Core developers
4 // Distributed under the MIT software license, see the accompanying
5 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 
7 #ifndef RAVEN_NET_PROCESSING_H
8 #define RAVEN_NET_PROCESSING_H
9 
10 #include "net.h"
11 #include "validationinterface.h"
12 #include "consensus/params.h"
13 
15 static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100;
17 static const int64_t ORPHAN_TX_EXPIRE_TIME = 20 * 60;
19 static const int64_t ORPHAN_TX_EXPIRE_INTERVAL = 5 * 60;
21 static const unsigned int DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN = 100;
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
33 static constexpr int64_t STALE_CHECK_INTERVAL = 10 * 60; // 10 minutes
35 static constexpr int64_t EXTRA_PEER_CHECK_INTERVAL = 45;
37 static constexpr int64_t MINIMUM_CONNECT_TIME = 30;
38 
40 private:
41  CConnman* const connman;
42 
43 public:
44  explicit PeerLogicValidation(CConnman* connman, CScheduler &scheduler);
45 
46  void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected, const std::vector<CTransactionRef>& vtxConflicted) override;
47  void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override;
48  void BlockChecked(const CBlock& block, const CValidationState& state) override;
49  void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& pblock) override;
50 
51 
52  void InitializeNode(CNode* pnode) override;
53  void FinalizeNode(NodeId nodeid, bool& fUpdateConnectionTime) override;
55  bool ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt) override;
63  bool SendMessages(CNode* pto, std::atomic<bool>& interrupt) override;
64 
65  void ConsiderEviction(CNode *pto, int64_t time_in_seconds);
66  void CheckForStaleTipAndEvictPeers(const Consensus::Params &consensusParams);
67  void EvictExtraOutboundPeers(int64_t time_in_seconds);
68 
69 private:
71 };
72 
77  std::vector<int> vHeightInFlight;
78 };
79 
81 bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats);
83 void Misbehaving(NodeId nodeid, int howmuch);
84 
85 #endif // RAVEN_NET_PROCESSING_H
CConnman *const connman
void Misbehaving(NodeId nodeid, int howmuch)
Increase a node&#39;s misbehavior score.
Definition: block.h:73
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override
Notifies listeners of updated block chain tip.
void CheckForStaleTipAndEvictPeers(const Consensus::Params &consensusParams)
void EvictExtraOutboundPeers(int64_t time_in_seconds)
Interface for message handling.
Definition: net.h:462
bool ProcessMessages(CNode *pfrom, std::atomic< bool > &interrupt) override
Process protocol messages received from a given node.
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats)
Get statistics from node state.
int64_t NodeId
Definition: net.h:93
Definition: net.h:120
Parameters that influence chain consensus.
Definition: params.h:47
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.
RVN END.
Definition: validation.h:30
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...
The block chain is a tree shaped structure starting with the genesis block at the root...
Definition: chain.h:172
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
PeerLogicValidation(CConnman *connman, CScheduler &scheduler)
Information about a peer.
Definition: net.h:596
std::vector< int > vHeightInFlight
void InitializeNode(CNode *pnode) override
bool SendMessages(CNode *pto, std::atomic< bool > &interrupt) override
Send queued protocol messages to be sent to a give node.