mirror of https://github.com/status-im/nim-eth.git
Address review comments from Enterlist PR
This commit is contained in:
parent
0d63ff4db4
commit
b951ec45dc
|
@ -229,7 +229,7 @@ proc fromBytesAux(r: var Record): bool =
|
||||||
return false
|
return false
|
||||||
|
|
||||||
# We already know we are working with a list
|
# We already know we are working with a list
|
||||||
discard rlp.enterList()
|
doAssert rlp.enterList()
|
||||||
rlp.skipElem() # Skip signature
|
rlp.skipElem() # Skip signature
|
||||||
|
|
||||||
r.seqNum = rlp.read(uint64)
|
r.seqNum = rlp.read(uint64)
|
||||||
|
|
|
@ -153,11 +153,9 @@ proc read*(rlp: var Rlp, T: typedesc[StatusOptions]): T =
|
||||||
|
|
||||||
let sz = rlp.listLen()
|
let sz = rlp.listLen()
|
||||||
# We already know that we are working with a list
|
# We already know that we are working with a list
|
||||||
discard rlp.enterList()
|
doAssert rlp.enterList()
|
||||||
for i in 0 ..< sz:
|
for i in 0 ..< sz:
|
||||||
if not rlp.enterList():
|
rlp.tryEnterList()
|
||||||
raise newException(RlpTypeMismatch,
|
|
||||||
"List expected, but the source RLP is not a list.")
|
|
||||||
|
|
||||||
var k: KeyKind
|
var k: KeyKind
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -387,7 +387,7 @@ proc replaceValue(data: Rlp, key: NibblesRange, value: BytesRange): Bytes =
|
||||||
# XXX: This can be optimized to a direct bitwise copy of the source RLP
|
# XXX: This can be optimized to a direct bitwise copy of the source RLP
|
||||||
var iter = data
|
var iter = data
|
||||||
# We already know that we are working with a list
|
# We already know that we are working with a list
|
||||||
discard iter.enterList()
|
doAssert iter.enterList()
|
||||||
for i in 0 ..< 16:
|
for i in 0 ..< 16:
|
||||||
r.append iter
|
r.append iter
|
||||||
iter.skipElem
|
iter.skipElem
|
||||||
|
@ -513,7 +513,7 @@ proc deleteAt(self: var HexaryTrie;
|
||||||
var rlpRes = initRlpList(17)
|
var rlpRes = initRlpList(17)
|
||||||
var iter = origRlp
|
var iter = origRlp
|
||||||
# We already know that we are working with a list
|
# We already know that we are working with a list
|
||||||
discard iter.enterList
|
doAssert iter.enterList
|
||||||
for i in 0 ..< 16:
|
for i in 0 ..< 16:
|
||||||
rlpRes.append iter
|
rlpRes.append iter
|
||||||
iter.skipElem
|
iter.skipElem
|
||||||
|
|
|
@ -102,7 +102,7 @@ test "encode and decode lists":
|
||||||
var list = rlpFromBytes encodeList(rlp.listELem(1), rlp.listELem(0)).toRange
|
var list = rlpFromBytes encodeList(rlp.listELem(1), rlp.listELem(0)).toRange
|
||||||
|
|
||||||
# test that iteration with enterList/skipElem works as expected
|
# test that iteration with enterList/skipElem works as expected
|
||||||
discard list.enterList # We alreay know that we are working with a list
|
doAssert list.enterList # We already know that we are working with a list
|
||||||
check list.toString == "Lorem ipsum dolor sit amet"
|
check list.toString == "Lorem ipsum dolor sit amet"
|
||||||
list.skipElem
|
list.skipElem
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue