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

Method create_node

fendermint/testing/materializer/src/testnet.rs:275–346  ·  view source on GitHub ↗

Create the configuration of a node. Fails if the genesis hasn't been created yet.

(
        &mut self,
        m: &mut R,
        subnet_name: &SubnetName,
        node_id: &NodeId,
        node: &Node,
        env: &EnvMap,
        peer_count: usize,
    )

Source from the content-addressed store, hash-verified

273 ///
274 /// Fails if the genesis hasn't been created yet.
275 async fn create_node(
276 &mut self,
277 m: &mut R,
278 subnet_name: &SubnetName,
279 node_id: &NodeId,
280 node: &Node,
281 env: &EnvMap,
282 peer_count: usize,
283 ) -> anyhow::Result<()> {
284 let genesis = self.genesis(subnet_name)?;
285 let network = self.network();
286 let node_name = subnet_name.node(node_id);
287
288 let parent_node = match (subnet_name.parent(), &node.parent_node) {
289 (Some(ps), Some(ParentNode::Internal(id))) => {
290 let tc = TargetConfig::<M>::Internal(
291 self.node(&ps.node(id))
292 .with_context(|| format!("invalid parent node in {node_name:?}"))?,
293 );
294 let deployment = self.deployment(&ps)?;
295 Some(ParentConfig {
296 node: tc,
297 deployment,
298 })
299 }
300 (Some(ps), Some(ParentNode::External(url))) if ps.is_root() => {
301 let tc = TargetConfig::External(url.clone());
302 let deployment = self.deployment(&ps)?;
303 Some(ParentConfig {
304 node: tc,
305 deployment,
306 })
307 }
308 (Some(_), Some(ParentNode::External(_))) => {
309 bail!("node {node_name:?} specifies external URL for parent, but it's on a non-root subnet")
310 }
311 (None, Some(_)) => {
312 bail!("node {node_name:?} specifies parent node, but there is no parent subnet")
313 }
314 (Some(_), None) => {
315 bail!("node {node_name:?} is on a subnet, but doesn't specify a parent node")
316 }
317 _ => None,
318 };
319
320 let node_config = NodeConfig {
321 network,
322 genesis,
323 validator: match &node.mode {
324 NodeMode::Full => None,
325 NodeMode::Validator { validator } => {
326 let validator = self
327 .account(validator)
328 .with_context(|| format!("invalid validator in {node_name:?}"))?;
329 Some(validator)
330 }
331 },
332 parent_node,

Callers 1

Calls 10

genesisMethod · 0.80
with_contextMethod · 0.80
deploymentMethod · 0.80
contextMethod · 0.80
networkMethod · 0.45
nodeMethod · 0.45
parentMethod · 0.45
is_rootMethod · 0.45
accountMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected