Changeset View
Changeset View
Standalone View
Standalone View
src/net.cpp
| Show First 20 Lines • Show All 632 Lines • ▼ Show 20 Lines | if (addrLocal.IsValid()) { | ||||
| error("Addr local already set for node: %i. Refusing to change from %s " | error("Addr local already set for node: %i. Refusing to change from %s " | ||||
| "to %s", | "to %s", | ||||
| id, addrLocal.ToString(), addrLocalIn.ToString()); | id, addrLocal.ToString(), addrLocalIn.ToString()); | ||||
| } else { | } else { | ||||
| addrLocal = addrLocalIn; | addrLocal = addrLocalIn; | ||||
| } | } | ||||
| } | } | ||||
| #undef X | |||||
| #define X(name) stats.name = name | |||||
| void CNode::copyStats(CNodeStats &stats) { | void CNode::copyStats(CNodeStats &stats) { | ||||
| stats.nodeid = this->GetId(); | stats.nodeid = this->GetId(); | ||||
| X(nServices); | stats.nServices = nServices; | ||||
| X(addr); | stats.addr = addr; | ||||
| { | { | ||||
| LOCK(cs_filter); | LOCK(cs_filter); | ||||
| X(fRelayTxes); | stats.fRelayTxes = fRelayTxes; | ||||
| } | } | ||||
| X(nLastSend); | stats.nLastSend = nLastSend; | ||||
| X(nLastRecv); | stats.nLastRecv = nLastRecv; | ||||
| X(nTimeConnected); | stats.nTimeConnected = nTimeConnected; | ||||
| X(nTimeOffset); | stats.nTimeOffset = nTimeOffset; | ||||
| stats.addrName = GetAddrName(); | stats.addrName = GetAddrName(); | ||||
| X(nVersion); | stats.nVersion = nVersion; | ||||
| { | { | ||||
| LOCK(cs_SubVer); | LOCK(cs_SubVer); | ||||
| X(cleanSubVer); | stats.cleanSubVer = cleanSubVer; | ||||
| } | } | ||||
| X(fInbound); | stats.fInbound = fInbound; | ||||
| X(fAddnode); | stats.fAddnode = fAddnode; | ||||
| X(nStartingHeight); | stats.nStartingHeight = nStartingHeight; | ||||
| { | { | ||||
| LOCK(cs_vSend); | LOCK(cs_vSend); | ||||
| X(mapSendBytesPerMsgCmd); | stats.mapSendBytesPerMsgCmd = mapSendBytesPerMsgCmd; | ||||
| X(nSendBytes); | stats.nSendBytes = nSendBytes; | ||||
| } | } | ||||
| { | { | ||||
| LOCK(cs_vRecv); | LOCK(cs_vRecv); | ||||
| X(mapRecvBytesPerMsgCmd); | stats.mapRecvBytesPerMsgCmd = mapRecvBytesPerMsgCmd; | ||||
| X(nRecvBytes); | stats.nRecvBytes = nRecvBytes; | ||||
| } | } | ||||
| X(fWhitelisted); | stats.fWhitelisted = fWhitelisted; | ||||
| // 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. | ||||
| int64_t nPingUsecWait = 0; | int64_t nPingUsecWait = 0; | ||||
| if ((0 != nPingNonceSent) && (0 != nPingUsecStart)) { | if ((0 != nPingNonceSent) && (0 != nPingUsecStart)) { | ||||
| nPingUsecWait = GetTimeMicros() - nPingUsecStart; | nPingUsecWait = GetTimeMicros() - nPingUsecStart; | ||||
| } | } | ||||
| // Raw ping time is in microseconds, but show it to user as whole seconds | // Raw ping time is in microseconds, but show it to user as whole seconds | ||||
| // (Bitcoin users should be well used to small numbers with many decimal | // (Bitcoin users should be well used to small numbers with many decimal | ||||
| // places by now :) | // places by now :) | ||||
| stats.dPingTime = ((double(nPingUsecTime)) / 1e6); | stats.dPingTime = ((double(nPingUsecTime)) / 1e6); | ||||
| stats.dMinPing = ((double(nMinPingUsecTime)) / 1e6); | stats.dMinPing = ((double(nMinPingUsecTime)) / 1e6); | ||||
| stats.dPingWait = ((double(nPingUsecWait)) / 1e6); | stats.dPingWait = ((double(nPingUsecWait)) / 1e6); | ||||
| // Leave string empty if addrLocal invalid (not filled in yet) | // Leave string empty if addrLocal invalid (not filled in yet) | ||||
| CService addrLocalUnlocked = GetAddrLocal(); | CService addrLocalUnlocked = GetAddrLocal(); | ||||
| stats.addrLocal = | stats.addrLocal = | ||||
| addrLocalUnlocked.IsValid() ? addrLocalUnlocked.ToString() : ""; | addrLocalUnlocked.IsValid() ? addrLocalUnlocked.ToString() : ""; | ||||
| } | } | ||||
| #undef X | |||||
| static bool IsOversizedMessage(const Config &config, const CNetMessage &msg) { | static bool IsOversizedMessage(const Config &config, const CNetMessage &msg) { | ||||
| if (!msg.in_data) { | if (!msg.in_data) { | ||||
| // Header only, cannot be oversized. | // Header only, cannot be oversized. | ||||
| return false; | return false; | ||||
| } | } | ||||
| return msg.hdr.IsOversized(config); | return msg.hdr.IsOversized(config); | ||||
| ▲ Show 20 Lines • Show All 2,363 Lines • Show Last 20 Lines | |||||