/// Creates signed ingress messages to add a new blessed replica version and
/// potentially updates the subnet record with this replica version.
Creates signed ingress messages to add a new blessed replica version and
potentially updates the subnet record with this replica version.
Creates signed ingress messages to add a new blessed replica version and potentially updates the subnet record with this replica version .
pub fn cmd_add_and_bless_replica_version(
    agent: &Agent,
    player: &crate::Player,
    cmd: &AddAndBlessReplicaVersionCmd,
    context_time: Time,
) -> Result<Vec<SignedIngress>, String> {
    let replica_version_id = cmd.replica_version_id.clone();
    let replica_version_record =
        serde_json::from_str::<ReplicaVersionRecord>(&cmd.replica_version_value)
            .unwrap_or_else(|err| panic!("Error parsing replica version JSON value: {:?}", err));
    let mut msgs = vec![
        add_replica_version(
            agent,
            replica_version_id.clone(),
            replica_version_record,
            context_time,
        )?,
        bless_replica_version(agent, player, replica_version_id.clone(), context_time)?,
    ];
    if cmd.update_subnet_record {
        let mut subnet_record = player.get_subnet_record(context_time + Duration::from_secs(60))?;
        subnet_record.replica_version_id = replica_version_id;
        msgs.push(update_subnet_record(
            agent,
            player.subnet_id,
            subnet_record,
            context_time,
        )?);
    }
    Ok(msgs)
}
pub fn cmd_add_and_bless_replica_version ( agent : & Agent , player : & crate :: Player , cmd : & AddAndBlessReplicaVersionCmd , context_time : Time , ) -> Result < Vec < SignedIngress > , String > { let replica_version_id = cmd . replica_version_id . clone ( ) ; let replica_version_record = serde_json :: from_str :: < ReplicaVersionRecord > ( & cmd . replica_version_value ) . unwrap_or_else ( | err | panic ! ( " " err ) ) ; let mut msgs = vec ! [ add_replica_version ( agent replica_version_id clone ( ) replica_version_record context_time ) bless_replica_version ( agent player replica_version_id clone ( ) context_time ) ] ; if cmd . update_subnet_record { let mut subnet_record = player . get_subnet_record ( context_time + Duration :: from_secs ( 60 ) ) ? ; subnet_record . replica_version_id = replica_version_id ; msgs . push ( update_subnet_record ( agent , player . subnet_id , subnet_record , context_time , ) ? ) ; } Ok ( msgs ) }
Creates signed ingress messages to add a new blessed replica version and
potentially updates the subnet record with this replica version.
Creates signed ingress messages to add a new blessed replica version and potentially updates the subnet record with this replica version .
agent
&Agent
player
&crate::Player
cmd
&AddAndBlessReplicaVersionCmd
context_time
Time