aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2021-12-07 16:32:05 +0100
committerMarcoFalke <falke.marco@gmail.com>2021-12-14 18:04:48 +0100
commitfa1dc9b36a0ccf96cbaf106c060336d91b54579e (patch)
tree10987e7e09bef6c75195171fe9299a567d76f92a /src/net_processing.cpp
parent9635760ce85e01dbf21c93cc971515a2c4aead88 (diff)
p2p: Always serialize local timestamp for version msg
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r--src/net_processing.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 8c897b9a0b..9af05199bc 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -386,7 +386,7 @@ private:
EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
/** Send a version message to a peer */
- void PushNodeVersion(CNode& pnode, int64_t nTime);
+ void PushNodeVersion(CNode& pnode);
/** Send a ping message every PING_INTERVAL or if requested via RPC. May
* mark the peer to be disconnected if a ping has timed out.
@@ -1090,12 +1090,13 @@ void PeerManagerImpl::FindNextBlocksToDownload(NodeId nodeid, unsigned int count
} // namespace
-void PeerManagerImpl::PushNodeVersion(CNode& pnode, int64_t nTime)
+void PeerManagerImpl::PushNodeVersion(CNode& pnode)
{
// Note that pnode->GetLocalServices() is a reflection of the local
// services we were offering when the CNode object was created for this
// peer.
uint64_t my_services{pnode.GetLocalServices()};
+ const int64_t nTime{count_seconds(GetTime<std::chrono::seconds>())};
uint64_t nonce = pnode.GetLocalNonce();
const int nNodeStartingHeight{m_best_height};
NodeId nodeid = pnode.GetId();
@@ -1167,7 +1168,7 @@ void PeerManagerImpl::InitializeNode(CNode *pnode)
m_peer_map.emplace_hint(m_peer_map.end(), nodeid, std::move(peer));
}
if (!pnode->IsInboundConn()) {
- PushNodeVersion(*pnode, GetTime());
+ PushNodeVersion(*pnode);
}
}
@@ -2599,7 +2600,9 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
// Inbound peers send us their version message when they connect.
// We send our version message in response.
- if (pfrom.IsInboundConn()) PushNodeVersion(pfrom, GetAdjustedTime());
+ if (pfrom.IsInboundConn()) {
+ PushNodeVersion(pfrom);
+ }
// Change version
const int greatest_common_version = std::min(nVersion, PROTOCOL_VERSION);