@@ -97,10 +97,10 @@ void EraseOrphansFor(NodeId peer);
97
97
/* * Increase a node's misbehavior score. */
98
98
void Misbehaving (NodeId nodeid, int howmuch, const std::string& message=" " ) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
99
99
100
- /* * Average delay between local address broadcasts in seconds. */
101
- static constexpr unsigned int AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL = 24 * 60 * 60 ;
102
- /* * Average delay between peer address broadcasts in seconds. */
103
- static const unsigned int AVG_ADDRESS_BROADCAST_INTERVAL = 30 ;
100
+ /* * Average delay between local address broadcasts */
101
+ static constexpr std::chrono::hours AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL{ 24 } ;
102
+ /* * Average delay between peer address broadcasts */
103
+ static constexpr std::chrono::seconds AVG_ADDRESS_BROADCAST_INTERVAL{ 30 } ;
104
104
/* * Average delay between trickled inventory transmissions in seconds.
105
105
* Blocks and whitelisted receivers bypass this, outbound peers get half this delay. */
106
106
static const unsigned int INVENTORY_BROADCAST_INTERVAL = 5 ;
@@ -1365,15 +1365,15 @@ void RelayTransaction(const uint256& txid, const CConnman& connman)
1365
1365
});
1366
1366
}
1367
1367
1368
- static void RelayAddress (const CAddress& addr, bool fReachable , CConnman* connman)
1368
+ static void RelayAddress (const CAddress& addr, bool fReachable , const CConnman& connman)
1369
1369
{
1370
1370
unsigned int nRelayNodes = fReachable ? 2 : 1 ; // limited relaying of addresses outside our network(s)
1371
1371
1372
1372
// Relay to a limited number of other nodes
1373
1373
// Use deterministic randomness to send to the same nodes for 24 hours
1374
1374
// at a time so the m_addr_knowns of the chosen nodes prevent repeats
1375
1375
uint64_t hashAddr = addr.GetHash ();
1376
- const CSipHasher hasher = connman-> GetDeterministicRandomizer (RANDOMIZER_ID_ADDRESS_RELAY).Write (hashAddr << 32 ).Write ((GetTime () + hashAddr) / (24 * 60 * 60 ));
1376
+ const CSipHasher hasher = connman. GetDeterministicRandomizer (RANDOMIZER_ID_ADDRESS_RELAY).Write (hashAddr << 32 ).Write ((GetTime () + hashAddr) / (24 * 60 * 60 ));
1377
1377
FastRandomContext insecure_rand;
1378
1378
1379
1379
std::array<std::pair<uint64_t , CNode*>,2 > best{{{0 , nullptr }, {0 , nullptr }}};
@@ -1398,7 +1398,7 @@ static void RelayAddress(const CAddress& addr, bool fReachable, CConnman* connma
1398
1398
}
1399
1399
};
1400
1400
1401
- connman-> ForEachNodeThen (std::move (sortfunc), std::move (pushfunc));
1401
+ connman. ForEachNodeThen (std::move (sortfunc), std::move (pushfunc));
1402
1402
}
1403
1403
1404
1404
void static ProcessGetBlockData (CNode* pfrom, const CChainParams& chainparams, const CInv& inv, CConnman* connman)
@@ -2192,7 +2192,7 @@ bool ProcessMessage(CNode* pfrom, const std::string& msg_type, CDataStream& vRec
2192
2192
if (addr.nTime > nSince && !pfrom->fGetAddr && vAddr.size () <= 10 && addr.IsRoutable ())
2193
2193
{
2194
2194
// Relay to a limited number of other nodes
2195
- RelayAddress (addr, fReachable , connman);
2195
+ RelayAddress (addr, fReachable , * connman);
2196
2196
}
2197
2197
// Do not store addresses outside our network
2198
2198
if (fReachable )
@@ -3583,16 +3583,16 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
3583
3583
int64_t nNow = GetTimeMicros ();
3584
3584
auto current_time = GetTime<std::chrono::microseconds>();
3585
3585
3586
- if (pto->IsAddrRelayPeer () && !::ChainstateActive ().IsInitialBlockDownload () && pto->nNextLocalAddrSend < nNow ) {
3586
+ if (pto->IsAddrRelayPeer () && !::ChainstateActive ().IsInitialBlockDownload () && pto->m_next_local_addr_send < current_time ) {
3587
3587
AdvertiseLocal (pto);
3588
- pto->nNextLocalAddrSend = PoissonNextSend (nNow , AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL);
3588
+ pto->m_next_local_addr_send = PoissonNextSend (current_time , AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL);
3589
3589
}
3590
3590
3591
3591
//
3592
3592
// Message: addr
3593
3593
//
3594
- if (pto->IsAddrRelayPeer () && pto->nNextAddrSend < nNow ) {
3595
- pto->nNextAddrSend = PoissonNextSend (nNow , AVG_ADDRESS_BROADCAST_INTERVAL);
3594
+ if (pto->IsAddrRelayPeer () && pto->m_next_addr_send < current_time ) {
3595
+ pto->m_next_addr_send = PoissonNextSend (current_time , AVG_ADDRESS_BROADCAST_INTERVAL);
3596
3596
std::vector<CAddress> vAddr;
3597
3597
vAddr.reserve (pto->vAddrToSend .size ());
3598
3598
assert (pto->m_addr_known );
0 commit comments