Added comments (#2546)

This commit is contained in:
Jordan Hrycaj 2024-08-06 12:43:39 +00:00 committed by GitHub
parent 5b502a06c4
commit 6bae929439
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 0 deletions

View File

@ -113,6 +113,7 @@ proc partUntwig*(
root: Hash256;
path: openArray[byte];
): Result[Blob,AristoError] =
## Verify the chain of rlp-encoded nodes and return the payload.
try:
let nibbles = NibblesBuf.fromBytes path
return chain.trackRlpNodes(root.to(HashKey), nibbles, start=true)
@ -124,6 +125,7 @@ proc partUntwig*(
root: Hash256;
path: Hash256;
): Result[Blob,AristoError] =
## Veriant of `partUntwig()`.
chain.partUntwig(root, path.data)
@ -133,6 +135,11 @@ proc partUntwigOk*(
path: openArray[byte];
payload: openArray[byte];
): Result[void,AristoError] =
## Verify the chain of rlp-encoded nodes and return the payload.
##
## Note: This function provides a functionality comparable to the
## `isValidBranch()` function from `hexary.nim`
##
if payload == ? chain.partUntwig(root, path):
ok()
else:
@ -144,6 +151,7 @@ proc partUntwigOk*(
path: Hash256;
payload: openArray[byte];
): Result[void,AristoError] =
## Veriant of `partUntwigOk()`.
chain.partUntwigOk(root, path.data, payload)
# ----------------