Skip to content

Commit fa1dc9b

Browse files
author
MarcoFalke
committed
p2p: Always serialize local timestamp for version msg
1 parent 9635760 commit fa1dc9b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Diff for: src/net_processing.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ class PeerManagerImpl final : public PeerManager
386386
EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
387387

388388
/** Send a version message to a peer */
389-
void PushNodeVersion(CNode& pnode, int64_t nTime);
389+
void PushNodeVersion(CNode& pnode);
390390

391391
/** Send a ping message every PING_INTERVAL or if requested via RPC. May
392392
* mark the peer to be disconnected if a ping has timed out.
@@ -1090,12 +1090,13 @@ void PeerManagerImpl::FindNextBlocksToDownload(NodeId nodeid, unsigned int count
10901090

10911091
} // namespace
10921092

1093-
void PeerManagerImpl::PushNodeVersion(CNode& pnode, int64_t nTime)
1093+
void PeerManagerImpl::PushNodeVersion(CNode& pnode)
10941094
{
10951095
// Note that pnode->GetLocalServices() is a reflection of the local
10961096
// services we were offering when the CNode object was created for this
10971097
// peer.
10981098
uint64_t my_services{pnode.GetLocalServices()};
1099+
const int64_t nTime{count_seconds(GetTime<std::chrono::seconds>())};
10991100
uint64_t nonce = pnode.GetLocalNonce();
11001101
const int nNodeStartingHeight{m_best_height};
11011102
NodeId nodeid = pnode.GetId();
@@ -1167,7 +1168,7 @@ void PeerManagerImpl::InitializeNode(CNode *pnode)
11671168
m_peer_map.emplace_hint(m_peer_map.end(), nodeid, std::move(peer));
11681169
}
11691170
if (!pnode->IsInboundConn()) {
1170-
PushNodeVersion(*pnode, GetTime());
1171+
PushNodeVersion(*pnode);
11711172
}
11721173
}
11731174

@@ -2599,7 +2600,9 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
25992600

26002601
// Inbound peers send us their version message when they connect.
26012602
// We send our version message in response.
2602-
if (pfrom.IsInboundConn()) PushNodeVersion(pfrom, GetAdjustedTime());
2603+
if (pfrom.IsInboundConn()) {
2604+
PushNodeVersion(pfrom);
2605+
}
26032606

26042607
// Change version
26052608
const int greatest_common_version = std::min(nVersion, PROTOCOL_VERSION);

0 commit comments

Comments
 (0)