Merge branch '0.4.x' into 0.5.x
authorLuke Dashjr <luke-jr+git@utopios.org>
Mon, 7 May 2012 02:46:14 +0000 (02:46 +0000)
committerLuke Dashjr <luke-jr+git@utopios.org>
Mon, 7 May 2012 02:46:14 +0000 (02:46 +0000)
1  2 
src/main.cpp

diff --cc src/main.cpp
@@@ -2208,14 -2175,19 +2208,22 @@@ bool static ProcessMessage(CNode* pfrom
          vector<CInv> vInv;
          vRecv >> vInv;
          if (vInv.size() > 50000)
 +        {
 +            pfrom->Misbehaving(20);
              return error("message inv size() = %d", vInv.size());
 +        }
  
+         // find last block in inv vector
+         unsigned int nLastBlock = (unsigned int)(-1);
+         for (unsigned int nInv = 0; nInv < vInv.size(); nInv++) {
+             if (vInv[vInv.size() - 1 - nInv].type == MSG_BLOCK)
+                 nLastBlock = vInv.size() - 1 - nInv;
+         }
          CTxDB txdb("r");
-         BOOST_FOREACH(const CInv& inv, vInv)
+         for (int nInv = 0; nInv < vInv.size(); nInv++)
          {
+             const CInv &inv = vInv[nInv];
              if (fShutdown)
                  return true;
              pfrom->AddInventoryKnown(inv);