TMGetObjectByHash design changes.

This commit is contained in:
JoelKatz
2012-10-12 03:59:25 -07:00
parent 6cffcf0533
commit 51c5de61d9
3 changed files with 41 additions and 43 deletions

View File

@@ -540,7 +540,7 @@ void Peer::processReadBuffer()
break;
#endif
case newcoin::mtGET_OBJECT:
case newcoin::mtGET_OBJECTS:
{
newcoin::TMGetObjectByHash msg;
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
@@ -549,15 +549,6 @@ void Peer::processReadBuffer()
}
break;
case newcoin::mtOBJECT:
{
newcoin::TMObjectByHash msg;
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvObjectByHash(msg);
else std::cerr << "parse error: " << type << std::endl;
}
break;
default:
std::cerr << "Unknown Msg: " << type << std::endl;
std::cerr << strHex(&mReadbuf[0], mReadbuf.size());
@@ -872,16 +863,29 @@ void Peer::recvPeers(newcoin::TMPeers& packet)
}
}
void Peer::recvIndexedObject(newcoin::TMIndexedObject& packet)
{
}
void Peer::recvGetObjectByHash(newcoin::TMGetObjectByHash& packet)
{
}
if (packet.query())
{ // this is a query
newcoin::TMGetObjectByHash reply;
void Peer::recvObjectByHash(newcoin::TMObjectByHash& packet)
{
reply.clear_query();
if (packet.has_seq())
reply.set_seq(packet.seq());
reply.set_type(packet.type());
if (packet.has_ledgerhash())
reply.set_ledgerhash(packet.ledgerhash());
for (unsigned i = 0; i < packet.objects_size(); ++i)
{
const newcoin::TMIndexedObject& obj = packet.objects(i);
// WRITEME
}
}
else
{ // this is a reply
// WRITEME
}
}
void Peer::recvPing(newcoin::TMPing& packet)

View File

@@ -102,9 +102,7 @@ protected:
void recvGetContacts(newcoin::TMGetContacts& packet);
void recvGetPeers(newcoin::TMGetPeers& packet);
void recvPeers(newcoin::TMPeers& packet);
void recvIndexedObject(newcoin::TMIndexedObject& packet);
void recvGetObjectByHash(newcoin::TMGetObjectByHash& packet);
void recvObjectByHash(newcoin::TMObjectByHash& packet);
void recvPing(newcoin::TMPing& packet);
void recvErrorMessage(newcoin::TMErrorMsg& packet);
void recvSearchTransaction(newcoin::TMSearchTransaction& packet);

View File

@@ -28,8 +28,7 @@ enum MessageType {
// data replication and synchronization
mtGET_VALIDATIONS = 40;
mtVALIDATION = 41;
mtGET_OBJECT = 42;
mtOBJECT = 43;
mtGET_OBJECTS = 42;
}
@@ -193,34 +192,31 @@ message TMAccount{
message TMIndexedObject
{
enum ObjectType {
otTRANSACTION = 1;
otTRANSACTION_NODE = 2; // a node in a transaction tree
otTRANSACTION_LEAF = 3; // a leaf in a transaction tree
otACCOUNT = 4; // a single account state (with balance/sequence)
otACCOUNT_NODE = 5; // a node in an account state tree
otACCOUNT_LEAF = 6; // a leaf in an account state tree
otLEDGER = 7;
}
required bytes hash = 1;
required ObjectType type = 2;
optional bytes hash = 1;
optional bytes nodeID = 2;
optional bytes index = 3;
optional bytes data = 4;
}
message TMGetObjectByHash
{
required TMIndexedObject object = 1;
optional uint32 seq = 2; // used to match replies to queries
enum ObjectType {
otUNKNOWN = 0;
otLEDGER = 1;
otTRANSACTION = 2;
otTRANSACTION_NODE = 3;
otSTATE_NODE = 4;
otCAS_OBJECT = 5;
}
required ObjectType type = 1;
required bool query = 2; // is this a query or a reply?
optional uint32 seq = 3; // used to match replies to queries
optional bytes ledgerHash = 4; // the hash of the ledger these queries are for
optional bool fat = 5; // return related nodes
repeated TMIndexedObject objects = 6; // the specific objects requested
}
message TMObjectByHash
{
optional TMIndexedObject object = 1; // present unless no object found
optional bytes data = 2; // present unless no object found
optional uint32 seq = 3; // matches seq from query
}
message TMLedgerNode {
required bytes nodedata = 1;