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