Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.h
Show First 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | public: | ||||
/** Process a single message from a peer. Public for fuzz testing */ | /** Process a single message from a peer. Public for fuzz testing */ | ||||
void ProcessMessage(const Config &config, CNode &pfrom, | void ProcessMessage(const Config &config, CNode &pfrom, | ||||
const std::string &msg_type, CDataStream &vRecv, | const std::string &msg_type, CDataStream &vRecv, | ||||
int64_t nTimeReceived, | int64_t nTimeReceived, | ||||
const std::atomic<bool> &interruptMsgProc); | const std::atomic<bool> &interruptMsgProc); | ||||
/** | /** | ||||
* Increment peer's misbehavior score. If the new value >= | |||||
* DISCOURAGEMENT_THRESHOLD, mark the node to be discouraged, meaning the | |||||
* peer might be disconnected and added to the discouragement filter. Public | |||||
* for unit testing. | |||||
*/ | |||||
void Misbehaving(const NodeId pnode, const int howmuch, | |||||
const std::string &message); | |||||
/** | |||||
* Retrieve unbroadcast transactions from the mempool and reattempt | * Retrieve unbroadcast transactions from the mempool and reattempt | ||||
* sending to peers | * sending to peers | ||||
*/ | */ | ||||
void ReattemptInitialBroadcast(CScheduler &scheduler) const; | void ReattemptInitialBroadcast(CScheduler &scheduler) const; | ||||
private: | private: | ||||
// overloaded variant of above to operate on CNode*s | |||||
void Misbehaving(const CNode &node, int howmuch, | |||||
const std::string &message) { | |||||
Misbehaving(node.GetId(), howmuch, message); | |||||
} | |||||
/** | /** | ||||
* Potentially mark a node discouraged based on the contents of a | * Potentially mark a node discouraged based on the contents of a | ||||
* BlockValidationState object | * BlockValidationState object | ||||
* | * | ||||
* @param[in] via_compact_block this bool is passed in because | * @param[in] via_compact_block this bool is passed in because | ||||
* net_processing should punish peers differently depending on whether the | * net_processing should punish peers differently depending on whether the | ||||
* data was provided in a compact block message or not. If the compact block | * data was provided in a compact block message or not. If the compact block | ||||
* had a valid header, but contained invalid txs, the peer should not be | * had a valid header, but contained invalid txs, the peer should not be | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | struct CNodeStateStats { | ||||
int m_misbehavior_score = 0; | int m_misbehavior_score = 0; | ||||
int nSyncHeight = -1; | int nSyncHeight = -1; | ||||
int nCommonHeight = -1; | int nCommonHeight = -1; | ||||
std::vector<int> vHeightInFlight; | std::vector<int> vHeightInFlight; | ||||
}; | }; | ||||
/** Get statistics from node state */ | /** Get statistics from node state */ | ||||
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats); | bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats); | ||||
/** | |||||
* Increment peer's misbehavior score. If the new value >= | |||||
* DISCOURAGEMENT_THRESHOLD, mark the node to be discouraged, meaning the peer | |||||
* might be disconnected and added to the discouragement filter. | |||||
*/ | |||||
void Misbehaving(const NodeId nodeid, const int howmuch, | |||||
const std::string &message = ""); | |||||
/** Relay transaction to every node */ | /** Relay transaction to every node */ | ||||
void RelayTransaction(const TxId &txid, const CConnman &connman); | void RelayTransaction(const TxId &txid, const CConnman &connman); | ||||
#endif // BITCOIN_NET_PROCESSING_H | #endif // BITCOIN_NET_PROCESSING_H |