Simplify SHAMapNodeID:

The existing SHAMapNodeID object has both a valid and an invalid state
and requirs callers to verify the state of an instance prior to using
it. A simple set of changes removes that restriction and ensures that
all instances are valid, making the code more robust.

This change also:

1. Introduces a new function to construct a SHAMapNodeID from a
   serialized blob; and
2. Reduces the amount of constructors the class exposes.
This commit is contained in:
Nik Bougalis
2020-09-21 21:33:27 -07:00
parent 57ffc58613
commit ab77444fa3
12 changed files with 245 additions and 266 deletions

View File

@@ -249,7 +249,7 @@ public:
uint256 const hash(ripple::sha512Half(123456789));
getLedger->set_ledgerhash(hash.begin(), hash.size());
getLedger->set_ledgerseq(123456789);
ripple::SHAMapNodeID sha(hash.data(), hash.size());
ripple::SHAMapNodeID sha(17, hash);
getLedger->add_nodeids(sha.getRawString());
getLedger->set_requestcookie(123456789);
getLedger->set_querytype(protocol::qtINDIRECT);
@@ -309,7 +309,7 @@ public:
uint256 hash(ripple::sha512Half(i));
auto object = getObject->add_objects();
object->set_hash(hash.data(), hash.size());
ripple::SHAMapNodeID sha(hash.data(), hash.size());
ripple::SHAMapNodeID sha(i % 55, hash);
object->set_nodeid(sha.getRawString());
object->set_index("");
object->set_data("");