Skip to content

Commit

Permalink
refactor: add discovery enr back to SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
neriumrevolta committed Dec 10, 2023
1 parent a7b1cdb commit 0b202aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 1 addition & 3 deletions examples/ping-pong/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ async fn main() {
// if not provided then they are usually generated based on indexer allocations
let subtopics: Vec<String> = vec!["ping-pong-content-topic".to_string()];

let discovery_enr = "enr:-P-4QJI8tS1WTdIQxq_yIrD05oIIW1Xg-tm_qfP0CHfJGnp9dfr6ttQJmHwTNxGEl4Le8Q7YHcmi-kXTtphxFysS11oBgmlkgnY0gmlwhLymh5GKbXVsdGlhZGRyc7hgAC02KG5vZGUtMDEuZG8tYW1zMy53YWt1djIucHJvZC5zdGF0dXNpbS5uZXQGdl8ALzYobm9kZS0wMS5kby1hbXMzLndha3V2Mi5wcm9kLnN0YXR1c2ltLm5ldAYfQN4DiXNlY3AyNTZrMaEDbl1X_zJIw3EAJGtmHMVn4Z2xhpSoUaP5ElsHKCv7hlWDdGNwgnZfg3VkcIIjKIV3YWt1Mg8".to_string();

// GraphcastAgentConfig defines the configuration that the SDK expects from all Radios, regardless of their specific functionality
let graphcast_agent_config = GraphcastAgentConfig::new(
config.private_key.expect("No private key provided"),
Expand All @@ -100,7 +98,7 @@ async fn main() {
config.waku_port,
None,
Some(false),
Some(vec![discovery_enr]),
None,
config.discv5_port,
)
.await
Expand Down
9 changes: 8 additions & 1 deletion src/graphcast_agent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ impl GraphcastAgentConfig {
let boot_node_addresses = convert_to_multiaddrs(&boot_node_addresses.unwrap_or_default())
.map_err(|_| GraphcastAgentError::ConvertMultiaddrError)?;

let mut discv5_enrs = discv5_enrs.unwrap_or_default();

if discv5_port.is_some() {
// Discovery network
discv5_enrs.push("enr:-P-4QJI8tS1WTdIQxq_yIrD05oIIW1Xg-tm_qfP0CHfJGnp9dfr6ttQJmHwTNxGEl4Le8Q7YHcmi-kXTtphxFysS11oBgmlkgnY0gmlwhLymh5GKbXVsdGlhZGRyc7hgAC02KG5vZGUtMDEuZG8tYW1zMy53YWt1djIucHJvZC5zdGF0dXNpbS5uZXQGdl8ALzYobm9kZS0wMS5kby1hbXMzLndha3V2Mi5wcm9kLnN0YXR1c2ltLm5ldAYfQN4DiXNlY3AyNTZrMaEDbl1X_zJIw3EAJGtmHMVn4Z2xhpSoUaP5ElsHKCv7hlWDdGNwgnZfg3VkcIIjKIV3YWt1Mg8".to_string());
}

let config = GraphcastAgentConfig {
wallet_key,
graph_account,
Expand All @@ -117,7 +124,7 @@ impl GraphcastAgentConfig {
waku_addr,
// Extra handling here to make sure the default behavior is filter protocol disabled
filter_protocol: Some(filter_protocol.unwrap_or(false)),
discv5_enrs: discv5_enrs.unwrap_or_default(),
discv5_enrs,
discv5_port,
};

Expand Down

0 comments on commit 0b202aa

Please sign in to comment.