Merge #20561: p2p: periodically clear m_addr_known

65273fa0e74f0c11dfbf0645dd962bdc779ea558 Clear m_addr_known before our periodic self-advertisement (Suhas Daftuar)

Pull request description:

  We use a rolling bloom filter to track which addresses we've previously sent a peer, but after #7125 we no longer clear it every day before our own announcement.  This looks to me like an oversight which has the effect of reducing the frequency with which we actually self-announce our own address, so this reintroduces resetting that filter.

ACKs for top commit:
  naumenkogs:
    ACK 65273fa0e74f0c11dfbf0645dd962bdc779ea558
  laanwj:
    Code review ACK 65273fa0e74f0c11dfbf0645dd962bdc779ea558
  sipa:
    utACK 65273fa0e74f0c11dfbf0645dd962bdc779ea558

Tree-SHA512: 602c155fb6d2249b054fcb6f1c0dd17143605ceb87132286bbd90babf26d258ff6c41f9925482c17e2be41805d33f9b83926cb447f394969ffecd4bccfa0a64f
This commit is contained in:
Wladimir J. van der Laan 2020-12-07 23:57:49 +01:00 committed by pasta
parent 6abbbe12c7
commit 5e23f3506c
No known key found for this signature in database
GPG Key ID: 52527BEDABE87984

View File

@ -4757,6 +4757,15 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
if (fListen && pto->RelayAddrsWithConn() &&
!m_chainman.ActiveChainstate().IsInitialBlockDownload() &&
pto->m_next_local_addr_send < current_time) {
// If we've sent before, clear the bloom filter for the peer, so that our
// self-announcement will actually go out.
// This might be unnecessary if the bloom filter has already rolled
// over since our last self-announcement, but there is only a small
// bandwidth cost that we can incur by doing this (which happens
// once a day on average).
if (pto->m_next_local_addr_send != std::chrono::microseconds::zero()) {
pto->m_addr_known->reset();
}
if (std::optional<CAddress> local_addr = GetLocalAddrForPeer(pto)) {
FastRandomContext insecure_rand;
pto->PushAddress(*local_addr, insecure_rand);