diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-04-15 08:58:50 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2016-04-15 08:59:40 +0200 |
commit | efc059322ceffbc7485001bebc88dd2fdcb60c4d (patch) | |
tree | a40c2b481dc74808f0d176d98efefd75db15bd70 /src | |
parent | bbd210d9275ac892184e1dd5dc2de09d3cd9f28e (diff) | |
parent | 38c310299cfef419d42744362b90c1700b598953 (diff) |
Merge #7877: Change mapRelay to store CTransactions
38c3102 Change mapRelay to store CTransactions (Pieter Wuille)
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 7 | ||||
-rw-r--r-- | src/net.cpp | 17 | ||||
-rw-r--r-- | src/net.h | 5 |
3 files changed, 8 insertions, 21 deletions
diff --git a/src/main.cpp b/src/main.cpp index 63516adae3..ed9ee16545 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4458,7 +4458,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam bool pushed = false; { LOCK(cs_mapRelay); - map<CInv, CDataStream>::iterator mi = mapRelay.find(inv); + map<uint256, CTransaction>::iterator mi = mapRelay.find(inv.hash); if (mi != mapRelay.end()) { pfrom->PushMessage(inv.GetCommand(), (*mi).second); pushed = true; @@ -4467,10 +4467,7 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam if (!pushed && inv.type == MSG_TX) { CTransaction tx; if (mempool.lookup(inv.hash, tx)) { - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss.reserve(1000); - ss << tx; - pfrom->PushMessage(NetMsgType::TX, ss); + pfrom->PushMessage(NetMsgType::TX, tx); pushed = true; } } diff --git a/src/net.cpp b/src/net.cpp index 3bf8c165dc..e64cb4ef90 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -90,8 +90,8 @@ std::string strSubVersion; vector<CNode*> vNodes; CCriticalSection cs_vNodes; -map<CInv, CDataStream> mapRelay; -deque<pair<int64_t, CInv> > vRelayExpiration; +map<uint256, CTransaction> mapRelay; +deque<pair<int64_t, uint256> > vRelayExpiration; CCriticalSection cs_mapRelay; limitedmap<uint256, int64_t> mapAlreadyAskedFor(MAX_INV_SZ); @@ -2055,14 +2055,6 @@ instance_of_cnetcleanup; void RelayTransaction(const CTransaction& tx, CFeeRate feerate) { - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss.reserve(10000); - ss << tx; - RelayTransaction(tx, feerate, ss); -} - -void RelayTransaction(const CTransaction& tx, CFeeRate feerate, const CDataStream& ss) -{ CInv inv(MSG_TX, tx.GetHash()); { LOCK(cs_mapRelay); @@ -2073,9 +2065,8 @@ void RelayTransaction(const CTransaction& tx, CFeeRate feerate, const CDataStrea 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)); + mapRelay.insert(std::make_pair(inv.hash, tx)); + vRelayExpiration.push_back(std::make_pair(GetTime() + 15 * 60, inv.hash)); } LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) @@ -161,8 +161,8 @@ extern int nMaxConnections; extern std::vector<CNode*> vNodes; extern CCriticalSection cs_vNodes; -extern std::map<CInv, CDataStream> mapRelay; -extern std::deque<std::pair<int64_t, CInv> > vRelayExpiration; +extern std::map<uint256, CTransaction> mapRelay; +extern std::deque<std::pair<int64_t, uint256> > vRelayExpiration; extern CCriticalSection cs_mapRelay; extern limitedmap<uint256, int64_t> mapAlreadyAskedFor; @@ -773,7 +773,6 @@ public: class CTransaction; void RelayTransaction(const CTransaction& tx, CFeeRate feerate); -void RelayTransaction(const CTransaction& tx, CFeeRate feerate, const CDataStream& ss); /** Access to the (IP) address database (peers.dat) */ class CAddrDB |