-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: extract configuration types to
reth-network-types
(#9136)
- Loading branch information
Showing
22 changed files
with
584 additions
and
504 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[package] | ||
name = "reth-network-types" | ||
version.workspace = true | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
license.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
description = "Commonly used network types" | ||
|
||
[lints] | ||
workspace = true | ||
|
||
[dependencies] | ||
# reth | ||
reth-network-api.workspace = true | ||
reth-network-peers.workspace = true | ||
reth-net-banlist.workspace = true | ||
|
||
# io | ||
serde = { workspace = true, optional = true } | ||
humantime-serde = { workspace = true, optional = true } | ||
serde_json = { workspace = true } | ||
|
||
# misc | ||
tracing.workspace = true | ||
|
||
[features] | ||
serde = ["dep:serde", "dep:humantime-serde"] | ||
test-utils = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/// Describes the type of backoff should be applied. | ||
#[derive(Debug, Clone, PartialEq, Eq)] | ||
pub enum BackoffKind { | ||
/// Use the lowest configured backoff duration. | ||
/// | ||
/// This applies to connection problems where there is a chance that they will be resolved | ||
/// after the short duration. | ||
Low, | ||
/// Use a slightly higher duration to put a peer in timeout | ||
/// | ||
/// This applies to more severe connection problems where there is a lower chance that they | ||
/// will be resolved. | ||
Medium, | ||
/// Use the max configured backoff duration. | ||
/// | ||
/// This is intended for spammers, or bad peers in general. | ||
High, | ||
} | ||
|
||
// === impl BackoffKind === | ||
|
||
impl BackoffKind { | ||
/// Returns true if the backoff is considered severe. | ||
pub const fn is_severe(&self) -> bool { | ||
matches!(self, Self::Medium | Self::High) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//! Commonly used networking types. | ||
//! | ||
//! ## Feature Flags | ||
//! | ||
//! - `serde` (default): Enable serde support | ||
#![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/paradigmxyz/reth/issues/" | ||
)] | ||
#![cfg_attr(not(test), warn(unused_crate_dependencies))] | ||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] | ||
|
||
/// Types related to peering. | ||
pub mod peers; | ||
pub use peers::{ConnectionsConfig, PeersConfig, ReputationChangeWeights}; | ||
|
||
pub mod session; | ||
pub use session::{SessionLimits, SessionsConfig}; | ||
|
||
/// [`BackoffKind`] definition. | ||
mod backoff; | ||
pub use backoff::BackoffKind; |
Oops, something went wrong.