Address review comments from Enterlist PR

This commit is contained in:
kdeme 2020-02-29 17:35:08 +01:00
parent 0d63ff4db4
commit b951ec45dc
No known key found for this signature in database
GPG Key ID: 4E8DD21420AF43F5
4 changed files with 6 additions and 8 deletions

View File

@ -229,7 +229,7 @@ proc fromBytesAux(r: var Record): bool =
return false
# We already know we are working with a list
discard rlp.enterList()
doAssert rlp.enterList()
rlp.skipElem() # Skip signature
r.seqNum = rlp.read(uint64)

View File

@ -153,11 +153,9 @@ proc read*(rlp: var Rlp, T: typedesc[StatusOptions]): T =
let sz = rlp.listLen()
# We already know that we are working with a list
discard rlp.enterList()
doAssert rlp.enterList()
for i in 0 ..< sz:
if not rlp.enterList():
raise newException(RlpTypeMismatch,
"List expected, but the source RLP is not a list.")
rlp.tryEnterList()
var k: KeyKind
try:

View File

@ -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
var iter = data
# We already know that we are working with a list
discard iter.enterList()
doAssert iter.enterList()
for i in 0 ..< 16:
r.append iter
iter.skipElem
@ -513,7 +513,7 @@ proc deleteAt(self: var HexaryTrie;
var rlpRes = initRlpList(17)
var iter = origRlp
# We already know that we are working with a list
discard iter.enterList
doAssert iter.enterList
for i in 0 ..< 16:
rlpRes.append iter
iter.skipElem

View File

@ -102,7 +102,7 @@ test "encode and decode lists":
var list = rlpFromBytes encodeList(rlp.listELem(1), rlp.listELem(0)).toRange
# 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"
list.skipElem