erasure: removing MDS assumption from decode

decode was only retrieving ecK pieces, which is OK with MDS,
but not working with 2D RS and other non MDS codes.

Signed-off-by: Csaba Kiraly <csaba.kiraly@gmail.com>
This commit is contained in:
Csaba Kiraly 2023-11-08 15:20:58 +01:00
parent 6adb498cbc
commit 195b5a81a6
No known key found for this signature in database
GPG Key ID: 0FE274EE8C95166E

View File

@ -154,13 +154,15 @@ proc encode*(
proc decode*(
self: Erasure,
encoded: Manifest): Future[?!Manifest] {.async.} =
encoded: Manifest,
needed: int = encoded.ecK): Future[?!Manifest] {.async.} =
## Decode a protected manifest into it's original
## manifest
##
## `encoded` - the encoded (protected) manifest to
## be recovered
##
## `needed` - number of pieces to retrieve before attempting decode.
## Defaults to MDS ecK.
logScope:
steps = encoded.steps
@ -197,7 +199,7 @@ proc decode*(
while true:
# Continue to receive blocks until we have just enough for decoding
# or no more blocks can arrive
if (resolved >= encoded.ecK) or (idxPendingBlocks.len == 0):
if (resolved >= needed) or (idxPendingBlocks.len == 0):
break
let