Skip to content

Commit

Permalink
address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickkuo committed Mar 16, 2022
1 parent cb25c08 commit 2c27da9
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions sui/src/rest_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,12 @@ struct ServerContext {
}

pub struct ServerState {
config: NetworkConfig,
gateway: GatewayClient,
keystore: Arc<RwLock<Box<dyn Keystore>>>,
// The fields below are for genesis and starting demo network.
// TODO: Remove these fields when we fully transform rest_server into GatewayServer.
addresses: Vec<SuiAddress>,
config: NetworkConfig,
keystore: Arc<RwLock<Box<dyn Keystore>>>,
working_dir: PathBuf,
// Server handles that will be used to restart authorities.
authority_handles: Vec<JoinHandle<()>>,
Expand Down Expand Up @@ -379,13 +381,7 @@ async fn sui_stop(
let server_context = rqctx.context();
// Taking state object without returning ownership
let mut state = server_context.server_state.lock().await;
let state = state.as_mut().ok_or_else(|| {
custom_http_error(
StatusCode::FAILED_DEPENDENCY,
"Server state does not exist. Please make a POST request to `sui/genesis/` and `sui/start/` to bootstrap the network."
.to_string(),
)
})?;
let state = state.as_mut().ok_or_else(server_state_error)?;

for authority_handle in &state.authority_handles {
authority_handle.abort();
Expand Down Expand Up @@ -752,7 +748,9 @@ async fn transfer_object(
{
Ok((cert, effects)) => {
let gas_used = match effects.status {
ExecutionStatus::Success { gas_used } => gas_used,
// TODO: handle the actual return value stored in
// ExecutionStatus::Success
ExecutionStatus::Success { gas_used, .. } => gas_used,
ExecutionStatus::Failure { gas_used, error } => {
return Err(custom_http_error(
StatusCode::FAILED_DEPENDENCY,
Expand Down Expand Up @@ -1149,7 +1147,9 @@ async fn handle_move_call(
{
Ok((cert, effects)) => {
let gas_used = match effects.status {
ExecutionStatus::Success { gas_used } => gas_used,
// TODO: handle the actual return value stored in
// ExecutionStatus::Success
ExecutionStatus::Success { gas_used, .. } => gas_used,
ExecutionStatus::Failure { gas_used, error } => {
let context = format!("Error calling move function, gas used {gas_used}");
return Err(anyhow::Error::new(error).context(context));
Expand Down

0 comments on commit 2c27da9

Please sign in to comment.