Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 1,356 Lines • ▼ Show 20 Lines | |||||
* Returns true if the given validation state result may result in a peer | * Returns true if the given validation state result may result in a peer | ||||
* banning/disconnecting us. We use this to determine which unaccepted | * banning/disconnecting us. We use this to determine which unaccepted | ||||
* transactions from a whitelisted peer that we can safely relay. | * transactions from a whitelisted peer that we can safely relay. | ||||
*/ | */ | ||||
static bool TxRelayMayResultInDisconnect(const TxValidationState &state) { | static bool TxRelayMayResultInDisconnect(const TxValidationState &state) { | ||||
return state.GetResult() == TxValidationResult::TX_CONSENSUS; | return state.GetResult() == TxValidationResult::TX_CONSENSUS; | ||||
} | } | ||||
/** | bool PeerManager::MaybePunishNodeForBlock(NodeId nodeid, | ||||
* Potentially ban a node based on the contents of a BlockValidationState object | |||||
* | |||||
* @param[in] via_compact_block this bool is passed in because net_processing | |||||
* should punish peers differently depending on whether the 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 punished. See BIP 152. | |||||
* | |||||
* @return Returns true if the peer was punished (probably disconnected) | |||||
*/ | |||||
static bool MaybePunishNodeForBlock(NodeId nodeid, | |||||
const BlockValidationState &state, | const BlockValidationState &state, | ||||
bool via_compact_block, | bool via_compact_block, | ||||
const std::string &message = "") { | const std::string &message) { | ||||
switch (state.GetResult()) { | switch (state.GetResult()) { | ||||
case BlockValidationResult::BLOCK_RESULT_UNSET: | case BlockValidationResult::BLOCK_RESULT_UNSET: | ||||
break; | break; | ||||
// The node is providing invalid data: | // The node is providing invalid data: | ||||
case BlockValidationResult::BLOCK_CONSENSUS: | case BlockValidationResult::BLOCK_CONSENSUS: | ||||
case BlockValidationResult::BLOCK_MUTATED: | case BlockValidationResult::BLOCK_MUTATED: | ||||
if (!via_compact_block) { | if (!via_compact_block) { | ||||
Misbehaving(nodeid, 100, message); | Misbehaving(nodeid, 100, message); | ||||
▲ Show 20 Lines • Show All 4,148 Lines • Show Last 20 Lines |