mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-22 20:42:13 +00:00
Attempt to find proper readValue.
This commit is contained in:
parent
9de65fa293
commit
b7f36be73c
@ -4,6 +4,7 @@
|
|||||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
|
import ../spec/datatypes except readValue, writeValue
|
||||||
import
|
import
|
||||||
std/[typetraits, sequtils, strutils, deques, sets, options],
|
std/[typetraits, sequtils, strutils, deques, sets, options],
|
||||||
stew/[results, base10],
|
stew/[results, base10],
|
||||||
@ -15,8 +16,6 @@ import
|
|||||||
../ssz/merkleization,
|
../ssz/merkleization,
|
||||||
./rest_utils
|
./rest_utils
|
||||||
|
|
||||||
import ../spec/datatypes except readValue, writeValue
|
|
||||||
|
|
||||||
logScope: topics = "rest_beaconapi"
|
logScope: topics = "rest_beaconapi"
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -290,19 +289,37 @@ proc readValue*(reader: var JsonReader, value: var Slot)
|
|||||||
else:
|
else:
|
||||||
reader.raiseUnexpectedValue($res.error())
|
reader.raiseUnexpectedValue($res.error())
|
||||||
|
|
||||||
# proc readValue*(reader: var JsonReader, value: var ValidatorIndex)
|
proc readValue*(reader: var JsonReader, value: var uint64)
|
||||||
# {.raises: [IOError, SerializationError, Defect].} =
|
{.raises: [IOError, SerializationError, Defect].} =
|
||||||
# let svalue = reader.readValue(string)
|
let svalue = reader.readValue(string)
|
||||||
# let res = Base10.decode(uint64, svalue)
|
let res = Base10.decode(uint64, svalue)
|
||||||
# if res.isOk():
|
if res.isOk():
|
||||||
# let v = res.get()
|
value = res.get()
|
||||||
# if v < VALIDATOR_REGISTRY_LIMIT:
|
else:
|
||||||
# value = ValidatorIndex(v)
|
reader.raiseUnexpectedValue($res.error())
|
||||||
# else:
|
|
||||||
# reader.raiseUnexpectedValue(
|
proc readValue*(reader: var JsonReader, value: var uint32)
|
||||||
# "Validator index is bigger then VALIDATOR_REGISTRY_LIMIT")
|
{.raises: [IOError, SerializationError, Defect].} =
|
||||||
# else:
|
let svalue = reader.readValue(string)
|
||||||
# reader.raiseUnexpectedValue($res.error())
|
let res = Base10.decode(uint32, svalue)
|
||||||
|
if res.isOk():
|
||||||
|
value = res.get()
|
||||||
|
else:
|
||||||
|
reader.raiseUnexpectedValue($res.error())
|
||||||
|
|
||||||
|
proc readValue*(reader: var JsonReader, value: var ValidatorIndex)
|
||||||
|
{.raises: [IOError, SerializationError, Defect].} =
|
||||||
|
let svalue = reader.readValue(string)
|
||||||
|
let res = Base10.decode(uint64, svalue)
|
||||||
|
if res.isOk():
|
||||||
|
let v = res.get()
|
||||||
|
if v < VALIDATOR_REGISTRY_LIMIT:
|
||||||
|
value = ValidatorIndex(v)
|
||||||
|
else:
|
||||||
|
reader.raiseUnexpectedValue(
|
||||||
|
"Validator index is bigger then VALIDATOR_REGISTRY_LIMIT")
|
||||||
|
else:
|
||||||
|
reader.raiseUnexpectedValue($res.error())
|
||||||
|
|
||||||
proc decodeBody*[T](t: typedesc[T],
|
proc decodeBody*[T](t: typedesc[T],
|
||||||
body: ContentBody): Result[T, cstring] =
|
body: ContentBody): Result[T, cstring] =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user