More detailed comment in erasure.decode()

This commit is contained in:
Bulat-Ziganshin 2022-09-04 01:20:40 +03:00
parent 0260635564
commit 5ebfe676a6
2 changed files with 20 additions and 10 deletions

View File

@ -195,8 +195,17 @@ proc decode*(
resolved = 0
while true:
# Continue to receive blocks until we have just enough for decoding
# or no more blocks can arrive
# Continue to receive blocks until one of the following:
# - we received K blocks
# - there are no more blocks to wait
#
# In the former case, we received just enough blocks to decode ECC group.
# Since Leopard decoding is very fast (~~ 1 GB/sec), it may be faster
# to reconstruct not yet arrived data blocks rather than wait more.
#
# We can replace this condition with dataPieces>=K to conserve some CPU resources.
# Or, develop a more complex algorithm with parallel downloading of multiple groups
# and timeouts.
if (resolved >= encoded.K) or (idxPendingBlocks.len == 0):
break

View File

@ -157,13 +157,15 @@ func copyAllScalarFields(
original: Manifest,
protected: bool
): Manifest =
# Sometimes we need to copy all but a few fields
# from a manifest to another one.
# It can be mplemented by copying all fields and then
# making a few edits, but it is inefficient to copy
# an entire `blocks` array only to drop it.
# So we made a helper that copies all scalar fields,
# i.e. all fields except for `blocks`.
## Sometimes we need to copy all but a few fields
## from a manifest to another one.
## It can be mplemented by copying all fields and then
## making a few edits, but it is inefficient to copy
## an entire `blocks` array only to drop it.
## So we made a helper that copies all scalar fields,
## i.e. all fields except for `blocks`.
##
var copy = Manifest(
rootHash: original.rootHash,
originalBytes: original.originalBytes,
@ -253,7 +255,6 @@ proc removeProtection*(
? self.verify()
self.success
proc new*(
T: type Manifest,
data: openArray[byte],