From 4f69b8e2ff1ee1995c27879367dea497e2d7a14c Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Mon, 17 Sep 2018 18:28:15 +0300 Subject: [PATCH] Fix the Transaction object serialization issues This requires the use of the latest compiler from the nimbus branch. --- eth_common/eth_types.nim | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/eth_common/eth_types.nim b/eth_common/eth_types.nim index df1c190..bc2f9bb 100644 --- a/eth_common/eth_types.nim +++ b/eth_common/eth_types.nim @@ -23,6 +23,8 @@ type ## Type alias used for gas computation # For reference - https://github.com/status-im/nimbus/issues/35#issuecomment-391726518 + TxAddressTag* = object # In transactions zero address is encoded as empty blob + Transaction* = object accountNonce*: AccountNonce gasPrice*: GasInt @@ -33,8 +35,6 @@ type V*: byte R*, S*: UInt256 - TxAddressTag* = object # In transactions zero address is encoded as empty blob - BlockNumber* = UInt256 BlockHeader* = object @@ -175,12 +175,11 @@ proc append*(rlpWriter: var RlpWriter, value: Stint) = {.error: "RLP serialization of signed integers is not allowed".} discard -# BUG! The compilation is successfull with the following prox commented out, because this proc is ignored even if present -# proc read*(rlp: var Rlp, T: typedesc[EthAddress], tag: type TxAddressTag): T {.inline.} = -# if rlp.blobLen != 0: -# result = rlp.read(EthAddress) -# else: -# rlp.skipElem +proc read*(rlp: var Rlp, T: typedesc[EthAddress], tag: type TxAddressTag): T {.inline.} = + if rlp.blobLen != 0: + result = rlp.read(EthAddress) + else: + rlp.skipElem proc append*(rlpWriter: var RlpWriter, a: EthAddress, tag: type TxAddressTag) {.inline.} = var d: type(a)