mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
feat(eth-wire): derive serde traits for eth-wire types (#348)
* wip: start adding serde to stuff * add serde traits to NewBlockHashes * derive serde traits for the rest of the types * derive serde traits for p2p subprotocol messages * cargo fmt
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
use crate::{Header, SealedHeader, TransactionSigned, H256};
|
||||
use reth_rlp::{Decodable, DecodeError, Encodable, RlpDecodable, RlpEncodable};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::ops::Deref;
|
||||
|
||||
/// Ethereum full block.
|
||||
@ -46,7 +47,7 @@ impl Deref for BlockLocked {
|
||||
}
|
||||
|
||||
/// Either a block hash _or_ a block number
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum BlockHashOrNumber {
|
||||
/// A block hash
|
||||
Hash(H256),
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
use crate::U256;
|
||||
use ethers_core::types::{ParseChainError, U64};
|
||||
use reth_rlp::{Decodable, Encodable};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{fmt, str::FromStr};
|
||||
|
||||
/// Either a named or chain id or the actual id value
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
pub enum Chain {
|
||||
/// Contains a known chain
|
||||
Named(ethers_core::types::Chain),
|
||||
|
||||
@ -6,6 +6,7 @@ use bytes::{BufMut, BytesMut};
|
||||
use ethers_core::{types::H64, utils::keccak256};
|
||||
use reth_codecs::{main_codec, Compact};
|
||||
use reth_rlp::{length_of_length, Decodable, Encodable};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::ops::Deref;
|
||||
|
||||
/// Block header
|
||||
@ -279,7 +280,7 @@ impl SealedHeader {
|
||||
/// [`HeadersDirection::Falling`] block numbers for `reverse == false`
|
||||
///
|
||||
/// See also <https://github.com/ethereum/devp2p/blob/master/caps/eth.md#getblockheaders-0x03>
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Default)]
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Default, Serialize, Deserialize)]
|
||||
pub enum HeadersDirection {
|
||||
/// Falling block number.
|
||||
#[default]
|
||||
|
||||
Reference in New Issue
Block a user