mirror of https://github.com/status-im/nim-eth.git
Add times_rlp and headers_rlp modules (#743)
This commit is contained in:
parent
4ea11b9fb9
commit
cea821df60
|
@ -7,16 +7,13 @@
|
||||||
import
|
import
|
||||||
"."/[
|
"."/[
|
||||||
accounts_rlp, addresses_rlp, base_rlp, blocks_rlp, eth_types, hashes_rlp,
|
accounts_rlp, addresses_rlp, base_rlp, blocks_rlp, eth_types, hashes_rlp,
|
||||||
receipts_rlp, transactions_rlp,
|
headers_rlp, receipts_rlp, times_rlp, transactions_rlp,
|
||||||
],
|
],
|
||||||
../rlp
|
../rlp
|
||||||
|
|
||||||
export
|
export
|
||||||
accounts_rlp, addresses_rlp, base_rlp, blocks_rlp, eth_types, hashes_rlp,
|
accounts_rlp, addresses_rlp, base_rlp, blocks_rlp, eth_types, hashes_rlp,
|
||||||
receipts_rlp, transactions_rlp, rlp
|
headers_rlp, receipts_rlp, times_rlp, transactions_rlp, rlp
|
||||||
|
|
||||||
proc read*(rlp: var Rlp, T: type EthTime): T {.raises: [RlpError].} =
|
|
||||||
EthTime rlp.read(uint64)
|
|
||||||
|
|
||||||
proc append*(rlpWriter: var RlpWriter, value: BlockHashOrNumber) =
|
proc append*(rlpWriter: var RlpWriter, value: BlockHashOrNumber) =
|
||||||
case value.isHash
|
case value.isHash
|
||||||
|
@ -31,9 +28,6 @@ proc read*(rlp: var Rlp, T: type BlockHashOrNumber): T =
|
||||||
else:
|
else:
|
||||||
BlockHashOrNumber(isHash: false, number: rlp.read(BlockNumber))
|
BlockHashOrNumber(isHash: false, number: rlp.read(BlockNumber))
|
||||||
|
|
||||||
proc append*(rlpWriter: var RlpWriter, t: EthTime) {.inline.} =
|
|
||||||
rlpWriter.append(t.uint64)
|
|
||||||
|
|
||||||
proc rlpHash*[T](v: T): Hash32 =
|
proc rlpHash*[T](v: T): Hash32 =
|
||||||
keccak256(rlp.encode(v))
|
keccak256(rlp.encode(v))
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
# eth
|
||||||
|
# Copyright (c) 2024 Status Research & Development GmbH
|
||||||
|
# Licensed and distributed under either of
|
||||||
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||||
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
|
{.push raises: [].}
|
||||||
|
|
||||||
|
import ./[headers, base_rlp, times_rlp], ../rlp
|
||||||
|
|
||||||
|
export headers, base_rlp, times_rlp, rlp
|
|
@ -0,0 +1,18 @@
|
||||||
|
# eth
|
||||||
|
# Copyright (c) 2024 Status Research & Development GmbH
|
||||||
|
# Licensed and distributed under either of
|
||||||
|
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||||
|
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||||
|
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||||
|
|
||||||
|
{.push raises: [].}
|
||||||
|
|
||||||
|
import ./times, ../rlp
|
||||||
|
|
||||||
|
export times, rlp
|
||||||
|
|
||||||
|
proc read*(rlp: var Rlp, T: type EthTime): T {.raises: [RlpError].} =
|
||||||
|
EthTime rlp.read(uint64)
|
||||||
|
|
||||||
|
proc append*(rlpWriter: var RlpWriter, t: EthTime) {.inline.} =
|
||||||
|
rlpWriter.append(t.uint64)
|
Loading…
Reference in New Issue