Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 1,590 Lines • ▼ Show 20 Lines | |||||
static void RelayAddress(const CAddress &addr, bool fReachable, | static void RelayAddress(const CAddress &addr, bool fReachable, | ||||
CConnman *connman) { | CConnman *connman) { | ||||
// Limited relaying of addresses outside our network(s) | // Limited relaying of addresses outside our network(s) | ||||
unsigned int nRelayNodes = fReachable ? 2 : 1; | unsigned int nRelayNodes = fReachable ? 2 : 1; | ||||
// Relay to a limited number of other nodes. | // Relay to a limited number of other nodes. | ||||
// Use deterministic randomness to send to the same nodes for 24 hours at a | // Use deterministic randomness to send to the same nodes for 24 hours at a | ||||
// time so the addrKnowns of the chosen nodes prevent repeats. | // time so the m_addr_knowns of the chosen nodes prevent repeats | ||||
uint64_t hashAddr = addr.GetHash(); | uint64_t hashAddr = addr.GetHash(); | ||||
const CSipHasher hasher = | const CSipHasher hasher = | ||||
connman->GetDeterministicRandomizer(RANDOMIZER_ID_ADDRESS_RELAY) | connman->GetDeterministicRandomizer(RANDOMIZER_ID_ADDRESS_RELAY) | ||||
.Write(hashAddr << 32) | .Write(hashAddr << 32) | ||||
.Write((GetTime() + hashAddr) / (24 * 60 * 60)); | .Write((GetTime() + hashAddr) / (24 * 60 * 60)); | ||||
FastRandomContext insecure_rand; | FastRandomContext insecure_rand; | ||||
std::array<std::pair<uint64_t, CNode *>, 2> best{ | std::array<std::pair<uint64_t, CNode *>, 2> best{ | ||||
▲ Show 20 Lines • Show All 2,744 Lines • ▼ Show 20 Lines | bool PeerLogicValidation::SendMessages(const Config &config, CNode *pto, | ||||
// Message: addr | // Message: addr | ||||
// | // | ||||
if (pto->IsAddrRelayPeer() && pto->nNextAddrSend < nNow) { | if (pto->IsAddrRelayPeer() && pto->nNextAddrSend < nNow) { | ||||
pto->nNextAddrSend = | pto->nNextAddrSend = | ||||
PoissonNextSend(nNow, AVG_ADDRESS_BROADCAST_INTERVAL); | PoissonNextSend(nNow, AVG_ADDRESS_BROADCAST_INTERVAL); | ||||
std::vector<CAddress> vAddr; | std::vector<CAddress> vAddr; | ||||
vAddr.reserve(pto->vAddrToSend.size()); | vAddr.reserve(pto->vAddrToSend.size()); | ||||
for (const CAddress &addr : pto->vAddrToSend) { | for (const CAddress &addr : pto->vAddrToSend) { | ||||
if (!pto->addrKnown.contains(addr.GetKey())) { | if (!pto->m_addr_known->contains(addr.GetKey())) { | ||||
pto->addrKnown.insert(addr.GetKey()); | pto->m_addr_known->insert(addr.GetKey()); | ||||
vAddr.push_back(addr); | vAddr.push_back(addr); | ||||
// receiver rejects addr messages larger than 1000 | // receiver rejects addr messages larger than 1000 | ||||
if (vAddr.size() >= 1000) { | if (vAddr.size() >= 1000) { | ||||
connman->PushMessage( | connman->PushMessage( | ||||
pto, msgMaker.Make(NetMsgType::ADDR, vAddr)); | pto, msgMaker.Make(NetMsgType::ADDR, vAddr)); | ||||
vAddr.clear(); | vAddr.clear(); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 630 Lines • Show Last 20 Lines |