chore: add and fix more lints, improve docs (#4765)

This commit is contained in:
DaniPopes
2023-09-25 17:46:46 +02:00
committed by GitHub
parent b701cbc9a3
commit 8f9d2908ca
134 changed files with 709 additions and 625 deletions

View File

@ -113,6 +113,7 @@ impl<T> RethNodeCommandExt for T where T: RethNodeCommandConfig + fmt::Debug + c
///
/// This is a convenience type for [NoArgs<()>].
#[derive(Debug, Clone, Copy, Default, Args)]
#[non_exhaustive]
pub struct DefaultRethNodeCommandConfig;
impl RethNodeCommandConfig for DefaultRethNodeCommandConfig {}

View File

@ -81,7 +81,7 @@ impl<Ext: RethCliExt> Cli<Ext> {
let _guard = self.init_tracing()?;
let runner = CliRunner::default();
let runner = CliRunner;
match self.command {
Commands::Node(command) => runner.run_command_until_exit(|ctx| command.execute(ctx)),
Commands::Init(command) => runner.run_blocking_until_ctrl_c(command.execute()),

View File

@ -1,5 +1,4 @@
use clap::Parser;
use reth_db::{
database::Database,
table::Table,
@ -11,7 +10,6 @@ use reth_db::{
#[derive(Parser, Debug)]
pub struct Command {
/// Table name
#[arg()]
pub table: Tables,
}

View File

@ -10,7 +10,6 @@ pub struct Command {
/// The table name
///
/// NOTE: The dupsort tables are not supported now.
#[arg()]
pub table: Tables,
/// The key to get content for

View File

@ -60,7 +60,7 @@ pub fn logs_dir() -> Option<PathBuf> {
///
/// The data dir should contain a subdirectory for each chain, and those chain directories will
/// include all information for that chain, such as the p2p secret.
#[derive(Default, Debug, Clone)]
#[derive(Clone, Copy, Debug, Default)]
#[non_exhaustive]
pub struct DataDirPath;
@ -73,7 +73,7 @@ impl XdgPath for DataDirPath {
/// Returns the path to the reth logs directory.
///
/// Refer to [dirs_next::cache_dir] for cross-platform behavior.
#[derive(Default, Debug, Clone)]
#[derive(Clone, Copy, Debug, Default)]
#[non_exhaustive]
pub struct LogsDir;

View File

@ -1,10 +1,3 @@
#![warn(missing_docs, unreachable_pub, unused_crate_dependencies)]
#![deny(unused_must_use, rust_2018_idioms)]
#![doc(test(
no_crate_inject,
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
))]
//! Rust Ethereum (reth) binary executable.
//!
//! ## Feature Flags
@ -23,6 +16,15 @@
//! - `min-debug-logs`: Disables all logs below `debug` level.
//! - `min-trace-logs`: Disables all logs below `trace` level.
#![doc(
html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
issue_tracker_base_url = "https://github.com/paradigmxzy/reth/issues/"
)]
#![warn(missing_docs, unreachable_pub, rustdoc::all)]
#![deny(unused_must_use, rust_2018_idioms)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
pub mod args;
pub mod chain;
pub mod cli;

View File

@ -3,6 +3,7 @@
use futures::Stream;
use reth_provider::CanonChainTracker;
use std::{
fmt,
pin::Pin,
task::{ready, Context, Poll},
time::Duration,
@ -24,6 +25,12 @@ pub struct ConsensusLayerHealthEvents {
canon_chain: Box<dyn CanonChainTracker>,
}
impl fmt::Debug for ConsensusLayerHealthEvents {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ConsensusLayerHealthEvents").field("interval", &self.interval).finish()
}
}
impl ConsensusLayerHealthEvents {
/// Creates a new [ConsensusLayerHealthEvents] with the given canonical chain tracker.
pub fn new(canon_chain: Box<dyn CanonChainTracker>) -> Self {
@ -78,7 +85,7 @@ impl Stream for ConsensusLayerHealthEvents {
/// Event that is triggered when Consensus Layer health is degraded from the
/// Execution Layer point of view.
#[derive(Debug)]
#[derive(Clone, Copy, Debug)]
pub enum ConsensusLayerHealthEvent {
/// Consensus Layer client was never seen.
NeverSeen,

View File

@ -84,8 +84,8 @@ pub struct Command {
command: Subcommands,
}
#[derive(Subcommand, Debug)]
/// `reth p2p` subcommands
#[derive(Subcommand, Debug)]
pub enum Subcommands {
/// Download block header
Header {

View File

@ -5,8 +5,8 @@ use reth_tasks::{TaskExecutor, TaskManager};
use std::future::Future;
use tracing::trace;
/// Used to execute cli commands
#[derive(Default, Debug)]
/// Executes CLI commands.
#[derive(Clone, Debug, Default)]
#[non_exhaustive]
pub struct CliRunner;