diff options
Diffstat (limited to 'src/net.h')
-rw-r--r-- | src/net.h | 20 |
1 files changed, 13 insertions, 7 deletions
@@ -1,5 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2009-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -9,7 +9,6 @@ #include "bloom.h" #include "compat.h" #include "limitedmap.h" -#include "mruset.h" #include "netbase.h" #include "protocol.h" #include "random.h" @@ -114,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; }; @@ -386,13 +385,16 @@ public: CRollingBloomFilter addrKnown; bool fGetAddr; std::set<uint256> setKnown; + int64_t nNextAddrSend; + int64_t nNextLocalAddrSend; // inventory based relay - mruset<CInv> setInventoryKnown; + CRollingBloomFilter filterInventoryKnown; std::vector<CInv> vInventoryToSend; 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; @@ -497,7 +499,7 @@ public: { { LOCK(cs_inventory); - setInventoryKnown.insert(inv); + filterInventoryKnown.insert(inv.hash); } } @@ -505,8 +507,9 @@ public: { { LOCK(cs_inventory); - if (!setInventoryKnown.count(inv)) - vInventoryToSend.push_back(inv); + if (inv.type == MSG_TX && filterInventoryKnown.contains(inv.hash)) + return; + vInventoryToSend.push_back(inv); } } @@ -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 |