ech pack stuff.

This commit is contained in:
JoelKatz
2013-04-22 11:09:07 -07:00
parent 94838b0db7
commit aeccecb578
7 changed files with 62 additions and 11 deletions

View File

@@ -1235,18 +1235,40 @@ void Peer::recvGetObjectByHash(const boost::shared_ptr<ripple::TMGetObjectByHash
}
else
{ // this is a reply
if (packet.type() == ripple::TMGetObjectByHash::otFETCH_PACK)
theApp->getOPs().gotFetchPack();
for (int i = 0; i < packet.objects_size(); ++i)
{
const ripple::TMIndexedObject& obj = packet.objects(i);
if (obj.has_hash() && (obj.hash().size() == (256/8)))
{
uint256 hash;
memcpy(hash.begin(), obj.hash().data(), 256 / 8);
uint32 pLSeq = 0;
bool pLDo = true;
boost::shared_ptr< std::vector<unsigned char> > data = boost::make_shared< std::vector<unsigned char> >
(obj.data().begin(), obj.data().end());
if (obj.has_ledgerseq())
{
if (obj.ledgerseq() != pLSeq)
{
pLSeq = obj.ledgerseq();
pLDo = !theApp->getOPs().haveLedger(pLSeq);
if (!pLDo)
{
cLog(lsDEBUG) << "Got pack for " << pLSeq << " too late";
}
else cLog(lsDEBUG) << "Got pack for " << pLSeq;
}
}
theApp->getOPs().addFetchPack(hash, data);
if (pLDo)
{
uint256 hash;
memcpy(hash.begin(), obj.hash().data(), 256 / 8);
boost::shared_ptr< std::vector<unsigned char> > data = boost::make_shared< std::vector<unsigned char> >
(obj.data().begin(), obj.data().end());
theApp->getOPs().addFetchPack(hash, data);
}
}
}
}