Fabcoin Core  0.16.2
P2P Digital Currency
net_processing.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2017 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 FABCOIN_NET_PROCESSING_H
7 #define FABCOIN_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 = 100;
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;
23 static constexpr int64_t HEADERS_DOWNLOAD_TIMEOUT_BASE = 15 * 60 * 1000000; // 15 minutes
24 static constexpr int64_t HEADERS_DOWNLOAD_TIMEOUT_PER_HEADER = 1000; // 1ms/header
28 static constexpr int32_t MAX_OUTBOUND_PEERS_TO_PROTECT_FROM_DISCONNECT = 4;
30 static constexpr int64_t CHAIN_SYNC_TIMEOUT = 20 * 60; // 20 minutes
32 static constexpr int64_t STALE_CHECK_INTERVAL = 1.25 * 60; // 1.25 minutes
34 static constexpr int64_t EXTRA_PEER_CHECK_INTERVAL = 45;
36 static constexpr int64_t MINIMUM_CONNECT_TIME = 30;
37 
39 private:
40  CConnman* const connman;
41 
42 public:
43  explicit PeerLogicValidation(CConnman* connman, CScheduler &scheduler);
44 
45  void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected, const std::vector<CTransactionRef>& vtxConflicted) override;
46  void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override;
47  void BlockChecked(const CBlock& block, const CValidationState& state) override;
48  void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& pblock) override;
49 
50 
51  void InitializeNode(CNode* pnode) override;
52  void FinalizeNode(NodeId nodeid, bool& fUpdateConnectionTime) override;
54  bool ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt) override;
62  bool SendMessages(CNode* pto, std::atomic<bool>& interrupt) override;
63 
64  void ConsiderEviction(CNode *pto, int64_t time_in_seconds);
65  void CheckForStaleTipAndEvictPeers(const Consensus::Params &consensusParams);
66  void EvictExtraOutboundPeers(int64_t time_in_seconds);
67 
68 private:
70 };
71 
76  std::vector<int> vHeightInFlight;
77 };
78 
80 bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats);
82 void Misbehaving(NodeId nodeid, int howmuch);
83 
84 #endif // FABCOIN_NET_PROCESSING_H
CConnman *const connman
void Misbehaving(NodeId nodeid, int howmuch)
Increase a node&#39;s misbehavior score.
Definition: block.h:155
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:465
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:39
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:27
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:177
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:599
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.