Clear m_addr_known before our periodic self-advertisement

This behavior was apparently inadvertently broken in 5400ef6; without this
change our daily self-announcements frequently go unsent, because our
address is still in the peer's rolling bloom filter (for potentially many
days, depending on addr traffic).
This commit is contained in:
Suhas Daftuar 2020-12-03 10:03:53 -05:00
parent a0489f3472
commit 65273fa0e7

View file

@ -4074,6 +4074,15 @@ bool PeerManager::SendMessages(CNode* pto)
auto current_time = GetTime<std::chrono::microseconds>();
if (pto->RelayAddrsWithConn() && !::ChainstateActive().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();
}
AdvertiseLocal(pto);
pto->m_next_local_addr_send = PoissonNextSend(current_time, AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL);
}