Merge branch 'enterlist'

This commit is contained in:
Ștefan Talpalaru 2020-02-26 00:54:43 +01:00
commit 22bf279b07
No known key found for this signature in database
GPG Key ID: CBF7934204F1B6F9
4 changed files with 4 additions and 16 deletions

View File

@ -567,7 +567,7 @@ proc p2pProtocolBackendImpl*(protocol: P2PProtocol): Backend =
read = bindSym("read", brForceOpen) read = bindSym("read", brForceOpen)
checkedRlpRead = bindSym "checkedRlpRead" checkedRlpRead = bindSym "checkedRlpRead"
startList = bindSym "startList" startList = bindSym "startList"
safeEnterList = bindSym "safeEnterList" enterList = bindSym "enterList"
finish = bindSym "finish" finish = bindSym "finish"
messagePrinter = bindSym "messagePrinter" messagePrinter = bindSym "messagePrinter"
@ -677,7 +677,7 @@ proc p2pProtocolBackendImpl*(protocol: P2PProtocol): Backend =
let let
paramCount = paramsToWrite.len paramCount = paramsToWrite.len
readParamsPrelude = if paramCount > 1: newCall(safeEnterList, receivedRlp) readParamsPrelude = if paramCount > 1: newCall(enterList, receivedRlp)
else: newStmtList() else: newStmtList()
when tracingEnabled: when tracingEnabled:

View File

@ -147,17 +147,9 @@ proc append*(rlpWriter: var RlpWriter, value: StatusOptions) =
rlpWriter.append(rlpFromBytes(bytes.toRange)) rlpWriter.append(rlpFromBytes(bytes.toRange))
proc read*(rlp: var Rlp, T: typedesc[StatusOptions]): T = proc read*(rlp: var Rlp, T: typedesc[StatusOptions]): T =
if not rlp.isList():
raise newException(RlpTypeMismatch,
"List expected, but the source RLP is not a list.")
let sz = rlp.listLen() let sz = rlp.listLen()
rlp.enterList() rlp.enterList()
for i in 0 ..< sz: for i in 0 ..< sz:
if not rlp.isList():
raise newException(RlpTypeMismatch,
"List expected, but the source RLP is not a list.")
rlp.enterList() rlp.enterList()
var k: KeyKind var k: KeyKind
try: try:

View File

@ -243,13 +243,9 @@ proc currentElemEnd*(self: Rlp): int =
result += payloadOffset() + payloadBytesCount() result += payloadOffset() + payloadBytesCount()
proc enterList*(self: var Rlp) = proc enterList*(self: var Rlp) =
doAssert isList()
position += payloadOffset()
proc safeEnterList*(self: var Rlp) =
if not isList(): if not isList():
raise newException(RlpTypeMismatch, "List expected, but source RLP is not a list") raise newException(RlpTypeMismatch, "List expected, but source RLP is not a list")
enterList() position += payloadOffset()
proc skipElem*(rlp: var Rlp) = proc skipElem*(rlp: var Rlp) =
rlp.position = rlp.currentElemEnd rlp.position = rlp.currentElemEnd

View File

@ -384,7 +384,7 @@ proc replaceValue(data: Rlp, key: NibblesRange, value: BytesRange): Bytes =
var r = initRlpList(17) var r = initRlpList(17)
# XXX: This can be optmized 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
iter.enterList() iter.enterList()
for i in 0 ..< 16: for i in 0 ..< 16: