MCPcopy Create free account
hub / github.com/ChainSafe/Delorean-Protocol / port_range

Method port_range

fendermint/testing/materializer/src/docker/mod.rs:380–393  ·  view source on GitHub ↗

Pick a range for a container. Remember the choice so that we can recreate this materializer in a test and allocate more if needed without clashes.

(&mut self, node_name: &NodeName)

Source from the content-addressed store, hash-verified

378 /// Pick a range for a container. Remember the choice so that we can recreate
379 /// this materializer in a test and allocate more if needed without clashes.
380 fn port_range(&mut self, node_name: &NodeName) -> anyhow::Result<DockerPortRange> {
381 if let Some(range) = self.state.port_ranges.get(node_name) {
382 return Ok(range.clone());
383 }
384 // Currently the range allocations are not dropped from the materializer,
385 // so the length can be used to derive the next available port. Otherwise
386 // we could loop through to find an unused slot.
387 let node_count = self.state.port_ranges.len() as u32;
388 let from = PORT_RANGE_START + PORT_RANGE_SIZE * node_count;
389 let to = from + PORT_RANGE_SIZE;
390 let range = DockerPortRange { from, to };
391 self.update_state(|s| s.port_ranges.insert(node_name.clone(), range.clone()))?;
392 Ok(range)
393 }
394
395 fn ipc_dir(&self, testnet_name: &TestnetName) -> PathBuf {
396 self.path(testnet_name).join("ipc")

Callers 1

create_nodeMethod · 0.80

Calls 3

update_stateMethod · 0.80
getMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected