MCPcopy Create free account
hub / github.com/ElementsProject/elements / AddTxAnnouncement

Method AddTxAnnouncement

src/net_processing.cpp:1162–1187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1160}
1161
1162void PeerManagerImpl::AddTxAnnouncement(const CNode& node, const GenTxid& gtxid, std::chrono::microseconds current_time)
1163{
1164 AssertLockHeld(::cs_main); // For m_txrequest
1165 NodeId nodeid = node.GetId();
1166 if (!node.HasPermission(NetPermissionFlags::Relay) && m_txrequest.Count(nodeid) >= MAX_PEER_TX_ANNOUNCEMENTS) {
1167 // Too many queued announcements from this peer
1168 return;
1169 }
1170 const CNodeState* state = State(nodeid);
1171
1172 // Decide the TxRequestTracker parameters for this announcement:
1173 // - "preferred": if fPreferredDownload is set (= outbound, or NetPermissionFlags::NoBan permission)
1174 // - "reqtime": current time plus delays for:
1175 // - NONPREF_PEER_TX_DELAY for announcements from non-preferred connections
1176 // - TXID_RELAY_DELAY for txid announcements while wtxid peers are available
1177 // - OVERLOADED_PEER_TX_DELAY for announcements from peers which have at least
1178 // MAX_PEER_TX_REQUEST_IN_FLIGHT requests in flight (and don't have NetPermissionFlags::Relay).
1179 auto delay{0us};
1180 const bool preferred = state->fPreferredDownload;
1181 if (!preferred) delay += NONPREF_PEER_TX_DELAY;
1182 if (!gtxid.IsWtxid() && m_wtxid_relay_peers > 0) delay += TXID_RELAY_DELAY;
1183 const bool overloaded = !node.HasPermission(NetPermissionFlags::Relay) &&
1184 m_txrequest.CountInFlight(nodeid) >= MAX_PEER_TX_REQUEST_IN_FLIGHT;
1185 if (overloaded) delay += OVERLOADED_PEER_TX_DELAY;
1186 m_txrequest.ReceivedInv(nodeid, gtxid, preferred, current_time + delay);
1187}
1188
1189// This function is used for testing the stale tip eviction logic, see
1190// denialofservice_tests.cpp

Callers

nothing calls this directly

Calls 7

GetIdMethod · 0.80
HasPermissionMethod · 0.80
IsWtxidMethod · 0.80
StateEnum · 0.70
CountMethod · 0.45
CountInFlightMethod · 0.45
ReceivedInvMethod · 0.45

Tested by

no test coverage detected