Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 21 additions & 29 deletions src/dfx/src/commands/canister/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use crate::lib::message::UserMessage;
use crate::util::print_idl_blob;
use clap::{App, Arg, ArgMatches, SubCommand};
use ic_http_agent::{Blob, RequestId};
use std::io::Write;
use std::time::{Duration, Instant};
use tokio::runtime::Runtime;

Expand Down Expand Up @@ -72,35 +71,28 @@ pub fn wait_on_request_status(client: &Client, request_id: RequestId) -> DfxResu
// the client work, and call again. We stop waiting after `REQUEST_TIMEOUT`.
loop {
response = runtime.block_on(request_status(client.clone(), request_id))?;
if response != ReadResponse::Unknown || start.elapsed() > REQUEST_TIMEOUT {
break;
} else {
std::thread::sleep(RETRY_PAUSE);
}
}

match response {
ReadResponse::Pending => {
eprint!("Request ID: ");
std::io::stderr().flush()?;
println!("0x{}", String::from(request_id));
Ok(())
}
ReadResponse::Replied { reply } => {
if let Some(QueryResponseReply { arg: blob }) = reply {
print_idl_blob(&blob)
.map_err(|e| DfxError::InvalidData(format!("Invalid IDL blob: {}", e)))?;
match response {
ReadResponse::Replied { reply } => {
if let Some(QueryResponseReply { arg: blob }) = reply {
print_idl_blob(&blob)
.map_err(|e| DfxError::InvalidData(format!("Invalid IDL blob: {}", e)))?;
}
return Ok(());
}
Ok(())
}
ReadResponse::Rejected {
reject_code,
reject_message,
} => Err(DfxError::ClientError(reject_code, reject_message)),
ReadResponse::Unknown => Err(DfxError::TimeoutWaitingForResponse(
request_id,
REQUEST_TIMEOUT,
)),
ReadResponse::Rejected {
reject_code,
reject_message,
} => return Err(DfxError::ClientError(reject_code, reject_message)),
ReadResponse::Pending => (),
ReadResponse::Unknown => (),
};
if start.elapsed() > REQUEST_TIMEOUT {
return Err(DfxError::TimeoutWaitingForResponse(
request_id,
REQUEST_TIMEOUT,
));
};
std::thread::sleep(RETRY_PAUSE);
}
}

Expand Down