Compare commits
2 Commits
44da7687a6
...
00104e5dff
Author | SHA1 | Date |
---|---|---|
Eric | 00104e5dff | |
gmega | bd75928227 |
|
@ -85,6 +85,10 @@ type
|
|||
|
||||
ErasureError* = object of CodexError
|
||||
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.} =
|
||||
## Convert an index to a position in the encoded
|
||||
|
@ -240,11 +244,12 @@ proc init*(
|
|||
ecK: Natural, ecM: Natural,
|
||||
strategy: StrategyType): ?!EncodingParams =
|
||||
if ecK > manifest.blocksCount:
|
||||
let exc = newException(InsufficientBlocksError,
|
||||
"Unable to encode manifest, not enough blocks, ecK = " &
|
||||
let exc = (ref InsufficientBlocksError)(
|
||||
msg: "Unable to encode manifest, not enough blocks, ecK = " &
|
||||
$ecK &
|
||||
", blocksCount = " &
|
||||
$manifest.blocksCount)
|
||||
$manifest.blocksCount,
|
||||
minSize: ecK.NBytes * manifest.blockSize)
|
||||
return failure(exc)
|
||||
|
||||
let
|
||||
|
|
|
@ -461,7 +461,9 @@ proc initPurchasingApi(node: CodexNodeRef, router: var RestRouter) =
|
|||
expiry), error:
|
||||
|
||||
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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue