Changed addProtection to protect

This commit is contained in:
Bulat-Ziganshin 2022-09-11 05:30:38 +03:00
parent 41c10dfbb1
commit e5e70a7dd2
3 changed files with 6 additions and 6 deletions

View File

@ -82,7 +82,7 @@ proc encode*(
parity = parity
trace "Erasure coding manifest", blocks, parity
without var encoded =? manifest.addProtection(blocks, parity), error:
without var encoded =? manifest.protect(blocks, parity), error:
trace "Unable to create manifest", msg = error.msg
return error.failure
@ -262,7 +262,7 @@ proc decode*(
finally:
decoder.release()
without decoded =? encoded.removeProtection(), error:
without decoded =? encoded.unprotect(), error:
return failure error
return success decoded

View File

@ -206,7 +206,7 @@ proc new*(
originalBytes: blocks.len * blockSize,
protected: protected).success
proc addProtection*(
proc protect*(
manifest: Manifest,
K, M: int): ?!Manifest =
## Create an erasure protected dataset manifest from an unprotected one
@ -239,7 +239,7 @@ proc addProtection*(
? self.verify()
self.success
proc removeProtection*(
proc unprotect*(
manifest: Manifest
): ?!Manifest =
## Create an unprotected dataset manifest from an erasure protected one

View File

@ -67,7 +67,7 @@ suite "Manifest":
manifest = Manifest.new(blocks).tryGet()
let
protected = manifest.addProtection(2, 2).tryGet()
protected = manifest.protect(2, 2).tryGet()
check:
protected.protected == true
protected.originalLen == manifest.len
@ -75,7 +75,7 @@ suite "Manifest":
protected.blocks[0..<N] == manifest.blocks
let
unprotected = protected.removeProtection().tryGet()
unprotected = protected.unprotect().tryGet()
check:
unprotected.protected == false
unprotected.cid.tryGet() == manifest.cid.tryGet()