Skip to content

Commit

Permalink
scripted-diff: Rename m_last_send and m_last_recv
Browse files Browse the repository at this point in the history
-BEGIN VERIFY SCRIPT-

ren() { sed -i "s/\<$1\>/$2/g" $(git grep -l "$1" ./src) ; }

ren nLastSend m_last_send
ren nLastRecv m_last_recv

-END VERIFY SCRIPT-
  • Loading branch information
MarcoFalke committed Nov 2, 2021
1 parent 9e3f7dc commit fa3a76f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
20 changes: 10 additions & 10 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,8 @@ void CNode::CopyStats(CNodeStats& stats)
} else {
stats.fRelayTxes = false;
}
X(nLastSend);
X(nLastRecv);
X(m_last_send);
X(m_last_recv);
X(nLastTXTime);
X(nLastBlockTime);
X(nTimeConnected);
Expand Down Expand Up @@ -614,7 +614,7 @@ bool CNode::ReceiveMsgBytes(Span<const uint8_t> msg_bytes, bool& complete)
complete = false;
const auto time = GetTime<std::chrono::microseconds>();
LOCK(cs_vRecv);
nLastRecv = std::chrono::duration_cast<std::chrono::seconds>(time).count();
m_last_recv = std::chrono::duration_cast<std::chrono::seconds>(time).count();
nRecvBytes += msg_bytes.size();
while (msg_bytes.size() > 0) {
// absorb network data
Expand Down Expand Up @@ -785,7 +785,7 @@ size_t CConnman::SocketSendData(CNode& node) const
nBytes = send(node.hSocket, reinterpret_cast<const char*>(data.data()) + node.nSendOffset, data.size() - node.nSendOffset, MSG_NOSIGNAL | MSG_DONTWAIT);
}
if (nBytes > 0) {
node.nLastSend = GetTimeSeconds();
node.m_last_send = GetTimeSeconds();
node.nSendBytes += nBytes;
node.nSendOffset += nBytes;
nSentSize += nBytes;
Expand Down Expand Up @@ -1309,18 +1309,18 @@ bool CConnman::InactivityCheck(const CNode& node) const

if (!ShouldRunInactivityChecks(node, now)) return false;

if (node.nLastRecv == 0 || node.nLastSend == 0) {
LogPrint(BCLog::NET, "socket no message in first %i seconds, %d %d peer=%d\n", m_peer_connect_timeout, node.nLastRecv != 0, node.nLastSend != 0, node.GetId());
if (node.m_last_recv == 0 || node.m_last_send == 0) {
LogPrint(BCLog::NET, "socket no message in first %i seconds, %d %d peer=%d\n", m_peer_connect_timeout, node.m_last_recv != 0, node.m_last_send != 0, node.GetId());
return true;
}

if (now > node.nLastSend + TIMEOUT_INTERVAL) {
LogPrint(BCLog::NET, "socket sending timeout: %is peer=%d\n", now - node.nLastSend, node.GetId());
if (now > node.m_last_send + TIMEOUT_INTERVAL) {
LogPrint(BCLog::NET, "socket sending timeout: %is peer=%d\n", now - node.m_last_send, node.GetId());
return true;
}

if (now > node.nLastRecv + TIMEOUT_INTERVAL) {
LogPrint(BCLog::NET, "socket receive timeout: %is peer=%d\n", now - node.nLastRecv, node.GetId());
if (now > node.m_last_recv + TIMEOUT_INTERVAL) {
LogPrint(BCLog::NET, "socket receive timeout: %is peer=%d\n", now - node.m_last_recv, node.GetId());
return true;
}

Expand Down
8 changes: 4 additions & 4 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ class CNodeStats
NodeId nodeid;
ServiceFlags nServices;
bool fRelayTxes;
int64_t nLastSend;
int64_t nLastRecv;
int64_t m_last_send;
int64_t m_last_recv;
int64_t nLastTXTime;
int64_t nLastBlockTime;
int64_t nTimeConnected;
Expand Down Expand Up @@ -420,8 +420,8 @@ class CNode

uint64_t nRecvBytes GUARDED_BY(cs_vRecv){0};

std::atomic<int64_t> nLastSend{0};
std::atomic<int64_t> nLastRecv{0};
std::atomic<int64_t> m_last_send{0};
std::atomic<int64_t> m_last_recv{0};
//! Unix epoch time at peer connection, in seconds.
const int64_t nTimeConnected;
std::atomic<int64_t> nTimeOffset{0};
Expand Down
4 changes: 2 additions & 2 deletions src/qt/rpcconsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1172,8 +1172,8 @@ void RPCConsole::updateDetailWidget()
ui->peerConnTime->setText(GUIUtil::formatDurationStr(time_now - stats->nodeStats.nTimeConnected));
ui->peerLastBlock->setText(TimeDurationField(time_now, stats->nodeStats.nLastBlockTime));
ui->peerLastTx->setText(TimeDurationField(time_now, stats->nodeStats.nLastTXTime));
ui->peerLastSend->setText(TimeDurationField(time_now, stats->nodeStats.nLastSend));
ui->peerLastRecv->setText(TimeDurationField(time_now, stats->nodeStats.nLastRecv));
ui->peerLastSend->setText(TimeDurationField(time_now, stats->nodeStats.m_last_send));
ui->peerLastRecv->setText(TimeDurationField(time_now, stats->nodeStats.m_last_recv));
ui->peerBytesSent->setText(GUIUtil::formatBytes(stats->nodeStats.nSendBytes));
ui->peerBytesRecv->setText(GUIUtil::formatBytes(stats->nodeStats.nRecvBytes));
ui->peerPingTime->setText(GUIUtil::formatPingTime(stats->nodeStats.m_last_ping_time));
Expand Down
4 changes: 2 additions & 2 deletions src/rpc/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ static RPCHelpMan getpeerinfo()
obj.pushKV("services", strprintf("%016x", stats.nServices));
obj.pushKV("servicesnames", GetServicesNames(stats.nServices));
obj.pushKV("relaytxes", stats.fRelayTxes);
obj.pushKV("lastsend", stats.nLastSend);
obj.pushKV("lastrecv", stats.nLastRecv);
obj.pushKV("lastsend", stats.m_last_send);
obj.pushKV("lastrecv", stats.m_last_recv);
obj.pushKV("last_transaction", stats.nLastTXTime);
obj.pushKV("last_block", stats.nLastBlockTime);
obj.pushKV("bytessent", stats.nSendBytes);
Expand Down

0 comments on commit fa3a76f

Please sign in to comment.