mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
A minimal, but serviceable, implemention of replying to TMGetObjectByHash queries.
This commit is contained in:
18
src/Peer.cpp
18
src/Peer.cpp
@@ -876,11 +876,27 @@ void Peer::recvGetObjectByHash(newcoin::TMGetObjectByHash& packet)
|
||||
if (packet.has_ledgerhash())
|
||||
reply.set_ledgerhash(packet.ledgerhash());
|
||||
|
||||
// This is a very minimal implementation
|
||||
for (unsigned i = 0; i < packet.objects_size(); ++i)
|
||||
{
|
||||
uint256 hash;
|
||||
const newcoin::TMIndexedObject& obj = packet.objects(i);
|
||||
// WRITEME
|
||||
if (obj.has_hash() && (obj.hash().size() == (256/8)))
|
||||
{
|
||||
memcpy(hash.begin(), obj.hash().data(), 256 / 8);
|
||||
HashedObject::pointer hObj = theApp->getHashedObjectStore().retrieve(hash);
|
||||
if (hObj)
|
||||
{
|
||||
newcoin::TMIndexedObject& newObj = *reply.add_objects();
|
||||
newObj.set_hash(hash.begin(), hash.size());
|
||||
newObj.set_data(&hObj->getData().front(), hObj->getData().size());
|
||||
if (obj.has_nodeid())
|
||||
newObj.set_index(obj.nodeid());
|
||||
}
|
||||
}
|
||||
}
|
||||
cLog(lsDEBUG) << "GetObjByHash query: had " << reply.objects_size() << " of " << packet.objects_size();
|
||||
sendPacket(boost::make_shared<PackedMessage>(packet, newcoin::mtGET_OBJECTS));
|
||||
}
|
||||
else
|
||||
{ // this is a reply
|
||||
|
||||
Reference in New Issue
Block a user