mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 02:49:55 +00:00
fmt: format doc comments (#5308)
This commit is contained in:
@ -153,8 +153,7 @@ where
|
|||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use reth::cli::components::RethRpcServerHandles;
|
/// use reth::{cli::components::RethRpcServerHandles, rpc::api::EthApiClient};
|
||||||
/// use reth::rpc::api::EthApiClient;
|
|
||||||
/// # async fn t(handles: RethRpcServerHandles) {
|
/// # async fn t(handles: RethRpcServerHandles) {
|
||||||
/// let client = handles.rpc.http_client().expect("http server not started");
|
/// let client = handles.rpc.http_client().expect("http server not started");
|
||||||
/// let block_number = client.block_number().await.unwrap();
|
/// let block_number = client.block_number().await.unwrap();
|
||||||
|
|||||||
@ -94,7 +94,7 @@ pub trait XdgPath {
|
|||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use reth::dirs::{PlatformPath, DataDirPath};
|
/// use reth::dirs::{DataDirPath, PlatformPath};
|
||||||
/// use std::str::FromStr;
|
/// use std::str::FromStr;
|
||||||
///
|
///
|
||||||
/// // Resolves to the platform-specific database path
|
/// // Resolves to the platform-specific database path
|
||||||
|
|||||||
@ -56,13 +56,11 @@ pub fn base_block_reward(
|
|||||||
/// let total_difficulty = U256::from(2_235_668_675_900usize);
|
/// let total_difficulty = U256::from(2_235_668_675_900usize);
|
||||||
/// let number_of_ommers = 1;
|
/// let number_of_ommers = 1;
|
||||||
///
|
///
|
||||||
/// let reward = base_block_reward(&MAINNET, block_number, block_difficulty, total_difficulty).map(|reward| block_reward(reward, 1));
|
/// let reward = base_block_reward(&MAINNET, block_number, block_difficulty, total_difficulty)
|
||||||
|
/// .map(|reward| block_reward(reward, 1));
|
||||||
///
|
///
|
||||||
/// // The base block reward is 5 ETH, and the ommer inclusion reward is 1/32th of 5 ETH.
|
/// // The base block reward is 5 ETH, and the ommer inclusion reward is 1/32th of 5 ETH.
|
||||||
/// assert_eq!(
|
/// assert_eq!(reward.unwrap(), ETH_TO_WEI * 5 + ((ETH_TO_WEI * 5) >> 5));
|
||||||
/// reward.unwrap(),
|
|
||||||
/// ETH_TO_WEI * 5 + ((ETH_TO_WEI * 5) >> 5)
|
|
||||||
/// );
|
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// # References
|
/// # References
|
||||||
|
|||||||
@ -28,8 +28,8 @@ mod with_attrs;
|
|||||||
///
|
///
|
||||||
/// Sample usage:
|
/// Sample usage:
|
||||||
/// ```
|
/// ```
|
||||||
/// use reth_metrics_derive::Metrics;
|
|
||||||
/// use metrics::{Counter, Gauge, Histogram};
|
/// use metrics::{Counter, Gauge, Histogram};
|
||||||
|
/// use reth_metrics_derive::Metrics;
|
||||||
///
|
///
|
||||||
/// #[derive(Metrics)]
|
/// #[derive(Metrics)]
|
||||||
/// #[metrics(scope = "metrics_custom")]
|
/// #[metrics(scope = "metrics_custom")]
|
||||||
@ -43,7 +43,7 @@ mod with_attrs;
|
|||||||
/// counter: Counter,
|
/// counter: Counter,
|
||||||
/// /// A renamed histogram.
|
/// /// A renamed histogram.
|
||||||
/// #[metric(rename = "histogram")]
|
/// #[metric(rename = "histogram")]
|
||||||
/// histo: Histogram
|
/// histo: Histogram,
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
@ -56,7 +56,7 @@ mod with_attrs;
|
|||||||
/// /// Some doc comment
|
/// /// Some doc comment
|
||||||
/// counter: metrics::Counter,
|
/// counter: metrics::Counter,
|
||||||
/// /// A renamed histogram.
|
/// /// A renamed histogram.
|
||||||
/// histo: metrics::Histogram
|
/// histo: metrics::Histogram,
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// impl Default for CustomMetrics {
|
/// impl Default for CustomMetrics {
|
||||||
@ -73,9 +73,18 @@ mod with_attrs;
|
|||||||
/// impl CustomMetrics {
|
/// impl CustomMetrics {
|
||||||
/// /// Describe all exposed metrics
|
/// /// Describe all exposed metrics
|
||||||
/// pub fn describe() {
|
/// pub fn describe() {
|
||||||
/// metrics::describe_gauge!("metrics_custom_gauge", "A gauge with doc comment description.");
|
/// metrics::describe_gauge!(
|
||||||
/// metrics::describe_gauge!("metrics_custom_second_gauge", "A gauge with metric attribute description.");
|
/// "metrics_custom_gauge",
|
||||||
/// metrics::describe_counter!("metrics_custom_counter", "Metric attribute description will be preferred over doc comment.");
|
/// "A gauge with doc comment description."
|
||||||
|
/// );
|
||||||
|
/// metrics::describe_gauge!(
|
||||||
|
/// "metrics_custom_second_gauge",
|
||||||
|
/// "A gauge with metric attribute description."
|
||||||
|
/// );
|
||||||
|
/// metrics::describe_counter!(
|
||||||
|
/// "metrics_custom_counter",
|
||||||
|
/// "Metric attribute description will be preferred over doc comment."
|
||||||
|
/// );
|
||||||
/// metrics::describe_histogram!("metrics_custom_histogram", "A renamed histogram.");
|
/// metrics::describe_histogram!("metrics_custom_histogram", "A renamed histogram.");
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
@ -110,13 +119,14 @@ mod with_attrs;
|
|||||||
///
|
///
|
||||||
/// impl DynamicScopeMetrics {
|
/// impl DynamicScopeMetrics {
|
||||||
/// pub fn new(scope: &str) -> Self {
|
/// pub fn new(scope: &str) -> Self {
|
||||||
/// Self {
|
/// Self { gauge: metrics::register_gauge!(format!("{}{}{}", scope, "_", "gauge")) }
|
||||||
/// gauge: metrics::register_gauge!(format!("{}{}{}", scope, "_", "gauge"))
|
|
||||||
/// }
|
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// pub fn describe(scope: &str) {
|
/// pub fn describe(scope: &str) {
|
||||||
/// metrics::describe_gauge!(format!("{}{}{}", scope, "_", "gauge"), "A gauge with doc comment description.");
|
/// metrics::describe_gauge!(
|
||||||
|
/// format!("{}{}{}", scope, "_", "gauge"),
|
||||||
|
/// "A gauge with doc comment description."
|
||||||
|
/// );
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
|
|||||||
@ -193,12 +193,11 @@ impl Discv4 {
|
|||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use std::io;
|
/// # use std::io;
|
||||||
/// use std::net::SocketAddr;
|
|
||||||
/// use std::str::FromStr;
|
|
||||||
/// use rand::thread_rng;
|
/// use rand::thread_rng;
|
||||||
/// use secp256k1::SECP256K1;
|
|
||||||
/// use reth_primitives::{NodeRecord, PeerId};
|
|
||||||
/// use reth_discv4::{Discv4, Discv4Config};
|
/// use reth_discv4::{Discv4, Discv4Config};
|
||||||
|
/// use reth_primitives::{NodeRecord, PeerId};
|
||||||
|
/// use secp256k1::SECP256K1;
|
||||||
|
/// use std::{net::SocketAddr, str::FromStr};
|
||||||
/// # async fn t() -> io::Result<()> {
|
/// # async fn t() -> io::Result<()> {
|
||||||
/// // generate a (random) keypair
|
/// // generate a (random) keypair
|
||||||
/// let mut rng = thread_rng();
|
/// let mut rng = thread_rng();
|
||||||
@ -206,15 +205,11 @@ impl Discv4 {
|
|||||||
/// let id = PeerId::from_slice(&pk.serialize_uncompressed()[1..]);
|
/// let id = PeerId::from_slice(&pk.serialize_uncompressed()[1..]);
|
||||||
///
|
///
|
||||||
/// let socket = SocketAddr::from_str("0.0.0.0:0").unwrap();
|
/// let socket = SocketAddr::from_str("0.0.0.0:0").unwrap();
|
||||||
/// let local_enr = NodeRecord {
|
/// let local_enr =
|
||||||
/// address: socket.ip(),
|
/// NodeRecord { address: socket.ip(), tcp_port: socket.port(), udp_port: socket.port(), id };
|
||||||
/// tcp_port: socket.port(),
|
|
||||||
/// udp_port: socket.port(),
|
|
||||||
/// id,
|
|
||||||
/// };
|
|
||||||
/// let config = Discv4Config::default();
|
/// let config = Discv4Config::default();
|
||||||
///
|
///
|
||||||
/// let(discv4, mut service) = Discv4::bind(socket, local_enr, secret_key, config).await.unwrap();
|
/// let (discv4, mut service) = Discv4::bind(socket, local_enr, secret_key, config).await.unwrap();
|
||||||
///
|
///
|
||||||
/// // get an update strea
|
/// // get an update strea
|
||||||
/// let updates = service.update_stream();
|
/// let updates = service.update_stream();
|
||||||
|
|||||||
@ -118,11 +118,13 @@ impl<R: Resolver> DnsDiscoveryService<R> {
|
|||||||
/// Creates a new instance of the [DnsDiscoveryService] using the given settings.
|
/// Creates a new instance of the [DnsDiscoveryService] using the given settings.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::sync::Arc;
|
|
||||||
/// use reth_dns_discovery::{DnsDiscoveryService, DnsResolver};
|
/// use reth_dns_discovery::{DnsDiscoveryService, DnsResolver};
|
||||||
|
/// use std::sync::Arc;
|
||||||
/// # fn t() {
|
/// # fn t() {
|
||||||
/// let service =
|
/// let service = DnsDiscoveryService::new(
|
||||||
/// DnsDiscoveryService::new(Arc::new(DnsResolver::from_system_conf().unwrap()), Default::default());
|
/// Arc::new(DnsResolver::from_system_conf().unwrap()),
|
||||||
|
/// Default::default(),
|
||||||
|
/// );
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn new(resolver: Arc<R>, config: DnsDiscoveryConfig) -> Self {
|
pub fn new(resolver: Arc<R>, config: DnsDiscoveryConfig) -> Self {
|
||||||
|
|||||||
@ -42,18 +42,16 @@ impl TaskDownloader {
|
|||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use std::sync::Arc;
|
|
||||||
/// use reth_downloaders::bodies::bodies::BodiesDownloaderBuilder;
|
|
||||||
/// use reth_downloaders::bodies::task::TaskDownloader;
|
|
||||||
/// use reth_interfaces::consensus::Consensus;
|
|
||||||
/// use reth_interfaces::p2p::bodies::client::BodiesClient;
|
|
||||||
/// use reth_db::database::Database;
|
/// use reth_db::database::Database;
|
||||||
/// fn t<B: BodiesClient + 'static, DB: Database + 'static>(client: Arc<B>, consensus:Arc<dyn Consensus>, db: Arc<DB>) {
|
/// use reth_downloaders::bodies::{bodies::BodiesDownloaderBuilder, task::TaskDownloader};
|
||||||
/// let downloader = BodiesDownloaderBuilder::default().build(
|
/// use reth_interfaces::{consensus::Consensus, p2p::bodies::client::BodiesClient};
|
||||||
/// client,
|
/// use std::sync::Arc;
|
||||||
/// consensus,
|
/// fn t<B: BodiesClient + 'static, DB: Database + 'static>(
|
||||||
/// db
|
/// client: Arc<B>,
|
||||||
/// );
|
/// consensus: Arc<dyn Consensus>,
|
||||||
|
/// db: Arc<DB>,
|
||||||
|
/// ) {
|
||||||
|
/// let downloader = BodiesDownloaderBuilder::default().build(client, consensus, db);
|
||||||
/// let downloader = TaskDownloader::spawn(downloader);
|
/// let downloader = TaskDownloader::spawn(downloader);
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|||||||
@ -10,9 +10,8 @@ use reth_primitives::{Chain, ForkId, PeerId, B256, U256};
|
|||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```
|
/// ```
|
||||||
/// use reth_eth_wire::EthVersion;
|
/// use reth_eth_wire::{types::Status, EthVersion};
|
||||||
/// use reth_primitives::{Chain, U256, B256, MAINNET_GENESIS_HASH, MAINNET, Hardfork};
|
/// use reth_primitives::{Chain, Hardfork, B256, MAINNET, MAINNET_GENESIS_HASH, U256};
|
||||||
/// use reth_eth_wire::types::Status;
|
|
||||||
///
|
///
|
||||||
/// // this is just an example status message!
|
/// // this is just an example status message!
|
||||||
/// let status = Status::builder()
|
/// let status = Status::builder()
|
||||||
|
|||||||
@ -33,9 +33,9 @@ impl HelloMessage {
|
|||||||
/// Starts a new `HelloMessageBuilder`
|
/// Starts a new `HelloMessageBuilder`
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use secp256k1::{SECP256K1, SecretKey};
|
|
||||||
/// use reth_ecies::util::pk2id;
|
/// use reth_ecies::util::pk2id;
|
||||||
/// use reth_eth_wire::HelloMessage;
|
/// use reth_eth_wire::HelloMessage;
|
||||||
|
/// use secp256k1::{SecretKey, SECP256K1};
|
||||||
/// let secret_key = SecretKey::new(&mut rand::thread_rng());
|
/// let secret_key = SecretKey::new(&mut rand::thread_rng());
|
||||||
/// let id = pk2id(&secret_key.public_key(SECP256K1));
|
/// let id = pk2id(&secret_key.public_key(SECP256K1));
|
||||||
/// let status = HelloMessage::builder(id).build();
|
/// let status = HelloMessage::builder(id).build();
|
||||||
|
|||||||
@ -206,9 +206,7 @@ impl NetworkConfigBuilder {
|
|||||||
/// # use reth_network::NetworkConfigBuilder;
|
/// # use reth_network::NetworkConfigBuilder;
|
||||||
/// # fn builder(builder: NetworkConfigBuilder) {
|
/// # fn builder(builder: NetworkConfigBuilder) {
|
||||||
/// let peer_id = builder.get_peer_id();
|
/// let peer_id = builder.get_peer_id();
|
||||||
/// builder.hello_message(
|
/// builder.hello_message(HelloMessage::builder(peer_id).build());
|
||||||
/// HelloMessage::builder(peer_id).build()
|
|
||||||
/// );
|
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn hello_message(mut self, hello_message: HelloMessage) -> Self {
|
pub fn hello_message(mut self, hello_message: HelloMessage) -> Self {
|
||||||
|
|||||||
@ -46,10 +46,9 @@
|
|||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! # async fn launch() {
|
//! # async fn launch() {
|
||||||
//! use reth_network::config::rng_secret_key;
|
//! use reth_network::{config::rng_secret_key, NetworkConfig, NetworkManager};
|
||||||
//! use reth_network::{NetworkConfig, NetworkManager};
|
|
||||||
//! use reth_provider::test_utils::NoopProvider;
|
|
||||||
//! use reth_primitives::mainnet_nodes;
|
//! use reth_primitives::mainnet_nodes;
|
||||||
|
//! use reth_provider::test_utils::NoopProvider;
|
||||||
//!
|
//!
|
||||||
//! // This block provider implementation is used for testing purposes.
|
//! // This block provider implementation is used for testing purposes.
|
||||||
//! let client = NoopProvider::default();
|
//! let client = NoopProvider::default();
|
||||||
@ -57,9 +56,7 @@
|
|||||||
//! // The key that's used for encrypting sessions and to identify our node.
|
//! // The key that's used for encrypting sessions and to identify our node.
|
||||||
//! let local_key = rng_secret_key();
|
//! let local_key = rng_secret_key();
|
||||||
//!
|
//!
|
||||||
//! let config = NetworkConfig::builder(local_key).boot_nodes(
|
//! let config = NetworkConfig::builder(local_key).boot_nodes(mainnet_nodes()).build(client);
|
||||||
//! mainnet_nodes()
|
|
||||||
//! ).build(client);
|
|
||||||
//!
|
//!
|
||||||
//! // create the network instance
|
//! // create the network instance
|
||||||
//! let network = NetworkManager::new(config).await.unwrap();
|
//! let network = NetworkManager::new(config).await.unwrap();
|
||||||
@ -74,11 +71,10 @@
|
|||||||
//! ### Configure all components of the Network with the [`NetworkBuilder`]
|
//! ### Configure all components of the Network with the [`NetworkBuilder`]
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
|
//! use reth_network::{config::rng_secret_key, NetworkConfig, NetworkManager};
|
||||||
|
//! use reth_primitives::mainnet_nodes;
|
||||||
//! use reth_provider::test_utils::NoopProvider;
|
//! use reth_provider::test_utils::NoopProvider;
|
||||||
//! use reth_transaction_pool::TransactionPool;
|
//! use reth_transaction_pool::TransactionPool;
|
||||||
//! use reth_primitives::mainnet_nodes;
|
|
||||||
//! use reth_network::config::rng_secret_key;
|
|
||||||
//! use reth_network::{NetworkConfig, NetworkManager};
|
|
||||||
//! async fn launch<Pool: TransactionPool>(pool: Pool) {
|
//! async fn launch<Pool: TransactionPool>(pool: Pool) {
|
||||||
//! // This block provider implementation is used for testing purposes.
|
//! // This block provider implementation is used for testing purposes.
|
||||||
//! let client = NoopProvider::default();
|
//! let client = NoopProvider::default();
|
||||||
|
|||||||
@ -260,11 +260,10 @@ where
|
|||||||
/// components of the network
|
/// components of the network
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
/// use reth_network::{config::rng_secret_key, NetworkConfig, NetworkManager};
|
||||||
|
/// use reth_primitives::mainnet_nodes;
|
||||||
/// use reth_provider::test_utils::NoopProvider;
|
/// use reth_provider::test_utils::NoopProvider;
|
||||||
/// use reth_transaction_pool::TransactionPool;
|
/// use reth_transaction_pool::TransactionPool;
|
||||||
/// use reth_primitives::mainnet_nodes;
|
|
||||||
/// use reth_network::config::rng_secret_key;
|
|
||||||
/// use reth_network::{NetworkConfig, NetworkManager};
|
|
||||||
/// async fn launch<Pool: TransactionPool>(pool: Pool) {
|
/// async fn launch<Pool: TransactionPool>(pool: Pool) {
|
||||||
/// // This block provider implementation is used for testing purposes.
|
/// // This block provider implementation is used for testing purposes.
|
||||||
/// let client = NoopProvider::default();
|
/// let client = NoopProvider::default();
|
||||||
|
|||||||
@ -22,9 +22,7 @@ use std::{
|
|||||||
/// # let clique = async {
|
/// # let clique = async {
|
||||||
///
|
///
|
||||||
/// // this creates a funded geth
|
/// // this creates a funded geth
|
||||||
/// let clique_geth = Geth::new()
|
/// let clique_geth = Geth::new().p2p_port(30303).chain_id(1337u64);
|
||||||
/// .p2p_port(30303)
|
|
||||||
/// .chain_id(1337u64);
|
|
||||||
///
|
///
|
||||||
/// // build the funded geth, generating a random signing key and enabling clique
|
/// // build the funded geth, generating a random signing key and enabling clique
|
||||||
/// let mut clique = CliqueGethInstance::new(clique_geth, None).await;
|
/// let mut clique = CliqueGethInstance::new(clique_geth, None).await;
|
||||||
|
|||||||
@ -90,9 +90,8 @@ impl IpcTransportClientBuilder {
|
|||||||
/// Try to establish the connection.
|
/// Try to establish the connection.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use jsonrpsee::rpc_params;
|
/// use jsonrpsee::{core::client::ClientT, rpc_params};
|
||||||
/// use reth_ipc::client::IpcClientBuilder;
|
/// use reth_ipc::client::IpcClientBuilder;
|
||||||
/// use jsonrpsee::core::client::ClientT;
|
|
||||||
/// # async fn run_client() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
/// # async fn run_client() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||||
/// let client = IpcClientBuilder::default().build("/tmp/my-uds").await?;
|
/// let client = IpcClientBuilder::default().build("/tmp/my-uds").await?;
|
||||||
/// let response: String = client.request("say_hello", rpc_params![]).await?;
|
/// let response: String = client.request("say_hello", rpc_params![]).await?;
|
||||||
|
|||||||
@ -530,7 +530,6 @@ impl<B, L> Builder<B, L> {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
///
|
|
||||||
/// #[tokio::main]
|
/// #[tokio::main]
|
||||||
/// async fn main() {
|
/// async fn main() {
|
||||||
/// let builder = tower::ServiceBuilder::new();
|
/// let builder = tower::ServiceBuilder::new();
|
||||||
|
|||||||
@ -18,13 +18,30 @@
|
|||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use reth_network_api::{NetworkInfo, Peers};
|
//! use reth_network_api::{NetworkInfo, Peers};
|
||||||
//! use reth_provider::{AccountReader, BlockReaderIdExt, ChainSpecProvider, CanonStateSubscriptions, StateProviderFactory, EvmEnvProvider, ChangeSetReader};
|
//! use reth_provider::{
|
||||||
//! use reth_rpc_builder::{RethRpcModule, RpcModuleBuilder, RpcServerConfig, ServerBuilder, TransportRpcModuleConfig};
|
//! AccountReader, BlockReaderIdExt, CanonStateSubscriptions, ChainSpecProvider,
|
||||||
|
//! ChangeSetReader, EvmEnvProvider, StateProviderFactory,
|
||||||
|
//! };
|
||||||
|
//! use reth_rpc_builder::{
|
||||||
|
//! RethRpcModule, RpcModuleBuilder, RpcServerConfig, ServerBuilder, TransportRpcModuleConfig,
|
||||||
|
//! };
|
||||||
//! use reth_tasks::TokioTaskExecutor;
|
//! use reth_tasks::TokioTaskExecutor;
|
||||||
//! use reth_transaction_pool::TransactionPool;
|
//! use reth_transaction_pool::TransactionPool;
|
||||||
//! pub async fn launch<Provider, Pool, Network, Events>(provider: Provider, pool: Pool, network: Network, events: Events)
|
//! pub async fn launch<Provider, Pool, Network, Events>(
|
||||||
//! where
|
//! provider: Provider,
|
||||||
//! Provider: AccountReader + BlockReaderIdExt + ChainSpecProvider + ChangeSetReader + StateProviderFactory + EvmEnvProvider + Clone + Unpin + 'static,
|
//! pool: Pool,
|
||||||
|
//! network: Network,
|
||||||
|
//! events: Events,
|
||||||
|
//! ) where
|
||||||
|
//! Provider: AccountReader
|
||||||
|
//! + BlockReaderIdExt
|
||||||
|
//! + ChainSpecProvider
|
||||||
|
//! + ChangeSetReader
|
||||||
|
//! + StateProviderFactory
|
||||||
|
//! + EvmEnvProvider
|
||||||
|
//! + Clone
|
||||||
|
//! + Unpin
|
||||||
|
//! + 'static,
|
||||||
//! Pool: TransactionPool + Clone + 'static,
|
//! Pool: TransactionPool + Clone + 'static,
|
||||||
//! Network: NetworkInfo + Peers + Clone + 'static,
|
//! Network: NetworkInfo + Peers + Clone + 'static,
|
||||||
//! Events: CanonStateSubscriptions + Clone + 'static,
|
//! Events: CanonStateSubscriptions + Clone + 'static,
|
||||||
@ -36,7 +53,9 @@
|
|||||||
//! RethRpcModule::Eth,
|
//! RethRpcModule::Eth,
|
||||||
//! RethRpcModule::Web3,
|
//! RethRpcModule::Web3,
|
||||||
//! ]);
|
//! ]);
|
||||||
//! let transport_modules = RpcModuleBuilder::new(provider, pool, network, TokioTaskExecutor::default(), events).build(transports);
|
//! let transport_modules =
|
||||||
|
//! RpcModuleBuilder::new(provider, pool, network, TokioTaskExecutor::default(), events)
|
||||||
|
//! .build(transports);
|
||||||
//! let handle = RpcServerConfig::default()
|
//! let handle = RpcServerConfig::default()
|
||||||
//! .with_http(ServerBuilder::default())
|
//! .with_http(ServerBuilder::default())
|
||||||
//! .start(transport_modules)
|
//! .start(transport_modules)
|
||||||
@ -49,22 +68,40 @@
|
|||||||
//!
|
//!
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use tokio::try_join;
|
|
||||||
//! use reth_network_api::{NetworkInfo, Peers};
|
//! use reth_network_api::{NetworkInfo, Peers};
|
||||||
//! use reth_provider::{AccountReader, BlockReaderIdExt, ChainSpecProvider, CanonStateSubscriptions, StateProviderFactory, EvmEnvProvider, ChangeSetReader};
|
//! use reth_provider::{
|
||||||
|
//! AccountReader, BlockReaderIdExt, CanonStateSubscriptions, ChainSpecProvider,
|
||||||
|
//! ChangeSetReader, EvmEnvProvider, StateProviderFactory,
|
||||||
|
//! };
|
||||||
//! use reth_rpc::JwtSecret;
|
//! use reth_rpc::JwtSecret;
|
||||||
//! use reth_rpc_builder::{RethRpcModule, RpcModuleBuilder, RpcServerConfig, TransportRpcModuleConfig};
|
//! use reth_rpc_api::EngineApiServer;
|
||||||
|
//! use reth_rpc_builder::{
|
||||||
|
//! auth::AuthServerConfig, RethRpcModule, RpcModuleBuilder, RpcServerConfig,
|
||||||
|
//! TransportRpcModuleConfig,
|
||||||
|
//! };
|
||||||
//! use reth_tasks::TokioTaskExecutor;
|
//! use reth_tasks::TokioTaskExecutor;
|
||||||
//! use reth_transaction_pool::TransactionPool;
|
//! use reth_transaction_pool::TransactionPool;
|
||||||
//! use reth_rpc_api::EngineApiServer;
|
//! use tokio::try_join;
|
||||||
//! use reth_rpc_builder::auth::AuthServerConfig;
|
//! pub async fn launch<Provider, Pool, Network, Events, EngineApi>(
|
||||||
//! pub async fn launch<Provider, Pool, Network, Events, EngineApi>(provider: Provider, pool: Pool, network: Network, events: Events, engine_api: EngineApi)
|
//! provider: Provider,
|
||||||
//! where
|
//! pool: Pool,
|
||||||
//! Provider: AccountReader + BlockReaderIdExt + ChainSpecProvider + ChangeSetReader + StateProviderFactory + EvmEnvProvider + Clone + Unpin + 'static,
|
//! network: Network,
|
||||||
|
//! events: Events,
|
||||||
|
//! engine_api: EngineApi,
|
||||||
|
//! ) where
|
||||||
|
//! Provider: AccountReader
|
||||||
|
//! + BlockReaderIdExt
|
||||||
|
//! + ChainSpecProvider
|
||||||
|
//! + ChangeSetReader
|
||||||
|
//! + StateProviderFactory
|
||||||
|
//! + EvmEnvProvider
|
||||||
|
//! + Clone
|
||||||
|
//! + Unpin
|
||||||
|
//! + 'static,
|
||||||
//! Pool: TransactionPool + Clone + 'static,
|
//! Pool: TransactionPool + Clone + 'static,
|
||||||
//! Network: NetworkInfo + Peers + Clone + 'static,
|
//! Network: NetworkInfo + Peers + Clone + 'static,
|
||||||
//! Events: CanonStateSubscriptions + Clone + 'static,
|
//! Events: CanonStateSubscriptions + Clone + 'static,
|
||||||
//! EngineApi: EngineApiServer
|
//! EngineApi: EngineApiServer,
|
||||||
//! {
|
//! {
|
||||||
//! // configure the rpc module per transport
|
//! // configure the rpc module per transport
|
||||||
//! let transports = TransportRpcModuleConfig::default().with_http(vec![
|
//! let transports = TransportRpcModuleConfig::default().with_http(vec![
|
||||||
@ -73,20 +110,20 @@
|
|||||||
//! RethRpcModule::Eth,
|
//! RethRpcModule::Eth,
|
||||||
//! RethRpcModule::Web3,
|
//! RethRpcModule::Web3,
|
||||||
//! ]);
|
//! ]);
|
||||||
//! let builder = RpcModuleBuilder::new(provider, pool, network, TokioTaskExecutor::default(), events);
|
//! let builder =
|
||||||
|
//! RpcModuleBuilder::new(provider, pool, network, TokioTaskExecutor::default(), events);
|
||||||
//!
|
//!
|
||||||
//! // configure the server modules
|
//! // configure the server modules
|
||||||
//! let (modules, auth_module, _registry) = builder.build_with_auth_server(transports, engine_api);
|
//! let (modules, auth_module, _registry) =
|
||||||
|
//! builder.build_with_auth_server(transports, engine_api);
|
||||||
//!
|
//!
|
||||||
//! // start the servers
|
//! // start the servers
|
||||||
//! let auth_config = AuthServerConfig::builder(JwtSecret::random()).build();
|
//! let auth_config = AuthServerConfig::builder(JwtSecret::random()).build();
|
||||||
//! let config = RpcServerConfig::default();
|
//! let config = RpcServerConfig::default();
|
||||||
//!
|
//!
|
||||||
//! let (_rpc_handle, _auth_handle) = try_join!(
|
//! let (_rpc_handle, _auth_handle) =
|
||||||
//! modules.start_server(config),
|
//! try_join!(modules.start_server(config), auth_module.start_server(auth_config),)
|
||||||
//! auth_module.start_server(auth_config),
|
//! .unwrap();
|
||||||
//! ).unwrap();
|
|
||||||
//!
|
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
@ -518,7 +555,10 @@ impl RpcModuleSelection {
|
|||||||
/// use reth_rpc_builder::{RethRpcModule, RpcModuleSelection};
|
/// use reth_rpc_builder::{RethRpcModule, RpcModuleSelection};
|
||||||
/// let selection = vec!["eth", "admin"];
|
/// let selection = vec!["eth", "admin"];
|
||||||
/// let config = RpcModuleSelection::try_from_selection(selection).unwrap();
|
/// let config = RpcModuleSelection::try_from_selection(selection).unwrap();
|
||||||
/// assert_eq!(config, RpcModuleSelection::Selection(vec![RethRpcModule::Eth, RethRpcModule::Admin]));
|
/// assert_eq!(
|
||||||
|
/// config,
|
||||||
|
/// RpcModuleSelection::Selection(vec![RethRpcModule::Eth, RethRpcModule::Admin])
|
||||||
|
/// );
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Create a unique selection from the [RethRpcModule] string identifiers
|
/// Create a unique selection from the [RethRpcModule] string identifiers
|
||||||
@ -527,7 +567,10 @@ impl RpcModuleSelection {
|
|||||||
/// use reth_rpc_builder::{RethRpcModule, RpcModuleSelection};
|
/// use reth_rpc_builder::{RethRpcModule, RpcModuleSelection};
|
||||||
/// let selection = vec!["eth", "admin", "eth", "admin"];
|
/// let selection = vec!["eth", "admin", "eth", "admin"];
|
||||||
/// let config = RpcModuleSelection::try_from_selection(selection).unwrap();
|
/// let config = RpcModuleSelection::try_from_selection(selection).unwrap();
|
||||||
/// assert_eq!(config, RpcModuleSelection::Selection(vec![RethRpcModule::Eth, RethRpcModule::Admin]));
|
/// assert_eq!(
|
||||||
|
/// config,
|
||||||
|
/// RpcModuleSelection::Selection(vec![RethRpcModule::Eth, RethRpcModule::Admin])
|
||||||
|
/// );
|
||||||
/// ```
|
/// ```
|
||||||
pub fn try_from_selection<I, T>(selection: I) -> Result<Self, T::Error>
|
pub fn try_from_selection<I, T>(selection: I) -> Result<Self, T::Error>
|
||||||
where
|
where
|
||||||
@ -1433,8 +1476,8 @@ impl RpcServerConfig {
|
|||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use reth_rpc_builder::{RethRpcModule, TransportRpcModuleConfig};
|
/// use reth_rpc_builder::{RethRpcModule, TransportRpcModuleConfig};
|
||||||
/// let config = TransportRpcModuleConfig::default()
|
/// let config =
|
||||||
/// .with_http([RethRpcModule::Eth, RethRpcModule::Admin]);
|
/// TransportRpcModuleConfig::default().with_http([RethRpcModule::Eth, RethRpcModule::Admin]);
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Debug, Clone, Default, Eq, PartialEq)]
|
#[derive(Debug, Clone, Default, Eq, PartialEq)]
|
||||||
pub struct TransportRpcModuleConfig {
|
pub struct TransportRpcModuleConfig {
|
||||||
|
|||||||
@ -366,7 +366,8 @@ impl Filter {
|
|||||||
/// # use alloy_primitives::Address;
|
/// # use alloy_primitives::Address;
|
||||||
/// # use reth_rpc_types::Filter;
|
/// # use reth_rpc_types::Filter;
|
||||||
/// # fn main() {
|
/// # fn main() {
|
||||||
/// let filter = Filter::new().address("0xAc4b3DacB91461209Ae9d41EC517c2B9Cb1B7DAF".parse::<Address>().unwrap());
|
/// let filter = Filter::new()
|
||||||
|
/// .address("0xAc4b3DacB91461209Ae9d41EC517c2B9Cb1B7DAF".parse::<Address>().unwrap());
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
@ -377,7 +378,10 @@ impl Filter {
|
|||||||
/// # use alloy_primitives::Address;
|
/// # use alloy_primitives::Address;
|
||||||
/// # use reth_rpc_types::Filter;
|
/// # use reth_rpc_types::Filter;
|
||||||
/// # fn main() {
|
/// # fn main() {
|
||||||
/// let addresses = vec!["0xAc4b3DacB91461209Ae9d41EC517c2B9Cb1B7DAF".parse::<Address>().unwrap(),"0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8".parse::<Address>().unwrap()];
|
/// let addresses = vec![
|
||||||
|
/// "0xAc4b3DacB91461209Ae9d41EC517c2B9Cb1B7DAF".parse::<Address>().unwrap(),
|
||||||
|
/// "0x8ad599c3A0ff1De082011EFDDc58f1908eb6e6D8".parse::<Address>().unwrap(),
|
||||||
|
/// ];
|
||||||
/// let filter = Filter::new().address(addresses);
|
/// let filter = Filter::new().address(addresses);
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
|
|||||||
@ -23,7 +23,8 @@ use tower::{Layer, Service};
|
|||||||
///
|
///
|
||||||
/// const AUTH_PORT: u32 = 8551;
|
/// const AUTH_PORT: u32 = 8551;
|
||||||
/// const AUTH_ADDR: &str = "0.0.0.0";
|
/// const AUTH_ADDR: &str = "0.0.0.0";
|
||||||
/// const AUTH_SECRET: &str = "f79ae8046bc11c9927afe911db7143c51a806c4a537cc08e0d37140b0192f430";
|
/// const AUTH_SECRET: &str =
|
||||||
|
/// "f79ae8046bc11c9927afe911db7143c51a806c4a537cc08e0d37140b0192f430";
|
||||||
///
|
///
|
||||||
/// let addr = format!("{AUTH_ADDR}:{AUTH_PORT}");
|
/// let addr = format!("{AUTH_ADDR}:{AUTH_PORT}");
|
||||||
/// let secret = JwtSecret::from_hex(AUTH_SECRET).unwrap();
|
/// let secret = JwtSecret::from_hex(AUTH_SECRET).unwrap();
|
||||||
|
|||||||
@ -147,10 +147,7 @@ impl JwtSecret {
|
|||||||
/// ```rust
|
/// ```rust
|
||||||
/// use reth_rpc::{Claims, JwtSecret};
|
/// use reth_rpc::{Claims, JwtSecret};
|
||||||
///
|
///
|
||||||
/// let my_claims = Claims {
|
/// let my_claims = Claims { iat: 0, exp: None };
|
||||||
/// iat: 0,
|
|
||||||
/// exp: None
|
|
||||||
/// };
|
|
||||||
/// let secret = JwtSecret::random();
|
/// let secret = JwtSecret::random();
|
||||||
/// let token = secret.encode(&my_claims).unwrap();
|
/// let token = secret.encode(&my_claims).unwrap();
|
||||||
/// ```
|
/// ```
|
||||||
|
|||||||
@ -41,9 +41,13 @@
|
|||||||
//! # let pipeline =
|
//! # let pipeline =
|
||||||
//! Pipeline::builder()
|
//! Pipeline::builder()
|
||||||
//! .with_tip_sender(tip_tx)
|
//! .with_tip_sender(tip_tx)
|
||||||
//! .add_stages(
|
//! .add_stages(DefaultStages::new(
|
||||||
//! DefaultStages::new(HeaderSyncMode::Tip(tip_rx), consensus, headers_downloader, bodies_downloader, factory)
|
//! HeaderSyncMode::Tip(tip_rx),
|
||||||
//! )
|
//! consensus,
|
||||||
|
//! headers_downloader,
|
||||||
|
//! bodies_downloader,
|
||||||
|
//! factory,
|
||||||
|
//! ))
|
||||||
//! .build(db, MAINNET.clone());
|
//! .build(db, MAINNET.clone());
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
|
|||||||
@ -59,7 +59,7 @@ pub const NUM_TABLES: usize = 26;
|
|||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use reth_db::{ table::Table, TableViewer, Tables };
|
/// use reth_db::{table::Table, TableViewer, Tables};
|
||||||
/// use std::str::FromStr;
|
/// use std::str::FromStr;
|
||||||
///
|
///
|
||||||
/// let headers = Tables::from_str("Headers").unwrap();
|
/// let headers = Tables::from_str("Headers").unwrap();
|
||||||
|
|||||||
@ -162,9 +162,9 @@ impl BundleStateWithReceipts {
|
|||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use reth_primitives::{Account, U256, Receipts};
|
/// use reth_db::{database::Database, test_utils::create_test_rw_db};
|
||||||
|
/// use reth_primitives::{Account, Receipts, U256};
|
||||||
/// use reth_provider::BundleStateWithReceipts;
|
/// use reth_provider::BundleStateWithReceipts;
|
||||||
/// use reth_db::{test_utils::create_test_rw_db, database::Database};
|
|
||||||
/// use std::collections::HashMap;
|
/// use std::collections::HashMap;
|
||||||
///
|
///
|
||||||
/// // Initialize the database
|
/// // Initialize the database
|
||||||
@ -173,7 +173,7 @@ impl BundleStateWithReceipts {
|
|||||||
/// // Initialize the bundle state
|
/// // Initialize the bundle state
|
||||||
/// let bundle = BundleStateWithReceipts::new_init(
|
/// let bundle = BundleStateWithReceipts::new_init(
|
||||||
/// HashMap::from([(
|
/// HashMap::from([(
|
||||||
/// [0x11;20].into(),
|
/// [0x11; 20].into(),
|
||||||
/// (
|
/// (
|
||||||
/// None,
|
/// None,
|
||||||
/// Some(Account { nonce: 1, balance: U256::from(10), bytecode_hash: None }),
|
/// Some(Account { nonce: 1, balance: U256::from(10), bytecode_hash: None }),
|
||||||
|
|||||||
@ -279,15 +279,21 @@ where
|
|||||||
/// # Example
|
/// # Example
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// use reth_provider::StateProviderFactory;
|
|
||||||
/// use reth_primitives::MAINNET;
|
/// use reth_primitives::MAINNET;
|
||||||
|
/// use reth_provider::StateProviderFactory;
|
||||||
/// use reth_tasks::TokioTaskExecutor;
|
/// use reth_tasks::TokioTaskExecutor;
|
||||||
/// use reth_transaction_pool::{TransactionValidationTaskExecutor, Pool};
|
/// use reth_transaction_pool::{
|
||||||
/// use reth_transaction_pool::blobstore::InMemoryBlobStore;
|
/// blobstore::InMemoryBlobStore, Pool, TransactionValidationTaskExecutor,
|
||||||
|
/// };
|
||||||
/// # fn t<C>(client: C) where C: StateProviderFactory + Clone + 'static {
|
/// # fn t<C>(client: C) where C: StateProviderFactory + Clone + 'static {
|
||||||
/// let blob_store = InMemoryBlobStore::default();
|
/// let blob_store = InMemoryBlobStore::default();
|
||||||
/// let pool = Pool::eth_pool(
|
/// let pool = Pool::eth_pool(
|
||||||
/// TransactionValidationTaskExecutor::eth(client, MAINNET.clone(), blob_store.clone(), TokioTaskExecutor::default()),
|
/// TransactionValidationTaskExecutor::eth(
|
||||||
|
/// client,
|
||||||
|
/// MAINNET.clone(),
|
||||||
|
/// blob_store.clone(),
|
||||||
|
/// TokioTaskExecutor::default(),
|
||||||
|
/// ),
|
||||||
/// blob_store,
|
/// blob_store,
|
||||||
/// Default::default(),
|
/// Default::default(),
|
||||||
/// );
|
/// );
|
||||||
|
|||||||
@ -7,3 +7,5 @@ binop_separator = "Back"
|
|||||||
trailing_comma = "Vertical"
|
trailing_comma = "Vertical"
|
||||||
trailing_semicolon = false
|
trailing_semicolon = false
|
||||||
use_field_init_shorthand = true
|
use_field_init_shorthand = true
|
||||||
|
format_code_in_doc_comments = true
|
||||||
|
doc_comment_code_block_width = 100
|
||||||
|
|||||||
Reference in New Issue
Block a user