Compare commits
2 Commits
44da7687a6
...
00104e5dff
Author | SHA1 | Date |
---|---|---|
Eric | 00104e5dff | |
gmega | bd75928227 |
|
@ -85,6 +85,10 @@ type
|
||||||
|
|
||||||
ErasureError* = object of CodexError
|
ErasureError* = object of CodexError
|
||||||
InsufficientBlocksError* = object of ErasureError
|
InsufficientBlocksError* = object of ErasureError
|
||||||
|
# Minimum size, in bytes, that the dataset must have had
|
||||||
|
# for the encoding request to have succeeded with the parameters
|
||||||
|
# provided.
|
||||||
|
minSize*: NBytes
|
||||||
|
|
||||||
func indexToPos(steps, idx, step: int): int {.inline.} =
|
func indexToPos(steps, idx, step: int): int {.inline.} =
|
||||||
## Convert an index to a position in the encoded
|
## Convert an index to a position in the encoded
|
||||||
|
@ -240,11 +244,12 @@ proc init*(
|
||||||
ecK: Natural, ecM: Natural,
|
ecK: Natural, ecM: Natural,
|
||||||
strategy: StrategyType): ?!EncodingParams =
|
strategy: StrategyType): ?!EncodingParams =
|
||||||
if ecK > manifest.blocksCount:
|
if ecK > manifest.blocksCount:
|
||||||
let exc = newException(InsufficientBlocksError,
|
let exc = (ref InsufficientBlocksError)(
|
||||||
"Unable to encode manifest, not enough blocks, ecK = " &
|
msg: "Unable to encode manifest, not enough blocks, ecK = " &
|
||||||
$ecK &
|
$ecK &
|
||||||
", blocksCount = " &
|
", blocksCount = " &
|
||||||
$manifest.blocksCount)
|
$manifest.blocksCount,
|
||||||
|
minSize: ecK.NBytes * manifest.blockSize)
|
||||||
return failure(exc)
|
return failure(exc)
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
|
@ -461,7 +461,9 @@ proc initPurchasingApi(node: CodexNodeRef, router: var RestRouter) =
|
||||||
expiry), error:
|
expiry), error:
|
||||||
|
|
||||||
if error of InsufficientBlocksError:
|
if error of InsufficientBlocksError:
|
||||||
return RestApiResponse.error(Http400, "Insufficient blocks, increased dataset size required")
|
return RestApiResponse.error(Http400,
|
||||||
|
"Dataset too small for erasure parameters, need at least " &
|
||||||
|
$(ref InsufficientBlocksError)(error).minSize.int & " bytes")
|
||||||
|
|
||||||
return RestApiResponse.error(Http500, error.msg)
|
return RestApiResponse.error(Http500, error.msg)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue