diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2015-04-08 11:20:00 -0700 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-12-14 13:43:53 +0100 |
commit | 10b88be79856ee7ee66f69705c16b335941e396e (patch) | |
tree | 29766c79315ae9c569321e2ee607107be948dd5d /src/net.h | |
parent | 06c6a584635bb42c511baf505cebd7cdf77b89e9 (diff) | |
download | bitcoin-10b88be79856ee7ee66f69705c16b335941e396e.tar.xz |
Replace trickle nodes with per-node/message Poisson delays
We used to have a trickle node, a node which was chosen in each iteration of
the send loop that was privileged and allowed to send out queued up non-time
critical messages. Since the removal of the fixed sleeps in the network code,
this resulted in fast and attackable treatment of such broadcasts.
This pull request changes the 3 remaining trickle use cases by random delays:
* Local address broadcast (while also removing the the wiping of the seen filter)
* Address relay
* Inv relay (for transactions; blocks are always relayed immediately)
The code is based on older commits by Patrick Strateman.
Github-Pull: #7125
Rebased-From: 5400ef6bcb9d243b2b21697775aa6491115420f3
Diffstat (limited to 'src/net.h')
-rw-r--r-- | src/net.h | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -113,7 +113,7 @@ struct CNodeSignals { boost::signals2::signal<int ()> GetHeight; boost::signals2::signal<bool (CNode*), CombinerAll> ProcessMessages; - boost::signals2::signal<bool (CNode*, bool), CombinerAll> SendMessages; + boost::signals2::signal<bool (CNode*), CombinerAll> SendMessages; boost::signals2::signal<void (NodeId, const CNode*)> InitializeNode; boost::signals2::signal<void (NodeId)> FinalizeNode; }; @@ -385,6 +385,8 @@ public: CRollingBloomFilter addrKnown; bool fGetAddr; std::set<uint256> setKnown; + int64_t nNextAddrSend; + int64_t nNextLocalAddrSend; // inventory based relay CRollingBloomFilter filterInventoryKnown; @@ -392,6 +394,7 @@ public: CCriticalSection cs_inventory; std::set<uint256> setAskFor; std::multimap<int64_t, CInv> mapAskFor; + int64_t nNextInvSend; // Used for headers announcements - unfiltered blocks to relay // Also protected by cs_inventory std::vector<uint256> vBlockHashesToAnnounce; @@ -785,4 +788,7 @@ public: void DumpBanlist(); +/** Return a timestamp in the future (in microseconds) for exponentially distributed events. */ +int64_t PoissonNextSend(int64_t nNow, int average_interval_seconds); + #endif // BITCOIN_NET_H |