-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: extract configuration types to reth-network-types
#9136
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perfect