aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h61
1 files changed, 15 insertions, 46 deletions
diff --git a/src/net.h b/src/net.h
index 44c80dac28..087b2dd6a2 100644
--- a/src/net.h
+++ b/src/net.h
@@ -19,6 +19,7 @@
#include "protocol.h"
#include "addrman.h"
#include "hash.h"
+#include "bloom.h"
class CNode;
class CBlockIndex;
@@ -151,7 +152,14 @@ public:
bool fNetworkNode;
bool fSuccessfullyConnected;
bool fDisconnect;
+ // We use fRelayTxes for two purposes -
+ // a) it allows us to not relay tx invs before receiving the peer's version message
+ // b) the peer may tell us in their version message that we should not relay tx invs
+ // until they have initialized their bloom filter.
+ bool fRelayTxes;
CSemaphoreGrant grantOutbound;
+ CCriticalSection cs_filter;
+ CBloomFilter* pfilter;
protected:
int nRefCount;
@@ -208,7 +216,9 @@ public:
nStartingHeight = -1;
fGetAddr = false;
nMisbehavior = 0;
+ fRelayTxes = false;
setInventoryKnown.max_size(SendBufferSize() / 1000);
+ pfilter = NULL;
// Be shy and don't send version until we hear
if (!fInbound)
@@ -222,6 +232,8 @@ public:
closesocket(hSocket);
hSocket = INVALID_SOCKET;
}
+ if (pfilter)
+ delete pfilter;
}
private:
@@ -556,51 +568,8 @@ public:
-
-
-
-
-
-
-
-inline void RelayInventory(const CInv& inv)
-{
- // Put on lists to offer to the other nodes
- {
- LOCK(cs_vNodes);
- BOOST_FOREACH(CNode* pnode, vNodes)
- pnode->PushInventory(inv);
- }
-}
-
-template<typename T>
-void RelayMessage(const CInv& inv, const T& a)
-{
- CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
- ss.reserve(10000);
- ss << a;
- RelayMessage(inv, ss);
-}
-
-template<>
-inline void RelayMessage<>(const CInv& inv, const CDataStream& ss)
-{
- {
- LOCK(cs_mapRelay);
- // Expire old relay messages
- while (!vRelayExpiration.empty() && vRelayExpiration.front().first < GetTime())
- {
- mapRelay.erase(vRelayExpiration.front().second);
- vRelayExpiration.pop_front();
- }
-
- // Save original serialized message so newer versions are preserved
- mapRelay.insert(std::make_pair(inv, ss));
- vRelayExpiration.push_back(std::make_pair(GetTime() + 15 * 60, inv));
- }
-
- RelayInventory(inv);
-}
-
+class CTransaction;
+void RelayTransaction(const CTransaction& tx, const uint256& hash);
+void RelayTransaction(const CTransaction& tx, const uint256& hash, const CDataStream& ss);
#endif