From 269d9c6492dc275650d2137d53f4afdca88e3216 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 13 Aug 2012 05:26:30 +0200 Subject: Replace RelayMessage with RelayTransaction. --- src/net.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'src/net.cpp') diff --git a/src/net.cpp b/src/net.cpp index 7867c85b7..aafc7206c 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -9,6 +9,7 @@ #include "init.h" #include "addrman.h" #include "ui_interface.h" +#include "script.h" #ifdef WIN32 #include @@ -1996,3 +1997,46 @@ public: } } instance_of_cnetcleanup; + + + + + + + +void RelayTransaction(const CTransaction& tx, const uint256& hash) +{ + CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); + ss.reserve(10000); + ss << tx; + RelayTransaction(tx, hash, ss); +} + +void RelayTransaction(const CTransaction& tx, const uint256& hash, const CDataStream& ss) +{ + CInv inv(MSG_TX, hash); + { + 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)); + } + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + { + LOCK(pnode->cs_filter); + if (pnode->pfilter) + { + if (pnode->pfilter->IsTransactionRelevantToFilter(tx, hash)) + pnode->PushInventory(inv); + } else + pnode->PushInventory(inv); + } +} -- cgit v1.2.3 From d3b26f7077f58ebfcfccc5f0b16f8c29be5dc6b5 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sat, 18 Aug 2012 23:38:28 -0400 Subject: Automatically add any matching outputs to a filter during matching. --- src/net.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/net.cpp') diff --git a/src/net.cpp b/src/net.cpp index aafc7206c..e88efcd19 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2034,7 +2034,7 @@ void RelayTransaction(const CTransaction& tx, const uint256& hash, const CDataSt LOCK(pnode->cs_filter); if (pnode->pfilter) { - if (pnode->pfilter->IsTransactionRelevantToFilter(tx, hash)) + if (pnode->pfilter->IsRelevantAndUpdate(tx, hash)) pnode->PushInventory(inv); } else pnode->PushInventory(inv); -- cgit v1.2.3 From 4c8fc1a5885634c3b463d5d44337d81cc5b1456b Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 20 Aug 2012 21:10:25 -0400 Subject: Let a node opt out of tx invs before we get a their bloom filter Note that the default value for fRelayTxes is false, meaning we now no longer relay tx inv messages before receiving the remote peer's version message. --- src/net.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/net.cpp') diff --git a/src/net.cpp b/src/net.cpp index e88efcd19..319739429 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2031,6 +2031,8 @@ void RelayTransaction(const CTransaction& tx, const uint256& hash, const CDataSt LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) { + if(!pnode->fRelayTxes) + continue; LOCK(pnode->cs_filter); if (pnode->pfilter) { -- cgit v1.2.3