diff options
| author | Jeff Garzik <[email protected]> | 2012-08-20 07:21:34 -0700 |
|---|---|---|
| committer | Jeff Garzik <[email protected]> | 2012-08-20 07:21:34 -0700 |
| commit | b3a570d158224e6ae6ee72fadd2bf947d7656f23 (patch) | |
| tree | 3f8ff0549b3582773f76017cd5583ab8d35549a4 /src/main.cpp | |
| parent | Merge pull request #1686 from Diapolo/fix_comment (diff) | |
| parent | Add 'mempool' P2P command, and extend 'getdata' behavior (diff) | |
| download | discoin-b3a570d158224e6ae6ee72fadd2bf947d7656f23.tar.xz discoin-b3a570d158224e6ae6ee72fadd2bf947d7656f23.zip | |
Merge pull request #1641 from jgarzik/mempool
Add 'mempool' P2P command, and extend 'getdata' behavior
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp index 550c10c37..846802713 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2583,7 +2583,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) { vector<CInv> vInv; vRecv >> vInv; - if (vInv.size() > 50000) + if (vInv.size() > MAX_INV_SZ) { pfrom->Misbehaving(20); return error("message inv size() = %d", vInv.size()); @@ -2634,7 +2634,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) { vector<CInv> vInv; vRecv >> vInv; - if (vInv.size() > 50000) + if (vInv.size() > MAX_INV_SZ) { pfrom->Misbehaving(20); return error("message getdata size() = %d", vInv.size()); @@ -2676,11 +2676,24 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) else if (inv.IsKnownType()) { // Send stream from relay memory + bool pushed = false; { LOCK(cs_mapRelay); map<CInv, CDataStream>::iterator mi = mapRelay.find(inv); - if (mi != mapRelay.end()) + if (mi != mapRelay.end()) { pfrom->PushMessage(inv.GetCommand(), (*mi).second); + pushed = true; + } + } + if (!pushed && inv.type == MSG_TX) { + LOCK(mempool.cs); + if (mempool.exists(inv.hash)) { + CTransaction tx = mempool.lookup(inv.hash); + CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); + ss.reserve(1000); + ss << tx; + pfrom->PushMessage("tx", ss); + } } } @@ -2855,6 +2868,22 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) } + else if (strCommand == "mempool") + { + std::vector<uint256> vtxid; + mempool.queryHashes(vtxid); + vector<CInv> vInv; + for (unsigned int i = 0; i < vtxid.size(); i++) { + CInv inv(MSG_TX, vtxid[i]); + vInv.push_back(inv); + if (i == (MAX_INV_SZ - 1)) + break; + } + if (vInv.size() > 0) + pfrom->PushMessage("inv", vInv); + } + + else if (strCommand == "checkorder") { uint256 hashReply; |