Fix AssertionError that should be RlpTypeMismatch

This commit is contained in:
kdeme 2019-10-10 13:07:20 +02:00
parent 87f2a51a1b
commit 9b69910570
No known key found for this signature in database
GPG Key ID: 4E8DD21420AF43F5
1 changed files with 7 additions and 4 deletions

View File

@ -289,11 +289,14 @@ proc append*(rlpWriter: var RlpWriter, t: Transaction, a: EthAddress) {.inline.}
rlpWriter.append(a)
proc read*(rlp: var Rlp, T: typedesc[HashOrStatus]): T {.inline.} =
doAssert(rlp.blobLen() == 32 or rlp.blobLen() == 1)
if rlp.blobLen == 1:
result = hashOrStatus(rlp.read(uint8) == 1)
if rlp.isBlob() and (rlp.blobLen() == 32 or rlp.blobLen() == 1):
if rlp.blobLen == 1:
result = hashOrStatus(rlp.read(uint8) == 1)
else:
result = hashOrStatus(rlp.read(Hash256))
else:
result = hashOrStatus(rlp.read(Hash256))
raise newException(RlpTypeMismatch,
"HashOrStatus expected, but the source RLP is not a blob of right size.")
proc append*(rlpWriter: var RlpWriter, value: HashOrStatus) {.inline.} =
if value.isHash: