mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-09 00:43:13 +00:00
refactor: remove unused variables and commented-out code in erasure and test files
This commit is contained in:
parent
75c4486c60
commit
31e93c1bca
@ -324,11 +324,6 @@ proc asyncEncode*(
|
||||
defer:
|
||||
threadPtr.close().expect("closing once works")
|
||||
|
||||
# var data = makeUncheckedArray(blocks)
|
||||
|
||||
# defer:
|
||||
# dealloc(data)
|
||||
|
||||
## Create an ecode task with block data
|
||||
var task = EncodeTask(
|
||||
erasure: cast[ptr Erasure](self),
|
||||
@ -386,10 +381,6 @@ proc encodeData(
|
||||
var data = seq[seq[byte]].new() # number of blocks to encode
|
||||
|
||||
data[].setLen(params.ecK)
|
||||
# TODO: this is a tight blocking loop so we sleep here to allow
|
||||
# other events to be processed, this should be addressed
|
||||
# by threading
|
||||
await sleepAsync(10.millis)
|
||||
|
||||
without resolved =?
|
||||
(await self.prepareEncodingData(manifest, params, step, data, cids, emptyBlock)),
|
||||
@ -495,14 +486,6 @@ proc asyncDecode*(
|
||||
defer:
|
||||
threadPtr.close().expect("closing once works")
|
||||
|
||||
# var
|
||||
# blockData = makeUncheckedArray(blocks)
|
||||
# parityData = makeUncheckedArray(parity)
|
||||
|
||||
# defer:
|
||||
# dealloc(blockData)
|
||||
# dealloc(parityData)
|
||||
|
||||
## Create an decode task with block data
|
||||
var task = DecodeTask(
|
||||
erasure: cast[ptr Erasure](self),
|
||||
@ -517,13 +500,12 @@ proc asyncDecode*(
|
||||
self.taskPool.spawn leopardDecodeTask(self.taskPool, addr task)
|
||||
let threadFut = threadPtr.wait()
|
||||
|
||||
if joinErr =? catch(await threadFut.join()).errorOption:
|
||||
if err =? catch(await noCancel threadFut).errorOption:
|
||||
return failure(err)
|
||||
if joinErr of CancelledError:
|
||||
raise (ref CancelledError) joinErr
|
||||
else:
|
||||
return failure(joinErr)
|
||||
if err =? catch(await threadFut.join()).errorOption:
|
||||
?catch(await noCancel threadFut)
|
||||
if err of CancelledError:
|
||||
raise (ref CancelledError) err
|
||||
|
||||
return failure(err)
|
||||
|
||||
if not task.success.load():
|
||||
return failure("Leopard decoding task failed")
|
||||
@ -549,11 +531,6 @@ proc decodeInternal(
|
||||
cids[].setLen(encoded.blocksCount)
|
||||
try:
|
||||
for step in 0 ..< encoded.steps:
|
||||
# TODO: this is a tight blocking loop so we sleep here to allow
|
||||
# other events to be processed, this should be addressed
|
||||
# by threading
|
||||
await sleepAsync(10.millis)
|
||||
|
||||
var
|
||||
data = seq[seq[byte]].new()
|
||||
parityData = seq[seq[byte]].new()
|
||||
|
||||
@ -302,78 +302,3 @@ suite "Erasure encode/decode":
|
||||
decoded.treeCid == manifest.treeCid
|
||||
decoded.treeCid == encoded.originalTreeCid
|
||||
decoded.blocksCount == encoded.originalBlocksCount
|
||||
|
||||
# test "Should complete encode/decode task when cancelled":
|
||||
# let
|
||||
# blocksLen = 10000
|
||||
# parityLen = 10
|
||||
# data = seq[seq[byte]].new()
|
||||
# chunker = RandomChunker.new(
|
||||
# rng, size = (blocksLen * BlockSize.int), chunkSize = BlockSize
|
||||
# )
|
||||
|
||||
# data[].setLen(blocksLen)
|
||||
|
||||
# for i in 0 ..< blocksLen:
|
||||
# let chunk = await chunker.getBytes()
|
||||
# shallowCopy(data[i], @(chunk))
|
||||
|
||||
# var
|
||||
# parity: seq[seq[byte]]
|
||||
# recovered: seq[seq[byte]]
|
||||
# cancelledTaskParity: seq[seq[byte]]
|
||||
# cancelledTaskRecovered: seq[seq[byte]]
|
||||
|
||||
# # parity = newSeqWith(parityLen, newSeq[byte](BlockSize.int))
|
||||
# # paritySeq = seq[seq[byte]].new()
|
||||
# # recovered = createDoubleArray(blocksLen, BlockSize.int)
|
||||
# # cancelledTaskParity = createDoubleArray(parityLen, BlockSize.int)
|
||||
# # cancelledTaskRecovered = createDoubleArray(blocksLen, BlockSize.int)
|
||||
|
||||
# # paritySeq[].setLen(parityLen)
|
||||
# # freeDoubleArray(parity, parityLen)
|
||||
# # freeDoubleArray(cancelledTaskParity, parityLen)
|
||||
# # freeDoubleArray(recovered, blocksLen)
|
||||
# # freeDoubleArray(cancelledTaskRecovered, blocksLen)
|
||||
|
||||
# # for i in 0 ..< parityLen:
|
||||
# # paritySeq[i] = cast[seq[byte]](parity[i])
|
||||
|
||||
# # call asyncEncode to get the parity
|
||||
# parity = (await erasure.asyncEncode(BlockSize.int, parityLen, data)).tryGet()
|
||||
|
||||
# let decFut = await erasure.asyncDecode(
|
||||
# BlockSize.int, data, parity
|
||||
# )
|
||||
|
||||
# check decFut.isOk
|
||||
|
||||
# # call asyncEncode and cancel the task
|
||||
# let encodeFut = erasure.asyncEncode(
|
||||
# BlockSize.int, parityLen, data,
|
||||
# )
|
||||
# encodeFut.cancel()
|
||||
|
||||
# try:
|
||||
# cancelledTaskParity = (await encodeFut).tryGet()
|
||||
# except CatchableError as exc:
|
||||
# check exc of CancelledError
|
||||
# finally:
|
||||
# check parity == cancelledTaskParity
|
||||
# # for i in 0 ..< parityLen:
|
||||
# # check equalMem(parity[i], cancelledTaskParity[i], BlockSize.int)
|
||||
|
||||
# # call asyncDecode and cancel the task
|
||||
# let decodeFut = erasure.asyncDecode(
|
||||
# BlockSize.int, data, parity,
|
||||
# )
|
||||
# decodeFut.cancel()
|
||||
|
||||
# try:
|
||||
# cancelledTaskRecovered = (await decodeFut).tryGet()
|
||||
# except CatchableError as exc:
|
||||
# check exc of CancelledError
|
||||
# finally:
|
||||
# check recovered == cancelledTaskRecovered
|
||||
# for i in 0 ..< blocksLen:
|
||||
# check equalMem(recovered[i], cancelledTaskRecovered[i], BlockSize.int)
|
||||
|
||||
2
vendor/nim-leopard
vendored
2
vendor/nim-leopard
vendored
@ -1 +1 @@
|
||||
Subproject commit 7506b90f9c650c02b96bf525d4fd1bd4942a495f
|
||||
Subproject commit aa5f8d7748a3299a3dbdc384f5e3fed330d30d51
|
||||
Loading…
x
Reference in New Issue
Block a user