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; root: Hash256;
path: openArray[byte]; path: openArray[byte];
): Result[Blob,AristoError] = ): Result[Blob,AristoError] =
## Verify the chain of rlp-encoded nodes and return the payload.
try: try:
let nibbles = NibblesBuf.fromBytes path let nibbles = NibblesBuf.fromBytes path
return chain.trackRlpNodes(root.to(HashKey), nibbles, start=true) return chain.trackRlpNodes(root.to(HashKey), nibbles, start=true)
@ -124,6 +125,7 @@ proc partUntwig*(
root: Hash256; root: Hash256;
path: Hash256; path: Hash256;
): Result[Blob,AristoError] = ): Result[Blob,AristoError] =
## Veriant of `partUntwig()`.
chain.partUntwig(root, path.data) chain.partUntwig(root, path.data)
@ -133,6 +135,11 @@ proc partUntwigOk*(
path: openArray[byte]; path: openArray[byte];
payload: openArray[byte]; payload: openArray[byte];
): Result[void,AristoError] = ): 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): if payload == ? chain.partUntwig(root, path):
ok() ok()
else: else:
@ -144,6 +151,7 @@ proc partUntwigOk*(
path: Hash256; path: Hash256;
payload: openArray[byte]; payload: openArray[byte];
): Result[void,AristoError] = ): Result[void,AristoError] =
## Veriant of `partUntwigOk()`.
chain.partUntwigOk(root, path.data, payload) chain.partUntwigOk(root, path.data, payload)
# ---------------- # ----------------