Changeset View
Changeset View
Standalone View
Standalone View
src/net.cpp
Show First 20 Lines • Show All 503 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void CNode::copyStats(CNodeStats &stats) { | void CNode::copyStats(CNodeStats &stats) { | ||||
stats.nodeid = this->GetId(); | stats.nodeid = this->GetId(); | ||||
stats.nServices = nServices; | stats.nServices = nServices; | ||||
stats.addr = addr; | stats.addr = addr; | ||||
stats.addrBind = addrBind; | stats.addrBind = addrBind; | ||||
{ | { | ||||
LOCK(m_tx_relay.cs_filter); | LOCK(m_tx_relay->cs_filter); | ||||
stats.fRelayTxes = m_tx_relay.fRelayTxes; | stats.fRelayTxes = m_tx_relay->fRelayTxes; | ||||
} | } | ||||
stats.nLastSend = nLastSend; | stats.nLastSend = nLastSend; | ||||
stats.nLastRecv = nLastRecv; | stats.nLastRecv = nLastRecv; | ||||
stats.nTimeConnected = nTimeConnected; | stats.nTimeConnected = nTimeConnected; | ||||
stats.nTimeOffset = nTimeOffset; | stats.nTimeOffset = nTimeOffset; | ||||
stats.addrName = GetAddrName(); | stats.addrName = GetAddrName(); | ||||
stats.nVersion = nVersion; | stats.nVersion = nVersion; | ||||
{ | { | ||||
Show All 11 Lines | void CNode::copyStats(CNodeStats &stats) { | ||||
{ | { | ||||
LOCK(cs_vRecv); | LOCK(cs_vRecv); | ||||
stats.mapRecvBytesPerMsgCmd = mapRecvBytesPerMsgCmd; | stats.mapRecvBytesPerMsgCmd = mapRecvBytesPerMsgCmd; | ||||
stats.nRecvBytes = nRecvBytes; | stats.nRecvBytes = nRecvBytes; | ||||
} | } | ||||
stats.m_legacyWhitelisted = m_legacyWhitelisted; | stats.m_legacyWhitelisted = m_legacyWhitelisted; | ||||
stats.m_permissionFlags = m_permissionFlags; | stats.m_permissionFlags = m_permissionFlags; | ||||
{ | { | ||||
LOCK(m_tx_relay.cs_feeFilter); | LOCK(m_tx_relay->cs_feeFilter); | ||||
stats.minFeeFilter = m_tx_relay.minFeeFilter; | stats.minFeeFilter = m_tx_relay->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 | ||||
// pingtime might fool the caller into thinking the node was still | // pingtime might fool the caller into thinking the node was still | ||||
// responsive, since pingtime does not update until the ping is complete, | // responsive, since pingtime does not update until the ping is complete, | ||||
// which might take a while. So, if a ping is taking an unusually long time | // which might take a while. So, if a ping is taking an unusually long time | ||||
// in flight, the caller can immediately detect that this is happening. | // in flight, the caller can immediately detect that this is happening. | ||||
▲ Show 20 Lines • Show All 323 Lines • ▼ Show 20 Lines | std::vector<NodeEvictionCandidate> vEvictionCandidates; | ||||
continue; | continue; | ||||
} | } | ||||
if (!node->fInbound) { | if (!node->fInbound) { | ||||
continue; | continue; | ||||
} | } | ||||
if (node->fDisconnect) { | if (node->fDisconnect) { | ||||
continue; | continue; | ||||
} | } | ||||
LOCK(node->m_tx_relay.cs_filter); | LOCK(node->m_tx_relay->cs_filter); | ||||
NodeEvictionCandidate candidate = { | NodeEvictionCandidate candidate = { | ||||
node->GetId(), | node->GetId(), | ||||
node->nTimeConnected, | node->nTimeConnected, | ||||
node->nMinPingUsecTime, | node->nMinPingUsecTime, | ||||
node->nLastBlockTime, | node->nLastBlockTime, | ||||
node->nLastTXTime, | node->nLastTXTime, | ||||
HasAllDesirableServiceFlags(node->nServices), | HasAllDesirableServiceFlags(node->nServices), | ||||
node->m_tx_relay.fRelayTxes, | node->m_tx_relay->fRelayTxes, | ||||
node->m_tx_relay.pfilter != nullptr, | node->m_tx_relay->pfilter != nullptr, | ||||
node->addr, | node->addr, | ||||
node->nKeyedNetGroup, | node->nKeyedNetGroup, | ||||
node->m_prefer_evict}; | node->m_prefer_evict}; | ||||
vEvictionCandidates.push_back(candidate); | vEvictionCandidates.push_back(candidate); | ||||
} | } | ||||
} | } | ||||
// Protect connections with certain characteristics | // Protect connections with certain characteristics | ||||
▲ Show 20 Lines • Show All 1,823 Lines • ▼ Show 20 Lines | : nTimeConnected(GetSystemTimeInSeconds()), addr(addrIn), | ||||
addrBind(addrBindIn), fInbound(fInboundIn), | addrBind(addrBindIn), fInbound(fInboundIn), | ||||
nKeyedNetGroup(nKeyedNetGroupIn), addrKnown(5000, 0.001), id(idIn), | nKeyedNetGroup(nKeyedNetGroupIn), addrKnown(5000, 0.001), id(idIn), | ||||
nLocalHostNonce(nLocalHostNonceIn), nLocalServices(nLocalServicesIn), | nLocalHostNonce(nLocalHostNonceIn), nLocalServices(nLocalServicesIn), | ||||
nMyStartingHeight(nMyStartingHeightIn) { | nMyStartingHeight(nMyStartingHeightIn) { | ||||
hSocket = hSocketIn; | hSocket = hSocketIn; | ||||
addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn; | addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn; | ||||
strSubVer = ""; | strSubVer = ""; | ||||
hashContinue = BlockHash(); | hashContinue = BlockHash(); | ||||
m_tx_relay = std::make_unique<TxRelay>(); | |||||
for (const std::string &msg : getAllNetMessageTypes()) { | for (const std::string &msg : getAllNetMessageTypes()) { | ||||
mapRecvBytesPerMsgCmd[msg] = 0; | mapRecvBytesPerMsgCmd[msg] = 0; | ||||
} | } | ||||
mapRecvBytesPerMsgCmd[NET_MESSAGE_COMMAND_OTHER] = 0; | mapRecvBytesPerMsgCmd[NET_MESSAGE_COMMAND_OTHER] = 0; | ||||
if (fLogIPs) { | if (fLogIPs) { | ||||
LogPrint(BCLog::NET, "Added connection to %s peer=%d\n", addrName, id); | LogPrint(BCLog::NET, "Added connection to %s peer=%d\n", addrName, id); | ||||
▲ Show 20 Lines • Show All 145 Lines • Show Last 20 Lines |