Changeset View
Changeset View
Standalone View
Standalone View
src/net.cpp
Show First 20 Lines • Show All 528 Lines • ▼ Show 20 Lines | stats.nStartingHeight = nStartingHeight; | ||||
stats.mapSendBytesPerMsgCmd = mapSendBytesPerMsgCmd; | stats.mapSendBytesPerMsgCmd = mapSendBytesPerMsgCmd; | ||||
stats.nSendBytes = nSendBytes; | stats.nSendBytes = nSendBytes; | ||||
} | } | ||||
{ | { | ||||
LOCK(cs_vRecv); | LOCK(cs_vRecv); | ||||
stats.mapRecvBytesPerMsgCmd = mapRecvBytesPerMsgCmd; | stats.mapRecvBytesPerMsgCmd = mapRecvBytesPerMsgCmd; | ||||
stats.nRecvBytes = nRecvBytes; | stats.nRecvBytes = nRecvBytes; | ||||
} | } | ||||
stats.fWhitelisted = fWhitelisted; | stats.m_legacyWhitelisted = m_legacyWhitelisted; | ||||
stats.m_permissionFlags = m_permissionFlags; | stats.m_permissionFlags = m_permissionFlags; | ||||
{ | { | ||||
LOCK(cs_feeFilter); | LOCK(cs_feeFilter); | ||||
stats.minFeeFilter = minFeeFilter; | stats.minFeeFilter = minFeeFilter; | ||||
} | } | ||||
// It is common for nodes with good ping times to suddenly become lagged, | // It is common for nodes with good ping times to suddenly become lagged, | ||||
// due to a new block arriving or other large transfer. Merely reporting | // due to a new block arriving or other large transfer. Merely reporting | ||||
▲ Show 20 Lines • Show All 317 Lines • ▼ Show 20 Lines | |||||
* partition a node the attacker must be simultaneously better at all of them | * partition a node the attacker must be simultaneously better at all of them | ||||
* than honest peers. | * than honest peers. | ||||
*/ | */ | ||||
bool CConnman::AttemptToEvictConnection() { | bool CConnman::AttemptToEvictConnection() { | ||||
std::vector<NodeEvictionCandidate> vEvictionCandidates; | std::vector<NodeEvictionCandidate> vEvictionCandidates; | ||||
{ | { | ||||
LOCK(cs_vNodes); | LOCK(cs_vNodes); | ||||
for (CNode *node : vNodes) { | for (const CNode *node : vNodes) { | ||||
if (node->fWhitelisted || !node->fInbound || node->fDisconnect) { | if (node->HasPermission(PF_NOBAN)) { | ||||
continue; | |||||
} | |||||
if (!node->fInbound) { | |||||
continue; | |||||
} | |||||
if (node->fDisconnect) { | |||||
continue; | continue; | ||||
} | } | ||||
LOCK(node->cs_filter); | LOCK(node->cs_filter); | ||||
NodeEvictionCandidate candidate = { | NodeEvictionCandidate candidate = { | ||||
node->GetId(), | node->GetId(), | ||||
node->nTimeConnected, | node->nTimeConnected, | ||||
node->nMinPingUsecTime, | node->nMinPingUsecTime, | ||||
node->nLastBlockTime, | node->nLastBlockTime, | ||||
▲ Show 20 Lines • Show All 188 Lines • ▼ Show 20 Lines | void CConnman::AcceptConnection(const ListenSocket &hListenSocket) { | ||||
} | } | ||||
CNode *pnode = | CNode *pnode = | ||||
new CNode(id, nodeServices, GetBestHeight(), hSocket, addr, | new CNode(id, nodeServices, GetBestHeight(), hSocket, addr, | ||||
CalculateKeyedNetGroup(addr), nonce, addr_bind, "", true); | CalculateKeyedNetGroup(addr), nonce, addr_bind, "", true); | ||||
pnode->AddRef(); | pnode->AddRef(); | ||||
pnode->m_permissionFlags = permissionFlags; | pnode->m_permissionFlags = permissionFlags; | ||||
// If this flag is present, the user probably expect that RPC and QT report | // If this flag is present, the user probably expect that RPC and QT report | ||||
// it as whitelisted (backward compatibility) | // it as whitelisted (backward compatibility) | ||||
pnode->fWhitelisted = legacyWhitelisted; | pnode->m_legacyWhitelisted = legacyWhitelisted; | ||||
pnode->m_prefer_evict = bannedlevel > 0; | pnode->m_prefer_evict = bannedlevel > 0; | ||||
m_msgproc->InitializeNode(*config, pnode); | m_msgproc->InitializeNode(*config, pnode); | ||||
LogPrint(BCLog::NET, "connection from %s accepted\n", addr.ToString()); | LogPrint(BCLog::NET, "connection from %s accepted\n", addr.ToString()); | ||||
{ | { | ||||
LOCK(cs_vNodes); | LOCK(cs_vNodes); | ||||
vNodes.push_back(pnode); | vNodes.push_back(pnode); | ||||
▲ Show 20 Lines • Show All 1,788 Lines • Show Last 20 Lines |