Builds the discovery driver from the CLI arguments.
(
&self,
chain_id: u64,
)
| 222 | |
| 223 | /// Builds the discovery driver from the CLI arguments. |
| 224 | pub fn discovery_driver( |
| 225 | &self, |
| 226 | chain_id: u64, |
| 227 | ) -> eyre::Result<base_consensus_disc::Discv5Driver> { |
| 228 | let keypair = self.keypair(chain_id)?; |
| 229 | let local_node_key = Self::local_node_key(keypair)?; |
| 230 | let advertised = self.advertised_node(local_node_key); |
| 231 | let discovery_config = self.discovery_config(); |
| 232 | let bootstore = self.bootstore(chain_id); |
| 233 | let bootnodes = self.bootnodes()?; |
| 234 | |
| 235 | let mut builder = Discv5Builder::new(advertised, chain_id, discovery_config) |
| 236 | .with_bootstore_file(bootstore) |
| 237 | .with_bootnodes(bootnodes) |
| 238 | .with_interval(Duration::from_secs(self.discovery_interval)) |
| 239 | .disable_forward(); |
| 240 | |
| 241 | if let Some(randomize) = self.discovery_randomize { |
| 242 | builder = builder.with_discovery_randomize(Some(Duration::from_secs(randomize))); |
| 243 | } |
| 244 | |
| 245 | builder.build().map_err(Into::into) |
| 246 | } |
| 247 | |
| 248 | /// Builds the local bootnode ENR without starting the discovery service. |
| 249 | pub fn local_enr(&self, chain_id: u64) -> eyre::Result<Enr> { |
no test coverage detected