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)
| 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") |
no test coverage detected