MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / PushNodeVersion

Method PushNodeVersion

src/net_processing.cpp:1559–1607  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1557} // namespace
1558
1559void PeerManagerImpl::PushNodeVersion(CNode& pnode, const Peer& peer)
1560{
1561 uint64_t my_services;
1562 int64_t my_time;
1563 uint64_t your_services;
1564 CService your_addr;
1565 std::string my_user_agent;
1566 int my_height;
1567 bool my_tx_relay;
1568 if (pnode.IsPrivateBroadcastConn()) {
1569 my_services = NODE_NONE;
1570 my_time = 0;
1571 your_services = NODE_NONE;
1572 your_addr = CService{};
1573 my_user_agent = "/pynode:0.0.1/"; // Use a constant other than the default (or user-configured). See https://github.com/bitcoin/bitcoin/pull/27509#discussion_r1214671917
1574 my_height = 0;
1575 my_tx_relay = false;
1576 } else {
1577 const CAddress& addr{pnode.addr};
1578 my_services = peer.m_our_services;
1579 my_time = TicksSinceEpoch<std::chrono::seconds>(NodeClock::now());
1580 your_services = addr.nServices;
1581 your_addr = addr.IsRoutable() && !IsProxy(addr) && addr.IsAddrV1Compatible() ? CService{addr} : CService{};
1582 my_user_agent = strSubVersion;
1583 my_height = m_best_height;
1584 my_tx_relay = !RejectIncomingTxs(pnode);
1585 }
1586
1587 MakeAndPushMessage(
1588 pnode,
1589 NetMsgType::VERSION,
1590 pnode.AdvertisedVersion(),
1591 my_services,
1592 my_time,
1593 // your_services + CNetAddr::V1(your_addr) is the pre-version-31402 serialization of your_addr (without nTime)
1594 your_services, CNetAddr::V1(your_addr),
1595 // same, for a dummy address
1596 my_services, CNetAddr::V1(CService{}),
1597 pnode.GetLocalNonce(),
1598 my_user_agent,
1599 my_height,
1600 my_tx_relay);
1601
1602 LogDebug(
1603 BCLog::NET, "send version message: version=%d, blocks=%d%s, txrelay=%d, peer=%d\n",
1604 pnode.AdvertisedVersion(), my_height,
1605 fLogIPs ? strprintf(", them=%s", your_addr.ToStringAddrPort()) : "",
1606 my_tx_relay, pnode.GetId());
1607}
1608
1609void PeerManagerImpl::UpdateLastBlockAnnounceTime(NodeId node, int64_t time_in_seconds)
1610{

Callers

nothing calls this directly

Calls 8

IsProxyFunction · 0.85
IsRoutableMethod · 0.80
IsAddrV1CompatibleMethod · 0.80
AdvertisedVersionMethod · 0.80
GetLocalNonceMethod · 0.80
ToStringAddrPortMethod · 0.80
GetIdMethod · 0.80

Tested by

no test coverage detected