mirror of https://github.com/status-im/nim-eth.git
ethblock: txs -> transactions (#694)
Using the same name as BlockBody to make them easily interchangeable - * add a few inits
This commit is contained in:
parent
b9b522f7ac
commit
5599435901
|
@ -171,7 +171,7 @@ type
|
||||||
|
|
||||||
EthBlock* = object
|
EthBlock* = object
|
||||||
header* : BlockHeader
|
header* : BlockHeader
|
||||||
txs* : seq[Transaction]
|
transactions*: seq[Transaction]
|
||||||
uncles* : seq[BlockHeader]
|
uncles* : seq[BlockHeader]
|
||||||
withdrawals*: Option[seq[Withdrawal]] # EIP-4895
|
withdrawals*: Option[seq[Withdrawal]] # EIP-4895
|
||||||
|
|
||||||
|
@ -209,6 +209,10 @@ const
|
||||||
EMPTY_UNCLE_HASH* = "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347".toDigest
|
EMPTY_UNCLE_HASH* = "1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347".toDigest
|
||||||
EMPTY_CODE_HASH* = "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470".toDigest
|
EMPTY_CODE_HASH* = "c5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470".toDigest
|
||||||
|
|
||||||
|
template txs*(blk: EthBlock): seq[Transaction] =
|
||||||
|
# Legacy name emulation
|
||||||
|
blk.transactions
|
||||||
|
|
||||||
when BlockNumber is int64:
|
when BlockNumber is int64:
|
||||||
## The goal of these templates is to make it easier to switch
|
## The goal of these templates is to make it easier to switch
|
||||||
## the block number type to a different representation
|
## the block number type to a different representation
|
||||||
|
@ -336,3 +340,11 @@ func hash*(a: EthAddress): Hash {.inline.} =
|
||||||
copyMem(addr a2, unsafeAddr a[16], sizeof(a2))
|
copyMem(addr a2, unsafeAddr a[16], sizeof(a2))
|
||||||
|
|
||||||
cast[Hash](a0 xor a1 xor uint64(a2))
|
cast[Hash](a0 xor a1 xor uint64(a2))
|
||||||
|
|
||||||
|
func init*(T: type EthBlock, header: sink BlockHeader, body: sink BlockBody): T =
|
||||||
|
T(
|
||||||
|
header: move(header),
|
||||||
|
transactions: move(body.transactions),
|
||||||
|
uncles: move(body.uncles),
|
||||||
|
withdrawals: move(body.withdrawals),
|
||||||
|
)
|
||||||
|
|
|
@ -33,7 +33,7 @@ proc loadFile(x: int) =
|
||||||
let header = r.read(EthHeader).header
|
let header = r.read(EthHeader).header
|
||||||
let body = r.readRecordType(BlockBody, false)
|
let body = r.readRecordType(BlockBody, false)
|
||||||
|
|
||||||
let blk3 = EthBlock(header: header, txs: body.transactions, uncles: body.uncles)
|
let blk3 = EthBlock(header: header, transactions: body.transactions, uncles: body.uncles)
|
||||||
let bytes3 = rlp.encode(blk3)
|
let bytes3 = rlp.encode(blk3)
|
||||||
check blk1 == blk3
|
check blk1 == blk3
|
||||||
check bytes1 == bytes3
|
check bytes1 == bytes3
|
||||||
|
|
Loading…
Reference in New Issue