aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorMatt Corallo <git@bluematt.me>2012-08-13 05:26:30 +0200
committerMatt Corallo <git@bluematt.me>2013-01-16 12:48:02 -0500
commit269d9c6492dc275650d2137d53f4afdca88e3216 (patch)
tree32ded97569c406479d8393eda9163f3ba488b7b9 /src/net.cpp
parent422d1225374e2d879dbd116151e0113aa7162500 (diff)
Replace RelayMessage with RelayTransaction.
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 7867c85b7f..aafc7206cd 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 <string.h>
@@ -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);
+ }
+}