mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
net: Make addr relay mockable
This commit is contained in:
parent
210b533a11
commit
fa47a0b003
2 changed files with 10 additions and 10 deletions
|
@ -797,8 +797,8 @@ public:
|
|||
std::vector<CAddress> vAddrToSend;
|
||||
const std::unique_ptr<CRollingBloomFilter> m_addr_known;
|
||||
bool fGetAddr{false};
|
||||
int64_t nNextAddrSend GUARDED_BY(cs_sendProcessing){0};
|
||||
int64_t nNextLocalAddrSend GUARDED_BY(cs_sendProcessing){0};
|
||||
std::chrono::microseconds m_next_addr_send GUARDED_BY(cs_sendProcessing){0};
|
||||
std::chrono::microseconds m_next_local_addr_send GUARDED_BY(cs_sendProcessing){0};
|
||||
|
||||
bool IsAddrRelayPeer() const { return m_addr_known != nullptr; }
|
||||
|
||||
|
|
|
@ -97,10 +97,10 @@ void EraseOrphansFor(NodeId peer);
|
|||
/** Increase a node's misbehavior score. */
|
||||
void Misbehaving(NodeId nodeid, int howmuch, const std::string& message="") EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
|
||||
/** Average delay between local address broadcasts in seconds. */
|
||||
static constexpr unsigned int AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL = 24 * 60 * 60;
|
||||
/** Average delay between peer address broadcasts in seconds. */
|
||||
static const unsigned int AVG_ADDRESS_BROADCAST_INTERVAL = 30;
|
||||
/** Average delay between local address broadcasts */
|
||||
static constexpr std::chrono::hours AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL{24};
|
||||
/** Average delay between peer address broadcasts */
|
||||
static constexpr std::chrono::seconds AVG_ADDRESS_BROADCAST_INTERVAL{30};
|
||||
/** Average delay between trickled inventory transmissions in seconds.
|
||||
* Blocks and whitelisted receivers bypass this, outbound peers get half this delay. */
|
||||
static const unsigned int INVENTORY_BROADCAST_INTERVAL = 5;
|
||||
|
@ -3583,16 +3583,16 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
|
|||
int64_t nNow = GetTimeMicros();
|
||||
auto current_time = GetTime<std::chrono::microseconds>();
|
||||
|
||||
if (pto->IsAddrRelayPeer() && !::ChainstateActive().IsInitialBlockDownload() && pto->nNextLocalAddrSend < nNow) {
|
||||
if (pto->IsAddrRelayPeer() && !::ChainstateActive().IsInitialBlockDownload() && pto->m_next_local_addr_send < current_time) {
|
||||
AdvertiseLocal(pto);
|
||||
pto->nNextLocalAddrSend = PoissonNextSend(nNow, AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL);
|
||||
pto->m_next_local_addr_send = PoissonNextSend(current_time, AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL);
|
||||
}
|
||||
|
||||
//
|
||||
// Message: addr
|
||||
//
|
||||
if (pto->IsAddrRelayPeer() && pto->nNextAddrSend < nNow) {
|
||||
pto->nNextAddrSend = PoissonNextSend(nNow, AVG_ADDRESS_BROADCAST_INTERVAL);
|
||||
if (pto->IsAddrRelayPeer() && pto->m_next_addr_send < current_time) {
|
||||
pto->m_next_addr_send = PoissonNextSend(current_time, AVG_ADDRESS_BROADCAST_INTERVAL);
|
||||
std::vector<CAddress> vAddr;
|
||||
vAddr.reserve(pto->vAddrToSend.size());
|
||||
assert(pto->m_addr_known);
|
||||
|
|
Loading…
Add table
Reference in a new issue