-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
16f2284
commit 6d2394e
Showing
13 changed files
with
74 additions
and
65 deletions.
There are no files selected for viewing
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,56 @@ | ||
use std::net::SocketAddr; | ||
|
||
use ethereum_types::H256; | ||
|
||
use crate::metrics::overlay::OverlayMetrics; | ||
use crate::metrics::registry::METRICS_REGISTRY; | ||
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, | ||
pub metrics: OverlayMetrics, | ||
} | ||
|
||
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() | ||
} | ||
} | ||
} | ||
|
||
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, | ||
metrics: METRICS_REGISTRY.overlay.clone(), | ||
} | ||
} | ||
} |
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
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
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