Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 1,182 Lines • ▼ Show 20 Lines | |||||
// overloaded variant of above to operate on CNode*s | // overloaded variant of above to operate on CNode*s | ||||
static void Misbehaving(CNode *node, int howmuch, const std::string &reason) | static void Misbehaving(CNode *node, int howmuch, const std::string &reason) | ||||
EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | EXCLUSIVE_LOCKS_REQUIRED(cs_main) { | ||||
Misbehaving(node->GetId(), howmuch, reason); | Misbehaving(node->GetId(), howmuch, reason); | ||||
} | } | ||||
static bool TxRelayMayResultInDisconnect(const CValidationState &state) { | static bool TxRelayMayResultInDisconnect(const CValidationState &state) { | ||||
assert(state.GetDoS() == state.GetDoSForReason()); | |||||
return (state.GetDoS() > 0); | return (state.GetDoS() > 0); | ||||
} | } | ||||
/** | /** | ||||
* Potentially ban a node based on the contents of a CValidationState object | * Potentially ban a node based on the contents of a CValidationState object | ||||
* TODO: net_processing should make the punish decision based on the reason | * TODO: net_processing should make the punish decision based on the reason | ||||
* a tx/block was invalid, rather than just the nDoS score handed back by | * a tx/block was invalid, rather than just the nDoS score handed back by | ||||
* validation. | * validation. | ||||
* | * | ||||
* @parameter via_compact_block: this bool is passed in because net_processing | * @parameter via_compact_block: this bool is passed in because net_processing | ||||
* should punish peers differently depending on whether the data was provided in | * 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 | * 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. | * contained invalid txs, the peer should not be punished. See BIP 152. | ||||
*/ | */ | ||||
static bool MaybePunishNode(NodeId nodeid, const CValidationState &state, | static bool MaybePunishNode(NodeId nodeid, const CValidationState &state, | ||||
bool via_compact_block, | bool via_compact_block, | ||||
const std::string &message = "") { | const std::string &message = "") { | ||||
assert(state.GetDoS() == state.GetDoSForReason()); | |||||
int nDoS = state.GetDoS(); | int nDoS = state.GetDoS(); | ||||
if (nDoS > 0 && !via_compact_block) { | if (nDoS > 0 && !via_compact_block) { | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
Misbehaving(nodeid, nDoS, message); | Misbehaving(nodeid, nDoS, message); | ||||
return true; | return true; | ||||
} | } | ||||
if (message != "") { | if (message != "") { | ||||
LogPrint(BCLog::NET, "peer=%d: %s\n", nodeid, message); | LogPrint(BCLog::NET, "peer=%d: %s\n", nodeid, message); | ||||
▲ Show 20 Lines • Show All 3,866 Lines • Show Last 20 Lines |