Comments addressed
This commit is contained in:
parent
4c31f50889
commit
9ea0bf4326
|
@ -18,11 +18,14 @@ type
|
||||||
func subkey(kind: DbKeyKind): array[1, byte] =
|
func subkey(kind: DbKeyKind): array[1, byte] =
|
||||||
result[0] = byte ord(kind)
|
result[0] = byte ord(kind)
|
||||||
|
|
||||||
func subkey[T](kind: DbKeyKind, key: T): auto =
|
func subkey[N: static int](kind: DbKeyKind, key: array[N, byte]):
|
||||||
var res: array[sizeof(T) + 1, byte]
|
array[N + 1, byte] =
|
||||||
res[0] = byte ord(kind)
|
result[0] = byte ord(kind)
|
||||||
copyMem(addr res[1], unsafeAddr key, sizeof(key))
|
result[1 .. ^1] = key
|
||||||
return res
|
|
||||||
|
func subkey(kind: DbKeyKind, key: uint64): array[sizeof(key) + 1, byte] =
|
||||||
|
result[0] = byte ord(kind)
|
||||||
|
copyMem(addr result[1], unsafeAddr key, sizeof(key))
|
||||||
|
|
||||||
func subkey(kind: type BeaconState, key: Eth2Digest): auto =
|
func subkey(kind: type BeaconState, key: Eth2Digest): auto =
|
||||||
subkey(kHashToState, key.data)
|
subkey(kHashToState, key.data)
|
||||||
|
|
|
@ -133,15 +133,13 @@ proc append*(writer: var RlpWriter, value: ValidatorPubKey) =
|
||||||
writer.append value.getBytes()
|
writer.append value.getBytes()
|
||||||
|
|
||||||
proc read*(rlp: var Rlp, T: type ValidatorPubKey): T {.inline.} =
|
proc read*(rlp: var Rlp, T: type ValidatorPubKey): T {.inline.} =
|
||||||
let r = rlp.read(seq[byte])
|
result = ValidatorPubKey.init(rlp.toBytes.toOpenArray)
|
||||||
if not init(result, r):
|
rlp.skipElem()
|
||||||
raise newException(Exception, "Could not init ValidatorPubKey from bytes")
|
|
||||||
|
|
||||||
proc append*(writer: var RlpWriter, value: ValidatorSig) =
|
proc append*(writer: var RlpWriter, value: ValidatorSig) =
|
||||||
writer.append value.getBytes()
|
writer.append value.getBytes()
|
||||||
|
|
||||||
proc read*(rlp: var Rlp, T: type ValidatorSig): T {.inline.} =
|
proc read*(rlp: var Rlp, T: type ValidatorSig): T {.inline.} =
|
||||||
let r = rlp.read(seq[byte])
|
result = ValidatorSig.init(rlp.toBytes.toOpenArray)
|
||||||
if not init(result, r):
|
rlp.skipElem()
|
||||||
raise newException(Exception, "Could not init ValidatorSig from bytes")
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue