Add times_rlp and headers_rlp modules (#743)

This commit is contained in:
Kim De Mey 2024-10-04 17:19:59 +02:00 committed by GitHub
parent 4ea11b9fb9
commit cea821df60
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 32 additions and 8 deletions

View File

@ -7,16 +7,13 @@
import
"."/[
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
export
accounts_rlp, addresses_rlp, base_rlp, blocks_rlp, eth_types, hashes_rlp,
receipts_rlp, transactions_rlp, rlp
proc read*(rlp: var Rlp, T: type EthTime): T {.raises: [RlpError].} =
EthTime rlp.read(uint64)
headers_rlp, receipts_rlp, times_rlp, transactions_rlp, rlp
proc append*(rlpWriter: var RlpWriter, value: BlockHashOrNumber) =
case value.isHash
@ -31,9 +28,6 @@ proc read*(rlp: var Rlp, T: type BlockHashOrNumber): T =
else:
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 =
keccak256(rlp.encode(v))

View File

@ -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

18
eth/common/times_rlp.nim Normal file
View File

@ -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)