Skip to content

Commit

Permalink
Implement IsBanned to allow checking for banned nodes outside of net_…
Browse files Browse the repository at this point in the history
…processing.cpp
  • Loading branch information
codablock committed Jan 17, 2019
1 parent 49de417 commit dd8f245
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,17 @@ void Misbehaving(NodeId pnode, int howmuch)
LogPrintf("%s: %s peer=%d (%d -> %d)\n", __func__, state->name, pnode, state->nMisbehavior-howmuch, state->nMisbehavior);
}


// Requires cs_main.
bool IsBanned(NodeId pnode)
{
CNodeState *state = State(pnode);
if (state == NULL)
return false;
if (state->fShouldBan) {
return true;
}
return false;
}



Expand Down
1 change: 1 addition & 0 deletions src/net_processing.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct CNodeStateStats {
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats);
/** Increase a node's misbehavior score. */
void Misbehaving(NodeId nodeid, int howmuch);
bool IsBanned(NodeId nodeid);

/** Process protocol messages received from a given node */
bool ProcessMessages(CNode* pfrom, CConnman& connman, const std::atomic<bool>& interrupt);
Expand Down

0 comments on commit dd8f245

Please sign in to comment.