readU32 new spec, change LE to BE
This commit is contained in:
parent
73c487fdb0
commit
cecb8986a4
|
@ -65,9 +65,8 @@ template read(t: var TreeBuilder, len: int): auto =
|
|||
toOpenArray(t.data, pos, pos + len - 1)
|
||||
]#
|
||||
|
||||
proc readU32(t: var TreeBuilder): int =
|
||||
# TODO: what if the value overflow int32.high?
|
||||
result = fromBytesLE(uint32, t.read(4)).int
|
||||
proc readU32(t: var TreeBuilder): uint32 =
|
||||
result = fromBytesBE(uint32, t.read(4))
|
||||
|
||||
proc toAddress(r: var EthAddress, x: openArray[byte]) {.inline.} =
|
||||
r[0..19] = x[0..19]
|
||||
|
@ -210,7 +209,7 @@ proc extensionNode(t: var TreeBuilder, depth: int): NodeKey =
|
|||
|
||||
proc accountNode(t: var TreeBuilder, depth: int): NodeKey =
|
||||
assert(depth < 65)
|
||||
let len = t.readU32()
|
||||
let len = t.readU32().int
|
||||
result = toNodeKey(t.read(len))
|
||||
|
||||
when defined(debugDepth):
|
||||
|
|
|
@ -39,6 +39,9 @@ proc rlpListToBitmask(r: var Rlp): uint =
|
|||
inc i
|
||||
r.position = 0
|
||||
|
||||
proc writeU32(wb: var WitnessBuilder, x: uint32) =
|
||||
wb.output.append(toBytesBE(x))
|
||||
|
||||
proc writeNibbles(wb: var WitnessBuilder; n: NibblesSeq) =
|
||||
let nibblesLen = n.len
|
||||
let numBytes = nibblesLen div 2 + nibblesLen mod 2
|
||||
|
@ -87,7 +90,7 @@ proc writeBranchNode(wb: var WitnessBuilder, mask: uint, depth: int, node: openA
|
|||
proc writeAccountNode(wb: var WitnessBuilder, node: openArray[byte], depth: int) =
|
||||
# write type
|
||||
wb.output.append(AccountNodeType.byte)
|
||||
wb.output.append(toBytesLe(node.len.uint32))
|
||||
wb.writeU32(node.len.uint32)
|
||||
wb.output.append(node)
|
||||
|
||||
when defined(debugDepth):
|
||||
|
|
Loading…
Reference in New Issue