mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-02-23 10:08:17 +00:00
More detailed comment in erasure.decode()
This commit is contained in:
parent
0260635564
commit
5ebfe676a6
@ -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
|
||||
|
||||
|
@ -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],
|
||||
|
Loading…
x
Reference in New Issue
Block a user