Skip to content

Commit

Permalink
merge bitcoin#23695: Always serialize local timestamp for version msg
Browse files Browse the repository at this point in the history
  • Loading branch information
kwvg committed Apr 26, 2024
1 parent d936c28 commit a9114f1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/net_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ class PeerManagerImpl final : public PeerManager
void SendBlockTransactions(CNode& pfrom, const CBlock& block, const BlockTransactionsRequest& req);

/** 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.
Expand Down Expand Up @@ -1148,14 +1148,15 @@ void PeerManagerImpl::FindNextBlocksToDownload(NodeId nodeid, unsigned int count
}
} // namespace

void PeerManagerImpl::PushNodeVersion(CNode& pnode, int64_t nTime)
void PeerManagerImpl::PushNodeVersion(CNode& pnode)
{
const auto& params = Params();

// Note that pnode->GetLocalServices() is a reflection of the local
// services we were offering when the CNode object was created for this
// peer.
ServiceFlags nLocalNodeServices = 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();
Expand Down Expand Up @@ -1348,7 +1349,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);
}
}

Expand Down Expand Up @@ -3220,8 +3221,9 @@ void PeerManagerImpl::ProcessMessage(
}

// Be shy and don't send version until we hear
if (pfrom.IsInboundConn())
PushNodeVersion(pfrom, GetAdjustedTime());
if (pfrom.IsInboundConn()) {
PushNodeVersion(pfrom);
}

if (Params().NetworkIDString() == CBaseChainParams::DEVNET) {
if (cleanSubVer.find(strprintf("devnet.%s", gArgs.GetDevNetName())) == std::string::npos) {
Expand Down

0 comments on commit a9114f1

Please sign in to comment.