public interface CheckedMapProof extends CheckedProof
ByteString key = "The key for which I want a proved value".getBytes();
HashCode expectedRootHash = // get a known root hash from block proof //
UncheckedMapProof proof = requestProofForKey(key);
// Convert to checked
CheckedMapProof checkedProof = proof.check();
// Check the root hash
if (checkedProof.isValid() && checkedProof.getRootHash().equals(expectedRootHash)) {
// Get and use the value(s)
ByteString value = checked.get(key);
}
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(com.google.protobuf.ByteString key)
If this proof is valid, returns true if there is a given key in the proof;
false — if there is no such key.
|
com.google.protobuf.ByteString |
get(com.google.protobuf.ByteString key)
If this proof is valid, returns the value corresponding to the specified key
or null if there is no such key in the proof.
|
java.util.Set<MapEntry> |
getEntries()
Get all leaf entries of this proof.
|
java.util.Set<com.google.protobuf.ByteString> |
getMissingKeys()
Get all keys that were requested, but did not appear in this proof.
|
MapProofStatus |
getProofStatus()
Returns the status of this proof: whether it is structurally valid.
|
getRootHash, isValid
java.util.Set<MapEntry> getEntries()
java.lang.IllegalStateException
- if the proof is not validjava.util.Set<com.google.protobuf.ByteString> getMissingKeys()
java.lang.IllegalStateException
- if the proof is not validboolean containsKey(com.google.protobuf.ByteString key)
java.lang.IllegalStateException
- if the proof is not validcom.google.protobuf.ByteString get(com.google.protobuf.ByteString key)
java.lang.IllegalStateException
- if the proof is not validMapProofStatus getProofStatus()
getProofStatus
in interface CheckedProof
Copyright © 2018 Exonum. All rights reserved.