Skip to content

Commit

Permalink
block spam filter, validate non null nodestate
Browse files Browse the repository at this point in the history
  • Loading branch information
furszy committed Feb 4, 2019
1 parent 84de55a commit da1b683
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/main.cpp
Expand Up @@ -4818,18 +4818,20 @@ bool ProcessNewBlock(CValidationState& state, CNode* pfrom, CBlock* pblock, CDis
// Check spamming
if(pfrom && GetBoolArg("-blockspamfilter", DEFAULT_BLOCK_SPAM_FILTER)) {
CNodeState *nodestate = State(pfrom->GetId());
nodestate->nodeBlocks.onBlockReceived(pindex->nHeight);
bool nodeStatus = true;
// UpdateState will return false if the node is attacking us or update the score and return true.
nodeStatus = nodestate->nodeBlocks.updateState(state, nodeStatus);
int nDoS = 0;
if (state.IsInvalid(nDoS)) {
if (nDoS > 0)
Misbehaving(pfrom->GetId(), nDoS);
nodeStatus = false;
if(nodestate != nullptr) {
nodestate->nodeBlocks.onBlockReceived(pindex->nHeight);
bool nodeStatus = true;
// UpdateState will return false if the node is attacking us or update the score and return true.
nodeStatus = nodestate->nodeBlocks.updateState(state, nodeStatus);
int nDoS = 0;
if (state.IsInvalid(nDoS)) {
if (nDoS > 0)
Misbehaving(pfrom->GetId(), nDoS);
nodeStatus = false;
}
if (!nodeStatus)
return error("%s : AcceptBlock FAILED - block spam protection", __func__);
}
if(!nodeStatus)
return error("%s : AcceptBlock FAILED - block spam protection", __func__);
}
return error("%s : AcceptBlock FAILED", __func__);
}
Expand Down

0 comments on commit da1b683

Please sign in to comment.