Use an .ini config file for environment vars in bitcoin-util-test.py
[bitcoinplatinum.git] / src / net_processing.h
blobf460595bc1094915d4416a16fdefa72f9ad2cc69
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2016 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.
6 #ifndef BITCOIN_NET_PROCESSING_H
7 #define BITCOIN_NET_PROCESSING_H
9 #include "net.h"
10 #include "validationinterface.h"
12 /** Default for -maxorphantx, maximum number of orphan transactions kept in memory */
13 static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100;
14 /** Expiration time for orphan transactions in seconds */
15 static const int64_t ORPHAN_TX_EXPIRE_TIME = 20 * 60;
16 /** Minimum time between orphan transactions expire time checks in seconds */
17 static const int64_t ORPHAN_TX_EXPIRE_INTERVAL = 5 * 60;
18 /** Default number of orphan+recently-replaced txn to keep around for block reconstruction */
19 static const unsigned int DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN = 100;
21 /** Register with a network node to receive its signals */
22 void RegisterNodeSignals(CNodeSignals& nodeSignals);
23 /** Unregister a network node */
24 void UnregisterNodeSignals(CNodeSignals& nodeSignals);
26 class PeerLogicValidation : public CValidationInterface {
27 private:
28 CConnman* connman;
30 public:
31 PeerLogicValidation(CConnman* connmanIn);
33 void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected, const std::vector<CTransactionRef>& vtxConflicted) override;
34 void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override;
35 void BlockChecked(const CBlock& block, const CValidationState& state) override;
36 void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& pblock) override;
39 struct CNodeStateStats {
40 int nMisbehavior;
41 int nSyncHeight;
42 int nCommonHeight;
43 std::vector<int> vHeightInFlight;
46 /** Get statistics from node state */
47 bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats);
48 /** Increase a node's misbehavior score. */
49 void Misbehaving(NodeId nodeid, int howmuch);
51 /** Process protocol messages received from a given node */
52 bool ProcessMessages(CNode* pfrom, CConnman& connman, const std::atomic<bool>& interrupt);
53 /**
54 * Send queued protocol messages to be sent to a give node.
56 * @param[in] pto The node which we are sending messages to.
57 * @param[in] connman The connection manager for that node.
58 * @param[in] interrupt Interrupt condition for processing threads
59 * @return True if there is more work to be done
61 bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interrupt);
63 #endif // BITCOIN_NET_PROCESSING_H