aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h63
1 files changed, 16 insertions, 47 deletions
diff --git a/src/net.h b/src/net.h
index e37953772e..99f41161b1 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;
@@ -82,11 +83,11 @@ enum threadId
THREAD_DUMPADDRESS,
THREAD_RPCHANDLER,
THREAD_IMPORT,
+ THREAD_SCRIPTCHECK,
THREAD_MAX
};
-extern bool fClient;
extern bool fDiscover;
extern bool fUseUPnP;
extern uint64 nLocalServices;
@@ -152,7 +153,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;
@@ -209,7 +217,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)
@@ -223,6 +233,8 @@ public:
closesocket(hSocket);
hSocket = INVALID_SOCKET;
}
+ if (pfilter)
+ delete pfilter;
}
private:
@@ -557,51 +569,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