diff --git a/eth/common/eth_types.nim b/eth/common/eth_types.nim index fc4edf4..6e96f6c 100644 --- a/eth/common/eth_types.nim +++ b/eth/common/eth_types.nim @@ -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: