mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-11 06:46:10 +00:00
a few more cleanups
This commit is contained in:
parent
7e881a4c09
commit
1d9a58f1e8
@ -513,7 +513,7 @@ Json.useCustomSerialization(BitSeq):
|
|||||||
writer.writeValue "0x" & seq[byte](value).toHex
|
writer.writeValue "0x" & seq[byte](value).toHex
|
||||||
|
|
||||||
template readValue*(reader: var JsonReader, value: var List) =
|
template readValue*(reader: var JsonReader, value: var List) =
|
||||||
value = T readValue(reader, seq[type value[0]])
|
value = type(value)(readValue(reader, seq[type value[0]]))
|
||||||
|
|
||||||
template writeValue*(writer: var JsonWriter, value: List) =
|
template writeValue*(writer: var JsonWriter, value: List) =
|
||||||
writeValue(writer, asSeq value)
|
writeValue(writer, asSeq value)
|
||||||
|
@ -10,6 +10,11 @@ const
|
|||||||
offsetSize* = 4
|
offsetSize* = 4
|
||||||
bytesPerChunk* = 32
|
bytesPerChunk* = 32
|
||||||
|
|
||||||
|
type
|
||||||
|
UintN* = SomeUnsignedInt # TODO: Add StUint here
|
||||||
|
BasicType* = bool|UintN
|
||||||
|
|
||||||
|
Limit* = int64
|
||||||
|
|
||||||
# A few index types from here onwards:
|
# A few index types from here onwards:
|
||||||
# * dataIdx - leaf index starting from 0 to maximum length of collection
|
# * dataIdx - leaf index starting from 0 to maximum length of collection
|
||||||
@ -17,9 +22,9 @@ const
|
|||||||
# * vIdx - virtual index in merkle tree - the root is found at index 1, its
|
# * vIdx - virtual index in merkle tree - the root is found at index 1, its
|
||||||
# two children at 2, 3 then 4, 5, 6, 7 etc
|
# two children at 2, 3 then 4, 5, 6, 7 etc
|
||||||
|
|
||||||
proc dataPerChunk(T: type): int =
|
template dataPerChunk(T: type): int =
|
||||||
# How many data items fit in a chunk
|
# How many data items fit in a chunk
|
||||||
when T is bool|SomeUnsignedInt: # BasicType
|
when T is BasicType:
|
||||||
bytesPerChunk div sizeof(T)
|
bytesPerChunk div sizeof(T)
|
||||||
else:
|
else:
|
||||||
1
|
1
|
||||||
@ -39,11 +44,6 @@ template layer*(vIdx: int64): int =
|
|||||||
log2trunc(vIdx.uint64).int
|
log2trunc(vIdx.uint64).int
|
||||||
|
|
||||||
type
|
type
|
||||||
UintN* = SomeUnsignedInt # TODO: Add StUint here
|
|
||||||
BasicType* = bool|UintN
|
|
||||||
|
|
||||||
Limit* = int64
|
|
||||||
|
|
||||||
List*[T; maxLen: static Limit] = distinct seq[T]
|
List*[T; maxLen: static Limit] = distinct seq[T]
|
||||||
BitList*[maxLen: static Limit] = distinct BitSeq
|
BitList*[maxLen: static Limit] = distinct BitSeq
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user