MCPcopy Create free account
hub / github.com/consensus-shipyard/ipc / container_name

Function container_name

fendermint/testing/materializer/src/docker/node.rs:623–634  ·  view source on GitHub ↗

Create a container name from a node name and a logical container name, e.g. "cometbft" in a way that we can use it as a hostname without being too long. It consists of `{node-id}-{container}-{hash(node-name)}`, e.g. "node-12-cometbft-a1b2c3"

(node_name: &NodeName, container: &str)

Source from the content-addressed store, hash-verified

621/// It consists of `{node-id}-{container}-{hash(node-name)}`,
622/// e.g. "node-12-cometbft-a1b2c3"
623pub fn container_name(node_name: &NodeName, container: &str) -> String {
624 let node_id = node_name
625 .path()
626 .file_stem()
627 .unwrap_or_default()
628 .to_string_lossy()
629 .to_string();
630 let hash = ResourceHash::digest(node_name.path_string());
631 let hash = hash.to_string();
632 let hash = &hash.as_str()[..6];
633 format!("{node_id}-{container}-{}", hash)
634}
635
636/// Collect comma separated values from seeds nodes.
637fn collect_seeds<F>(seed_nodes: &[&DockerNode], f: F) -> anyhow::Result<String>

Callers 1

get_or_createMethod · 0.70

Calls 4

to_stringMethod · 0.80
path_stringMethod · 0.80
as_strMethod · 0.80
pathMethod · 0.45

Tested by

no test coverage detected