Fixed transaction to serialization

This commit is contained in:
Yuriy Glukhov 2018-09-17 11:14:57 +03:00
parent 3e721c28b3
commit d1ed8ecc28
1 changed files with 17 additions and 1 deletions

View File

@ -27,12 +27,14 @@ type
accountNonce*: AccountNonce
gasPrice*: GasInt
gasLimit*: GasInt
to*: EthAddress
to* {.rlpCustomSerialization: TxAddressTag.}: EthAddress
value*: UInt256
payload*: Blob
V*: byte
R*, S*: UInt256
TxAddressTag* = object # In transactions zero address is encoded as empty blob
BlockNumber* = UInt256
BlockHeader* = object
@ -173,6 +175,20 @@ 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 append*(rlpWriter: var RlpWriter, a: EthAddress, tag: type TxAddressTag) {.inline.} =
var d: type(a)
if a == d:
rlpWriter.append("")
else:
rlpWriter.append(a)
proc read*(rlp: var Rlp, T: typedesc[MDigest]): T {.inline.} =
result.data = rlp.read(type(result.data))