mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Removing reth network api dependency from rpc types (#2281)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
3
Cargo.lock
generated
3
Cargo.lock
generated
@ -4941,6 +4941,7 @@ dependencies = [
|
||||
"reth-provider",
|
||||
"reth-rlp",
|
||||
"reth-rlp-derive",
|
||||
"reth-rpc-types",
|
||||
"reth-tasks",
|
||||
"reth-tracing",
|
||||
"reth-transaction-pool",
|
||||
@ -4963,6 +4964,7 @@ dependencies = [
|
||||
"async-trait",
|
||||
"reth-eth-wire",
|
||||
"reth-primitives",
|
||||
"reth-rpc-types",
|
||||
"serde",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
@ -5219,7 +5221,6 @@ dependencies = [
|
||||
"lru 0.9.0",
|
||||
"rand 0.8.5",
|
||||
"reth-interfaces",
|
||||
"reth-network-api",
|
||||
"reth-primitives",
|
||||
"reth-rlp",
|
||||
"serde",
|
||||
|
||||
@ -11,6 +11,7 @@ description = "Network interfaces"
|
||||
# reth
|
||||
reth-primitives = { path = "../../primitives" }
|
||||
reth-eth-wire = { path = "../eth-wire" }
|
||||
reth-rpc-types = { path = "../../rpc/rpc-types" }
|
||||
|
||||
# io
|
||||
serde = { version = "1.0", features = ["derive"], optional = true }
|
||||
|
||||
@ -11,12 +11,10 @@
|
||||
|
||||
use async_trait::async_trait;
|
||||
use reth_eth_wire::DisconnectReason;
|
||||
use reth_primitives::{NodeRecord, PeerId, H256, U256};
|
||||
use reth_primitives::{NodeRecord, PeerId};
|
||||
use reth_rpc_types::NetworkStatus;
|
||||
use std::net::SocketAddr;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub use error::NetworkError;
|
||||
pub use reputation::{Reputation, ReputationChangeKind};
|
||||
|
||||
@ -93,32 +91,3 @@ pub enum PeerKind {
|
||||
/// Trusted peer.
|
||||
Trusted,
|
||||
}
|
||||
|
||||
/// The status of the network being ran by the local node.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct NetworkStatus {
|
||||
/// The local node client version.
|
||||
pub client_version: String,
|
||||
/// The current ethereum protocol version
|
||||
pub protocol_version: u64,
|
||||
/// Information about the Ethereum Wire Protocol.
|
||||
pub eth_protocol_info: EthProtocolInfo,
|
||||
}
|
||||
/// Information about the Ethereum Wire Protocol (ETH)
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct EthProtocolInfo {
|
||||
/// The current difficulty at the head of the chain.
|
||||
#[cfg_attr(
|
||||
feature = "serde",
|
||||
serde(deserialize_with = "reth_primitives::serde_helper::deserialize_json_u256")
|
||||
)]
|
||||
pub difficulty: U256,
|
||||
/// The block hash of the head of the chain.
|
||||
pub head: H256,
|
||||
/// Network ID in base 10.
|
||||
pub network: u64,
|
||||
/// Genesis block of the current chain.
|
||||
pub genesis: H256,
|
||||
}
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
use crate::{
|
||||
EthProtocolInfo, NetworkError, NetworkInfo, NetworkStatus, PeerKind, Peers, PeersInfo,
|
||||
ReputationChangeKind,
|
||||
};
|
||||
use crate::{NetworkError, NetworkInfo, PeerKind, Peers, PeersInfo, ReputationChangeKind};
|
||||
use async_trait::async_trait;
|
||||
use reth_eth_wire::{DisconnectReason, ProtocolVersion};
|
||||
use reth_primitives::{rpc::Chain::Mainnet, NodeRecord, PeerId};
|
||||
use reth_rpc_types::{EthProtocolInfo, NetworkStatus};
|
||||
use std::net::{IpAddr, SocketAddr};
|
||||
|
||||
/// A type that implements all network trait that does nothing.
|
||||
|
||||
@ -31,6 +31,7 @@ reth-tasks = { path = "../../tasks" }
|
||||
reth-transaction-pool = { path = "../../transaction-pool" }
|
||||
reth-provider = { path = "../../storage/provider"}
|
||||
reth-metrics-common = { path = "../../metrics/common" }
|
||||
reth-rpc-types = { path = "../../rpc/rpc-types" }
|
||||
|
||||
# async/futures
|
||||
futures = "0.3"
|
||||
|
||||
@ -39,9 +39,10 @@ use reth_eth_wire::{
|
||||
DisconnectReason, EthVersion, Status,
|
||||
};
|
||||
use reth_net_common::bandwidth_meter::BandwidthMeter;
|
||||
use reth_network_api::{EthProtocolInfo, NetworkStatus, ReputationChangeKind};
|
||||
use reth_network_api::ReputationChangeKind;
|
||||
use reth_primitives::{NodeRecord, PeerId, H256};
|
||||
use reth_provider::BlockProvider;
|
||||
use reth_rpc_types::{EthProtocolInfo, NetworkStatus};
|
||||
use std::{
|
||||
net::SocketAddr,
|
||||
pin::Pin,
|
||||
|
||||
@ -11,9 +11,10 @@ use reth_interfaces::{
|
||||
};
|
||||
use reth_net_common::bandwidth_meter::BandwidthMeter;
|
||||
use reth_network_api::{
|
||||
NetworkError, NetworkInfo, NetworkStatus, PeerKind, Peers, PeersInfo, ReputationChangeKind,
|
||||
NetworkError, NetworkInfo, PeerKind, Peers, PeersInfo, ReputationChangeKind,
|
||||
};
|
||||
use reth_primitives::{Head, NodeRecord, PeerId, TransactionSigned, H256};
|
||||
use reth_rpc_types::NetworkStatus;
|
||||
use std::{
|
||||
net::SocketAddr,
|
||||
sync::{
|
||||
|
||||
@ -13,7 +13,6 @@ Reth RPC types
|
||||
# reth
|
||||
reth-primitives = { path = "../../primitives" }
|
||||
reth-rlp = { path = "../../rlp" }
|
||||
reth-network-api = { path = "../../net/network-api"}
|
||||
|
||||
# errors
|
||||
thiserror = "1.0"
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
use reth_network_api::{EthProtocolInfo, NetworkStatus};
|
||||
use reth_primitives::{NodeRecord, PeerId};
|
||||
use reth_primitives::{NodeRecord, PeerId, H256, U256};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
@ -64,6 +63,31 @@ pub struct Ports {
|
||||
pub listener: u16,
|
||||
}
|
||||
|
||||
/// The status of the network being ran by the local node.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct NetworkStatus {
|
||||
/// The local node client version.
|
||||
pub client_version: String,
|
||||
/// The current ethereum protocol version
|
||||
pub protocol_version: u64,
|
||||
/// Information about the Ethereum Wire Protocol.
|
||||
pub eth_protocol_info: EthProtocolInfo,
|
||||
}
|
||||
|
||||
/// Information about the Ethereum Wire Protocol (ETH)
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct EthProtocolInfo {
|
||||
/// The current difficulty at the head of the chain.
|
||||
#[serde(deserialize_with = "reth_primitives::serde_helper::deserialize_json_u256")]
|
||||
pub difficulty: U256,
|
||||
/// The block hash of the head of the chain.
|
||||
pub head: H256,
|
||||
/// Network ID in base 10.
|
||||
pub network: u64,
|
||||
/// Genesis block of the current chain.
|
||||
pub genesis: H256,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@ -70,14 +70,14 @@ pub struct PeerNetworkInfo {
|
||||
#[derive(Debug, Clone, Default, Serialize)]
|
||||
pub struct PeerProtocolsInfo {
|
||||
/// Ethereum protocol information
|
||||
pub eth: Option<EthProtocolInfo>,
|
||||
pub eth: Option<PeerEthProtocolInfo>,
|
||||
/// PIP protocol information.
|
||||
pub pip: Option<PipProtocolInfo>,
|
||||
}
|
||||
|
||||
/// Peer Ethereum protocol information
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||
pub struct EthProtocolInfo {
|
||||
pub struct PeerEthProtocolInfo {
|
||||
/// Negotiated ethereum protocol version
|
||||
pub version: u32,
|
||||
/// Peer total difficulty if known
|
||||
|
||||
Reference in New Issue
Block a user