Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 4,231 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
// Ignore unknown commands for extensibility | // Ignore unknown commands for extensibility | ||||
LogPrint(BCLog::NET, "Unknown command \"%s\" from peer=%d\n", | LogPrint(BCLog::NET, "Unknown command \"%s\" from peer=%d\n", | ||||
SanitizeString(msg_type), pfrom.GetId()); | SanitizeString(msg_type), pfrom.GetId()); | ||||
return; | return; | ||||
} | } | ||||
bool PeerLogicValidation::CheckIfBanned(CNode &pnode) { | bool PeerLogicValidation::MaybeDiscourageAndDisconnect(CNode &pnode) { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
CNodeState &state = *State(pnode.GetId()); | CNodeState &state = *State(pnode.GetId()); | ||||
if (state.m_should_discourage) { | if (state.m_should_discourage) { | ||||
state.m_should_discourage = false; | state.m_should_discourage = false; | ||||
if (pnode.HasPermission(PF_NOBAN)) { | if (pnode.HasPermission(PF_NOBAN)) { | ||||
LogPrintf("Warning: not punishing whitelisted peer %s!\n", | LogPrintf("Warning: not punishing whitelisted peer %s!\n", | ||||
pnode.addr.ToString()); | pnode.addr.ToString()); | ||||
▲ Show 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | try { | ||||
__func__, SanitizeString(msg_type), nMessageSize, e.what(), | __func__, SanitizeString(msg_type), nMessageSize, e.what(), | ||||
typeid(e).name()); | typeid(e).name()); | ||||
} catch (...) { | } catch (...) { | ||||
LogPrint(BCLog::NET, "%s(%s, %u bytes): Unknown exception caught\n", | LogPrint(BCLog::NET, "%s(%s, %u bytes): Unknown exception caught\n", | ||||
__func__, SanitizeString(msg_type), nMessageSize); | __func__, SanitizeString(msg_type), nMessageSize); | ||||
} | } | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
CheckIfBanned(*pfrom); | MaybeDiscourageAndDisconnect(*pfrom); | ||||
return fMoreWork; | return fMoreWork; | ||||
} | } | ||||
void PeerLogicValidation::ConsiderEviction(CNode &pto, | void PeerLogicValidation::ConsiderEviction(CNode &pto, | ||||
int64_t time_in_seconds) { | int64_t time_in_seconds) { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
▲ Show 20 Lines • Show All 249 Lines • ▼ Show 20 Lines | if (pingSend) { | ||||
} | } | ||||
} | } | ||||
TRY_LOCK(cs_main, lockMain); | TRY_LOCK(cs_main, lockMain); | ||||
if (!lockMain) { | if (!lockMain) { | ||||
return true; | return true; | ||||
} | } | ||||
if (CheckIfBanned(*pto)) { | if (MaybeDiscourageAndDisconnect(*pto)) { | ||||
return true; | return true; | ||||
} | } | ||||
CNodeState &state = *State(pto->GetId()); | CNodeState &state = *State(pto->GetId()); | ||||
// Address refresh broadcast | // Address refresh broadcast | ||||
int64_t nNow = GetTimeMicros(); | int64_t nNow = GetTimeMicros(); | ||||
auto current_time = GetTime<std::chrono::microseconds>(); | auto current_time = GetTime<std::chrono::microseconds>(); | ||||
▲ Show 20 Lines • Show All 661 Lines • Show Last 20 Lines |