[net processing] Move PoissonNextSendInbound to PeerManager

This commit is contained in:
John Newbery
2021-12-14 10:35:37 +00:00
committed by Martin Zumsande
parent bb060746df
commit ea99f5d01e
4 changed files with 24 additions and 26 deletions

View File

@ -3058,17 +3058,6 @@ bool CConnman::ForNode(NodeId id, std::function<bool(CNode* pnode)> func)
return found != nullptr && NodeFullyConnected(found) && func(found);
}
std::chrono::microseconds CConnman::PoissonNextSendInbound(std::chrono::microseconds now, std::chrono::seconds average_interval)
{
if (m_next_send_inv_to_incoming.load() < now) {
// If this function were called from multiple threads simultaneously
// it would possible that both update the next send variable, and return a different result to their caller.
// This is not possible in practice as only the net processing thread invokes this function.
m_next_send_inv_to_incoming = GetExponentialRand(now, average_interval);
}
return m_next_send_inv_to_incoming;
}
CSipHasher CConnman::GetDeterministicRandomizer(uint64_t id) const
{
return CSipHasher(nSeed0, nSeed1).Write(id);