-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: refactor metrics strategy to support multiple subnetworks
- Loading branch information
1 parent
0e504ea
commit f1b9578
Showing
24 changed files
with
499 additions
and
393 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,52 @@ | ||
use std::net::SocketAddr; | ||
|
||
use ethereum_types::H256; | ||
|
||
use ethportal_api::types::bootnodes::Bootnodes; | ||
use ethportal_api::types::cli::TrinConfig; | ||
use ethportal_api::types::distance::Distance; | ||
|
||
/// Capacity of the cache for observed `NodeAddress` values. | ||
/// Provides capacity for 32 full k-buckets. This capacity will be shared among all active portal | ||
/// subnetworks. | ||
const NODE_ADDR_CACHE_CAPACITY: usize = discv5::kbucket::MAX_NODES_PER_BUCKET * 32; | ||
|
||
#[derive(Clone)] | ||
pub struct PortalnetConfig { | ||
pub external_addr: Option<SocketAddr>, | ||
pub private_key: H256, | ||
pub listen_port: u16, | ||
pub bootnodes: Bootnodes, | ||
pub data_radius: Distance, | ||
pub internal_ip: bool, | ||
pub no_stun: bool, | ||
pub node_addr_cache_capacity: usize, | ||
} | ||
|
||
impl Default for PortalnetConfig { | ||
fn default() -> Self { | ||
Self { | ||
external_addr: None, | ||
private_key: H256::random(), | ||
listen_port: 4242, | ||
bootnodes: Bootnodes::default(), | ||
data_radius: Distance::MAX, | ||
internal_ip: false, | ||
no_stun: false, | ||
node_addr_cache_capacity: NODE_ADDR_CACHE_CAPACITY, | ||
} | ||
} | ||
} | ||
|
||
impl PortalnetConfig { | ||
pub fn new(trin_config: &TrinConfig, private_key: H256) -> Self { | ||
Self { | ||
external_addr: trin_config.external_addr, | ||
private_key, | ||
listen_port: trin_config.discovery_port, | ||
no_stun: trin_config.no_stun, | ||
bootnodes: trin_config.bootnodes.clone(), | ||
..Default::default() | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#![warn(clippy::unwrap_used)] | ||
|
||
pub mod config; | ||
pub mod discovery; | ||
pub mod events; | ||
pub mod find; | ||
|
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
pub mod labels; | ||
pub mod overlay; | ||
pub mod portalnet; | ||
pub mod storage; |
Oops, something went wrong.