| 682 | #undef X |
| 683 | #define X(name) stats.name = name |
| 684 | void CNode::copyStats(CNodeStats &stats) |
| 685 | { |
| 686 | stats.nodeid = this->GetId(); |
| 687 | X(nServices); |
| 688 | X(addr); |
| 689 | X(addrBind); |
| 690 | { |
| 691 | LOCK(cs_filter); |
| 692 | X(fRelayTxes); |
| 693 | } |
| 694 | X(nLastSend); |
| 695 | X(nLastRecv); |
| 696 | X(nTimeConnected); |
| 697 | X(nTimeOffset); |
| 698 | stats.addrName = GetAddrName(); |
| 699 | X(nVersion); |
| 700 | { |
| 701 | LOCK(cs_SubVer); |
| 702 | X(cleanSubVer); |
| 703 | } |
| 704 | X(fInbound); |
| 705 | X(m_manual_connection); |
| 706 | X(nStartingHeight); |
| 707 | { |
| 708 | LOCK(cs_vSend); |
| 709 | X(mapSendBytesPerMsgCmd); |
| 710 | X(nSendBytes); |
| 711 | } |
| 712 | { |
| 713 | LOCK(cs_vRecv); |
| 714 | X(mapRecvBytesPerMsgCmd); |
| 715 | X(nRecvBytes); |
| 716 | } |
| 717 | X(fWhitelisted); |
| 718 | |
| 719 | // It is common for nodes with good ping times to suddenly become lagged, |
| 720 | // due to a new block arriving or other large transfer. |
| 721 | // Merely reporting pingtime might fool the caller into thinking the node was still responsive, |
| 722 | // since pingtime does not update until the ping is complete, which might take a while. |
| 723 | // So, if a ping is taking an unusually long time in flight, |
| 724 | // the caller can immediately detect that this is happening. |
| 725 | int64_t nPingUsecWait = 0; |
| 726 | if ((0 != nPingNonceSent) && (0 != nPingUsecStart)) { |
| 727 | nPingUsecWait = GetTimeMicros() - nPingUsecStart; |
| 728 | } |
| 729 | |
| 730 | // 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 places by now :) |
| 731 | stats.dPingTime = (((double)nPingUsecTime) / 1e6); |
| 732 | stats.dMinPing = (((double)nMinPingUsecTime) / 1e6); |
| 733 | stats.dPingWait = (((double)nPingUsecWait) / 1e6); |
| 734 | |
| 735 | // Leave string empty if addrLocal invalid (not filled in yet) |
| 736 | CService addrLocalUnlocked = GetAddrLocal(); |
| 737 | stats.addrLocal = addrLocalUnlocked.IsValid() ? addrLocalUnlocked.ToString() : ""; |
| 738 | } |
| 739 | #undef X |
| 740 | |
| 741 | bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes, bool& complete) |
no test coverage detected