/// Stops the given canister, and polls until the `Stopped` state is reached.
///
/// Warning: there's no guarantee that this ever finishes!
/// TODO(NNS-65)
Stops the given canister, and polls until the `Stopped` state is reached.
Warning: there's no guarantee that this ever finishes.
Stops the given canister and polls until the ` Stopped ` state is reached . Warning : there ' s no guarantee that this ever finishes .
async fn stop_canister(canister_id: CanisterId) {
    // stop_canister returns the candid empty type, which cannot be parsed using
    // dfn_candid::candid
    let res: Result<(), (Option<i32>, String)> = call(
        CanisterId::ic_00(),
        "stop_canister",
        dfn_candid::candid_multi_arity,
        (CanisterIdRecord::from(canister_id),),
    )
    .await;
    // Let's make sure this worked. We can abort if not.
    res.unwrap();
    // Now wait
    loop {
        let status: CanisterStatusResult = call(
            CanisterId::ic_00(),
            "canister_status",
            dfn_candid::candid,
            (CanisterIdRecord::from(canister_id),),
        )
        .await
        .unwrap();
        if status.status == CanisterStatusType::Stopped {
            return;
        }
        println!(
            "{}Waiting for {:?} to stop. Current status: {}",
            LOG_PREFIX, canister_id, status.status
        );
    }
}
async fn stop_canister ( canister_id : CanisterId ) { // stop_canister returns the candid empty type, which cannot be parsed using // dfn_candid::candid let res : Result < ( ) , ( Option < i32 > , String ) > = call ( CanisterId :: ic_00 ( ) , " " , dfn_candid :: candid_multi_arity , ( CanisterIdRecord :: from ( canister_id ) , ) , ) . await ; // Let's make sure this worked. We can abort if not. res . unwrap ( ) ; // Now wait loop { let status : CanisterStatusResult = call ( CanisterId :: ic_00 ( ) , " " , dfn_candid :: candid , ( CanisterIdRecord :: from ( canister_id ) , ) , ) . await . unwrap ( ) ; if status . status == CanisterStatusType :: Stopped { return ; } println ! ( " " LOG_PREFIX canister_id status status ) ; } }
Stops the given canister, and polls until the `Stopped` state is reached.
Stops the given canister and polls until the ` Stopped ` state is reached .
canister_id
CanisterId