diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2012-06-27 07:49:28 -0700 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2012-06-27 07:49:28 -0700 |
commit | 6c88568fef4d4386e35bc474b1879006f0010ab2 (patch) | |
tree | dc5ea26e144fa17900d70405fd2b6b08978e3b89 /src/main.cpp | |
parent | 4a52c187d342c27741d23b9536cb1a108f5a6fcb (diff) | |
parent | 9d6cd04b3b73e5de10d6891dcdf151633e582de0 (diff) | |
download | bitcoin-6c88568fef4d4386e35bc474b1879006f0010ab2.tar.xz |
Merge pull request #973 from TheBlueMatt/diffsendbuffer
Stop processing messages on full send buffer and dont disconnect.
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/main.cpp b/src/main.cpp index b46866221f..f1398e9818 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2632,25 +2632,21 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) // Send the rest of the chain if (pindex) pindex = pindex->pnext; - int nLimit = 500 + locator.GetDistanceBack(); - unsigned int nBytes = 0; + int nLimit = 500; printf("getblocks %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().substr(0,20).c_str(), nLimit); for (; pindex; pindex = pindex->pnext) { if (pindex->GetBlockHash() == hashStop) { - printf(" getblocks stopping at %d %s (%u bytes)\n", pindex->nHeight, pindex->GetBlockHash().ToString().substr(0,20).c_str(), nBytes); + printf(" getblocks stopping at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString().substr(0,20).c_str()); break; } pfrom->PushInventory(CInv(MSG_BLOCK, pindex->GetBlockHash())); - CBlock block; - block.ReadFromDisk(pindex, true); - nBytes += block.GetSerializeSize(SER_NETWORK, PROTOCOL_VERSION); - if (--nLimit <= 0 || nBytes >= SendBufferSize()/2) + if (--nLimit <= 0) { // When this block is requested, we'll send an inv that'll make them // getblocks the next batch of inventory. - printf(" getblocks stopping at limit %d %s (%u bytes)\n", pindex->nHeight, pindex->GetBlockHash().ToString().substr(0,20).c_str(), nBytes); + printf(" getblocks stopping at limit %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString().substr(0,20).c_str()); pfrom->hashContinue = pindex->GetBlockHash(); break; } @@ -2910,6 +2906,10 @@ bool ProcessMessages(CNode* pfrom) loop { + // Don't bother if send buffer is too full to respond anyway + if (pfrom->vSend.size() >= SendBufferSize()) + break; + // Scan for message start CDataStream::iterator pstart = search(vRecv.begin(), vRecv.end(), BEGIN(pchMessageStart), END(pchMessageStart)); int nHeaderSize = vRecv.GetSerializeSize(CMessageHeader()); |