Skip to content

Commit 60b5795

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#23758: net: Use type-safe mockable time for peer connection time
fad9438 scripted-diff: Rename touched member variables (MarcoFalke) fa663a4 Use mockable time for peer connection time (MarcoFalke) fad7ead refactor: Use type-safe std::chrono in net (MarcoFalke) Pull request description: Benefits: * Type-safe * Mockable * Allows to revert a temporary test workaround ACKs for top commit: naumenkogs: ACK fad9438 shaavan: ACK fad9438 Tree-SHA512: af9bdfc695ab727b100c6810a7289d29b02b0ea9fa4fee9cc1f3eeefb52c8c465ea2734bae0c1c63b3b0d6264ba2c493268bc970ef6916570eb166de77829d82
2 parents 2d0bdb2 + fad9438 commit 60b5795

File tree

11 files changed

+102
-95
lines changed

11 files changed

+102
-95
lines changed

src/bench/peer_eviction.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ static void EvictionProtection0Networks250Candidates(benchmark::Bench& bench)
4242
bench,
4343
250 /* num_candidates */,
4444
[](NodeEvictionCandidate& c) {
45-
c.nTimeConnected = c.id;
45+
c.m_connected = std::chrono::seconds{c.id};
4646
c.m_network = NET_IPV4;
4747
});
4848
}
@@ -53,7 +53,7 @@ static void EvictionProtection1Networks250Candidates(benchmark::Bench& bench)
5353
bench,
5454
250 /* num_candidates */,
5555
[](NodeEvictionCandidate& c) {
56-
c.nTimeConnected = c.id;
56+
c.m_connected = std::chrono::seconds{c.id};
5757
c.m_is_local = false;
5858
if (c.id >= 130 && c.id < 240) { // 110 Tor
5959
c.m_network = NET_ONION;
@@ -69,7 +69,7 @@ static void EvictionProtection2Networks250Candidates(benchmark::Bench& bench)
6969
bench,
7070
250 /* num_candidates */,
7171
[](NodeEvictionCandidate& c) {
72-
c.nTimeConnected = c.id;
72+
c.m_connected = std::chrono::seconds{c.id};
7373
c.m_is_local = false;
7474
if (c.id >= 90 && c.id < 160) { // 70 Tor
7575
c.m_network = NET_ONION;
@@ -87,7 +87,7 @@ static void EvictionProtection3Networks050Candidates(benchmark::Bench& bench)
8787
bench,
8888
50 /* num_candidates */,
8989
[](NodeEvictionCandidate& c) {
90-
c.nTimeConnected = c.id;
90+
c.m_connected = std::chrono::seconds{c.id};
9191
c.m_is_local = (c.id == 28 || c.id == 47); // 2 localhost
9292
if (c.id >= 30 && c.id < 47) { // 17 I2P
9393
c.m_network = NET_I2P;
@@ -105,7 +105,7 @@ static void EvictionProtection3Networks100Candidates(benchmark::Bench& bench)
105105
bench,
106106
100 /* num_candidates */,
107107
[](NodeEvictionCandidate& c) {
108-
c.nTimeConnected = c.id;
108+
c.m_connected = std::chrono::seconds{c.id};
109109
c.m_is_local = (c.id >= 55 && c.id < 60); // 5 localhost
110110
if (c.id >= 70 && c.id < 80) { // 10 I2P
111111
c.m_network = NET_I2P;
@@ -123,7 +123,7 @@ static void EvictionProtection3Networks250Candidates(benchmark::Bench& bench)
123123
bench,
124124
250 /* num_candidates */,
125125
[](NodeEvictionCandidate& c) {
126-
c.nTimeConnected = c.id;
126+
c.m_connected = std::chrono::seconds{c.id};
127127
c.m_is_local = (c.id >= 140 && c.id < 160); // 20 localhost
128128
if (c.id >= 170 && c.id < 180) { // 10 I2P
129129
c.m_network = NET_I2P;

src/net.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -588,9 +588,9 @@ void CNode::CopyStats(CNodeStats& stats)
588588
}
589589
X(m_last_send);
590590
X(m_last_recv);
591-
X(nLastTXTime);
592-
X(nLastBlockTime);
593-
X(nTimeConnected);
591+
X(m_last_tx_time);
592+
X(m_last_block_time);
593+
X(m_connected);
594594
X(nTimeOffset);
595595
X(m_addr_name);
596596
X(nVersion);
@@ -847,7 +847,7 @@ static bool ReverseCompareNodeMinPingTime(const NodeEvictionCandidate &a, const
847847

848848
static bool ReverseCompareNodeTimeConnected(const NodeEvictionCandidate &a, const NodeEvictionCandidate &b)
849849
{
850-
return a.nTimeConnected > b.nTimeConnected;
850+
return a.m_connected > b.m_connected;
851851
}
852852

853853
static bool CompareNetGroupKeyed(const NodeEvictionCandidate &a, const NodeEvictionCandidate &b) {
@@ -857,27 +857,27 @@ static bool CompareNetGroupKeyed(const NodeEvictionCandidate &a, const NodeEvict
857857
static bool CompareNodeBlockTime(const NodeEvictionCandidate &a, const NodeEvictionCandidate &b)
858858
{
859859
// There is a fall-through here because it is common for a node to have many peers which have not yet relayed a block.
860-
if (a.nLastBlockTime != b.nLastBlockTime) return a.nLastBlockTime < b.nLastBlockTime;
860+
if (a.m_last_block_time != b.m_last_block_time) return a.m_last_block_time < b.m_last_block_time;
861861
if (a.fRelevantServices != b.fRelevantServices) return b.fRelevantServices;
862-
return a.nTimeConnected > b.nTimeConnected;
862+
return a.m_connected > b.m_connected;
863863
}
864864

865865
static bool CompareNodeTXTime(const NodeEvictionCandidate &a, const NodeEvictionCandidate &b)
866866
{
867867
// There is a fall-through here because it is common for a node to have more than a few peers that have not yet relayed txn.
868-
if (a.nLastTXTime != b.nLastTXTime) return a.nLastTXTime < b.nLastTXTime;
868+
if (a.m_last_tx_time != b.m_last_tx_time) return a.m_last_tx_time < b.m_last_tx_time;
869869
if (a.fRelayTxes != b.fRelayTxes) return b.fRelayTxes;
870870
if (a.fBloomFilter != b.fBloomFilter) return a.fBloomFilter;
871-
return a.nTimeConnected > b.nTimeConnected;
871+
return a.m_connected > b.m_connected;
872872
}
873873

874874
// Pick out the potential block-relay only peers, and sort them by last block time.
875875
static bool CompareNodeBlockRelayOnlyTime(const NodeEvictionCandidate &a, const NodeEvictionCandidate &b)
876876
{
877877
if (a.fRelayTxes != b.fRelayTxes) return a.fRelayTxes;
878-
if (a.nLastBlockTime != b.nLastBlockTime) return a.nLastBlockTime < b.nLastBlockTime;
878+
if (a.m_last_block_time != b.m_last_block_time) return a.m_last_block_time < b.m_last_block_time;
879879
if (a.fRelevantServices != b.fRelevantServices) return b.fRelevantServices;
880-
return a.nTimeConnected > b.nTimeConnected;
880+
return a.m_connected > b.m_connected;
881881
}
882882

883883
/**
@@ -896,7 +896,7 @@ struct CompareNodeNetworkTime {
896896
{
897897
if (m_is_local && a.m_is_local != b.m_is_local) return b.m_is_local;
898898
if ((a.m_network == m_network) != (b.m_network == m_network)) return b.m_network == m_network;
899-
return a.nTimeConnected > b.nTimeConnected;
899+
return a.m_connected > b.m_connected;
900900
};
901901
};
902902

@@ -1023,12 +1023,12 @@ void ProtectEvictionCandidatesByRatio(std::vector<NodeEvictionCandidate>& evicti
10231023
// (vEvictionCandidates is already sorted by reverse connect time)
10241024
uint64_t naMostConnections;
10251025
unsigned int nMostConnections = 0;
1026-
int64_t nMostConnectionsTime = 0;
1026+
std::chrono::seconds nMostConnectionsTime{0};
10271027
std::map<uint64_t, std::vector<NodeEvictionCandidate> > mapNetGroupNodes;
10281028
for (const NodeEvictionCandidate &node : vEvictionCandidates) {
10291029
std::vector<NodeEvictionCandidate> &group = mapNetGroupNodes[node.nKeyedNetGroup];
10301030
group.push_back(node);
1031-
const int64_t grouptime = group[0].nTimeConnected;
1031+
const auto grouptime{group[0].m_connected};
10321032

10331033
if (group.size() > nMostConnections || (group.size() == nMostConnections && grouptime > nMostConnectionsTime)) {
10341034
nMostConnections = group.size();
@@ -1072,8 +1072,8 @@ bool CConnman::AttemptToEvictConnection()
10721072
peer_relay_txes = node->m_tx_relay->fRelayTxes;
10731073
peer_filter_not_null = node->m_tx_relay->pfilter != nullptr;
10741074
}
1075-
NodeEvictionCandidate candidate = {node->GetId(), node->nTimeConnected, node->m_min_ping_time,
1076-
node->nLastBlockTime, node->nLastTXTime,
1075+
NodeEvictionCandidate candidate = {node->GetId(), node->m_connected, node->m_min_ping_time,
1076+
node->m_last_block_time, node->m_last_tx_time,
10771077
HasAllDesirableServiceFlags(node->nServices),
10781078
peer_relay_txes, peer_filter_not_null, node->nKeyedNetGroup,
10791079
node->m_prefer_evict, node->addr.IsLocal(),
@@ -1322,7 +1322,7 @@ void CConnman::NotifyNumConnectionsChanged()
13221322

13231323
bool CConnman::ShouldRunInactivityChecks(const CNode& node, std::chrono::seconds now) const
13241324
{
1325-
return std::chrono::seconds{node.nTimeConnected} + m_peer_connect_timeout < now;
1325+
return node.m_connected + m_peer_connect_timeout < now;
13261326
}
13271327

13281328
bool CConnman::InactivityCheck(const CNode& node) const
@@ -2977,7 +2977,7 @@ ServiceFlags CConnman::GetLocalServices() const
29772977
unsigned int CConnman::GetReceiveFloodSize() const { return nReceiveFloodSize; }
29782978

29792979
CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, SOCKET hSocketIn, const CAddress& addrIn, uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn, const CAddress& addrBindIn, const std::string& addrNameIn, ConnectionType conn_type_in, bool inbound_onion)
2980-
: nTimeConnected(GetTimeSeconds()),
2980+
: m_connected{GetTime<std::chrono::seconds>()},
29812981
addr(addrIn),
29822982
addrBind(addrBindIn),
29832983
m_addr_name{addrNameIn.empty() ? addr.ToStringIPPort() : addrNameIn},

src/net.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,9 @@ class CNodeStats
243243
bool fRelayTxes;
244244
std::chrono::seconds m_last_send;
245245
std::chrono::seconds m_last_recv;
246-
int64_t nLastTXTime;
247-
int64_t nLastBlockTime;
248-
int64_t nTimeConnected;
246+
std::chrono::seconds m_last_tx_time;
247+
std::chrono::seconds m_last_block_time;
248+
std::chrono::seconds m_connected;
249249
int64_t nTimeOffset;
250250
std::string m_addr_name;
251251
int nVersion;
@@ -422,8 +422,8 @@ class CNode
422422

423423
std::atomic<std::chrono::seconds> m_last_send{0s};
424424
std::atomic<std::chrono::seconds> m_last_recv{0s};
425-
//! Unix epoch time at peer connection, in seconds.
426-
const int64_t nTimeConnected;
425+
//! Unix epoch time at peer connection
426+
const std::chrono::seconds m_connected;
427427
std::atomic<int64_t> nTimeOffset{0};
428428
// Address of this peer
429429
const CAddress addr;
@@ -562,13 +562,13 @@ class CNode
562562
* preliminary validity checks and was saved to disk, even if we don't
563563
* connect the block or it eventually fails connection. Used as an inbound
564564
* peer eviction criterium in CConnman::AttemptToEvictConnection. */
565-
std::atomic<int64_t> nLastBlockTime{0};
565+
std::atomic<std::chrono::seconds> m_last_block_time{0s};
566566

567567
/** UNIX epoch time of the last transaction received from this peer that we
568568
* had not yet seen (e.g. not already received from another peer) and that
569569
* was accepted into our mempool. Used as an inbound peer eviction criterium
570570
* in CConnman::AttemptToEvictConnection. */
571-
std::atomic<int64_t> nLastTXTime{0};
571+
std::atomic<std::chrono::seconds> m_last_tx_time{0s};
572572

573573
/** Last measured round-trip time. Used only for RPC/GUI stats/debugging.*/
574574
std::atomic<std::chrono::microseconds> m_last_ping_time{0us};
@@ -1274,10 +1274,10 @@ void CaptureMessage(const CAddress& addr, const std::string& msg_type, const Spa
12741274
struct NodeEvictionCandidate
12751275
{
12761276
NodeId id;
1277-
int64_t nTimeConnected;
1277+
std::chrono::seconds m_connected;
12781278
std::chrono::microseconds m_min_ping_time;
1279-
int64_t nLastBlockTime;
1280-
int64_t nLastTXTime;
1279+
std::chrono::seconds m_last_block_time;
1280+
std::chrono::seconds m_last_tx_time;
12811281
bool fRelevantServices;
12821282
bool fRelayTxes;
12831283
bool fBloomFilter;

src/net_processing.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ static constexpr int64_t CHAIN_SYNC_TIMEOUT = 20 * 60; // 20 minutes
6161
static constexpr int64_t STALE_CHECK_INTERVAL = 10 * 60; // 10 minutes
6262
/** How frequently to check for extra outbound peers and disconnect, in seconds */
6363
static constexpr int64_t EXTRA_PEER_CHECK_INTERVAL = 45;
64-
/** Minimum time an outbound-peer-eviction candidate must be connected for, in order to evict, in seconds */
65-
static constexpr int64_t MINIMUM_CONNECT_TIME = 30;
64+
/** Minimum time an outbound-peer-eviction candidate must be connected for, in order to evict */
65+
static constexpr std::chrono::seconds MINIMUM_CONNECT_TIME{30};
6666
/** SHA256("main address relay")[0:8] */
6767
static constexpr uint64_t RANDOMIZER_ID_ADDRESS_RELAY = 0x3cac0035b5866b90ULL;
6868
/// Age after which a stale block will no longer be served if requested as
@@ -330,7 +330,7 @@ class PeerManagerImpl final : public PeerManager
330330
void ConsiderEviction(CNode& pto, int64_t time_in_seconds) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
331331

332332
/** If we have extra outbound peers, try to disconnect the one with the oldest block announcement */
333-
void EvictExtraOutboundPeers(int64_t time_in_seconds) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
333+
void EvictExtraOutboundPeers(std::chrono::seconds now) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
334334

335335
/** Retrieve unbroadcast transactions from the mempool and reattempt sending to peers */
336336
void ReattemptInitialBroadcast(CScheduler& scheduler);
@@ -2511,7 +2511,7 @@ void PeerManagerImpl::ProcessBlock(CNode& node, const std::shared_ptr<const CBlo
25112511
bool new_block{false};
25122512
m_chainman.ProcessNewBlock(m_chainparams, block, force_processing, &new_block);
25132513
if (new_block) {
2514-
node.nLastBlockTime = GetTime();
2514+
node.m_last_block_time = GetTime<std::chrono::seconds>();
25152515
} else {
25162516
LOCK(cs_main);
25172517
mapBlockSource.erase(block->GetHash());
@@ -3314,7 +3314,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
33143314
_RelayTransaction(tx.GetHash(), tx.GetWitnessHash());
33153315
m_orphanage.AddChildrenToWorkSet(tx, peer->m_orphan_work_set);
33163316

3317-
pfrom.nLastTXTime = GetTime();
3317+
pfrom.m_last_tx_time = GetTime<std::chrono::seconds>();
33183318

33193319
LogPrint(BCLog::MEMPOOL, "AcceptToMemoryPool: peer=%d: accepted %s (poolsz %u txn, %u kB)\n",
33203320
pfrom.GetId(),
@@ -4228,7 +4228,7 @@ void PeerManagerImpl::ConsiderEviction(CNode& pto, int64_t time_in_seconds)
42284228
}
42294229
}
42304230

4231-
void PeerManagerImpl::EvictExtraOutboundPeers(int64_t time_in_seconds)
4231+
void PeerManagerImpl::EvictExtraOutboundPeers(std::chrono::seconds now)
42324232
{
42334233
// If we have any extra block-relay-only peers, disconnect the youngest unless
42344234
// it's given us a block -- in which case, compare with the second-youngest, and
@@ -4237,14 +4237,14 @@ void PeerManagerImpl::EvictExtraOutboundPeers(int64_t time_in_seconds)
42374237
// to temporarily in order to sync our tip; see net.cpp.
42384238
// Note that we use higher nodeid as a measure for most recent connection.
42394239
if (m_connman.GetExtraBlockRelayCount() > 0) {
4240-
std::pair<NodeId, int64_t> youngest_peer{-1, 0}, next_youngest_peer{-1, 0};
4240+
std::pair<NodeId, std::chrono::seconds> youngest_peer{-1, 0}, next_youngest_peer{-1, 0};
42414241

42424242
m_connman.ForEachNode([&](CNode* pnode) {
42434243
if (!pnode->IsBlockOnlyConn() || pnode->fDisconnect) return;
42444244
if (pnode->GetId() > youngest_peer.first) {
42454245
next_youngest_peer = youngest_peer;
42464246
youngest_peer.first = pnode->GetId();
4247-
youngest_peer.second = pnode->nLastBlockTime;
4247+
youngest_peer.second = pnode->m_last_block_time;
42484248
}
42494249
});
42504250
NodeId to_disconnect = youngest_peer.first;
@@ -4262,13 +4262,14 @@ void PeerManagerImpl::EvictExtraOutboundPeers(int64_t time_in_seconds)
42624262
// valid headers chain with at least as much work as our tip.
42634263
CNodeState *node_state = State(pnode->GetId());
42644264
if (node_state == nullptr ||
4265-
(time_in_seconds - pnode->nTimeConnected >= MINIMUM_CONNECT_TIME && node_state->nBlocksInFlight == 0)) {
4265+
(now - pnode->m_connected >= MINIMUM_CONNECT_TIME && node_state->nBlocksInFlight == 0)) {
42664266
pnode->fDisconnect = true;
4267-
LogPrint(BCLog::NET, "disconnecting extra block-relay-only peer=%d (last block received at time %d)\n", pnode->GetId(), pnode->nLastBlockTime);
4267+
LogPrint(BCLog::NET, "disconnecting extra block-relay-only peer=%d (last block received at time %d)\n",
4268+
pnode->GetId(), count_seconds(pnode->m_last_block_time));
42684269
return true;
42694270
} else {
42704271
LogPrint(BCLog::NET, "keeping block-relay-only peer=%d chosen for eviction (connect time: %d, blocks_in_flight: %d)\n",
4271-
pnode->GetId(), pnode->nTimeConnected, node_state->nBlocksInFlight);
4272+
pnode->GetId(), count_seconds(pnode->m_connected), node_state->nBlocksInFlight);
42724273
}
42734274
return false;
42744275
});
@@ -4308,12 +4309,13 @@ void PeerManagerImpl::EvictExtraOutboundPeers(int64_t time_in_seconds)
43084309
// Also don't disconnect any peer we're trying to download a
43094310
// block from.
43104311
CNodeState &state = *State(pnode->GetId());
4311-
if (time_in_seconds - pnode->nTimeConnected > MINIMUM_CONNECT_TIME && state.nBlocksInFlight == 0) {
4312+
if (now - pnode->m_connected > MINIMUM_CONNECT_TIME && state.nBlocksInFlight == 0) {
43124313
LogPrint(BCLog::NET, "disconnecting extra outbound peer=%d (last block announcement received at time %d)\n", pnode->GetId(), oldest_block_announcement);
43134314
pnode->fDisconnect = true;
43144315
return true;
43154316
} else {
4316-
LogPrint(BCLog::NET, "keeping outbound peer=%d chosen for eviction (connect time: %d, blocks_in_flight: %d)\n", pnode->GetId(), pnode->nTimeConnected, state.nBlocksInFlight);
4317+
LogPrint(BCLog::NET, "keeping outbound peer=%d chosen for eviction (connect time: %d, blocks_in_flight: %d)\n",
4318+
pnode->GetId(), count_seconds(pnode->m_connected), state.nBlocksInFlight);
43174319
return false;
43184320
}
43194321
});
@@ -4335,7 +4337,7 @@ void PeerManagerImpl::CheckForStaleTipAndEvictPeers()
43354337

43364338
int64_t time_in_seconds = GetTime();
43374339

4338-
EvictExtraOutboundPeers(time_in_seconds);
4340+
EvictExtraOutboundPeers(std::chrono::seconds{time_in_seconds});
43394341

43404342
if (time_in_seconds > m_stale_tip_check_time) {
43414343
// Check whether our tip is stale, and if so, allow using an extra
@@ -4565,7 +4567,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
45654567

45664568
const auto current_time = GetTime<std::chrono::microseconds>();
45674569

4568-
if (pto->IsAddrFetchConn() && current_time - std::chrono::seconds(pto->nTimeConnected) > 10 * AVG_ADDRESS_BROADCAST_INTERVAL) {
4570+
if (pto->IsAddrFetchConn() && current_time - pto->m_connected > 10 * AVG_ADDRESS_BROADCAST_INTERVAL) {
45694571
LogPrint(BCLog::NET, "addrfetch connection timeout; disconnecting peer=%d\n", pto->GetId());
45704572
pto->fDisconnect = true;
45714573
return true;

src/qt/rpcconsole.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,9 +1173,9 @@ void RPCConsole::updateDetailWidget()
11731173
if (bip152_hb_settings.isEmpty()) bip152_hb_settings = ts.no;
11741174
ui->peerHighBandwidth->setText(bip152_hb_settings);
11751175
const auto time_now{GetTime<std::chrono::seconds>()};
1176-
ui->peerConnTime->setText(GUIUtil::formatDurationStr(time_now - std::chrono::seconds{stats->nodeStats.nTimeConnected}));
1177-
ui->peerLastBlock->setText(TimeDurationField(time_now, std::chrono::seconds{stats->nodeStats.nLastBlockTime}));
1178-
ui->peerLastTx->setText(TimeDurationField(time_now, std::chrono::seconds{stats->nodeStats.nLastTXTime}));
1176+
ui->peerConnTime->setText(GUIUtil::formatDurationStr(time_now - stats->nodeStats.m_connected));
1177+
ui->peerLastBlock->setText(TimeDurationField(time_now, stats->nodeStats.m_last_block_time));
1178+
ui->peerLastTx->setText(TimeDurationField(time_now, stats->nodeStats.m_last_tx_time));
11791179
ui->peerLastSend->setText(TimeDurationField(time_now, stats->nodeStats.m_last_send));
11801180
ui->peerLastRecv->setText(TimeDurationField(time_now, stats->nodeStats.m_last_recv));
11811181
ui->peerBytesSent->setText(GUIUtil::formatBytes(stats->nodeStats.nSendBytes));

src/rpc/net.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,11 @@ static RPCHelpMan getpeerinfo()
198198
obj.pushKV("relaytxes", stats.fRelayTxes);
199199
obj.pushKV("lastsend", count_seconds(stats.m_last_send));
200200
obj.pushKV("lastrecv", count_seconds(stats.m_last_recv));
201-
obj.pushKV("last_transaction", stats.nLastTXTime);
202-
obj.pushKV("last_block", stats.nLastBlockTime);
201+
obj.pushKV("last_transaction", count_seconds(stats.m_last_tx_time));
202+
obj.pushKV("last_block", count_seconds(stats.m_last_block_time));
203203
obj.pushKV("bytessent", stats.nSendBytes);
204204
obj.pushKV("bytesrecv", stats.nRecvBytes);
205-
obj.pushKV("conntime", stats.nTimeConnected);
205+
obj.pushKV("conntime", count_seconds(stats.m_connected));
206206
obj.pushKV("timeoffset", stats.nTimeOffset);
207207
if (stats.m_last_ping_time > 0us) {
208208
obj.pushKV("pingtime", CountSecondsDouble(stats.m_last_ping_time));

0 commit comments

Comments
 (0)