diff --git a/api/bin/chainflip-cli/src/main.rs b/api/bin/chainflip-cli/src/main.rs index a0e8fa7fbfa..f09155d46d9 100644 --- a/api/bin/chainflip-cli/src/main.rs +++ b/api/bin/chainflip-cli/src/main.rs @@ -124,7 +124,7 @@ async fn run_cli() -> Result<()> { VanityName { name } => { api.operator_api().set_vanity_name(name).await?; }, - CheckUpdate {} => get_update_state(api.query_api()).await?, + PreUpdateCheck {} => pre_update_check(api.query_api()).await?, ForceRotation {} => { api.governance_api().force_rotation().await?; }, @@ -292,8 +292,8 @@ async fn get_bound_executor_address(api: QueryApi) -> Result<()> { Ok(()) } -async fn get_update_state(api: QueryApi) -> Result<()> { - let can_update = api.get_update_state(None, None).await?; +async fn pre_update_check(api: QueryApi) -> Result<()> { + let can_update = api.pre_update_check(None, None).await?; if can_update { println!("You can safely update your node/engine"); } else { diff --git a/api/bin/chainflip-cli/src/settings.rs b/api/bin/chainflip-cli/src/settings.rs index 09a1fc621f9..2da3fc84dc2 100644 --- a/api/bin/chainflip-cli/src/settings.rs +++ b/api/bin/chainflip-cli/src/settings.rs @@ -151,7 +151,7 @@ pub enum CliCommand { name: String, }, #[clap(about = "Check if it is safe to update your node/engine")] - CheckUpdate {}, + PreUpdateCheck {}, #[clap( // This is only useful for testing. No need to show to the end user. hide = true, diff --git a/api/lib/src/queries.rs b/api/lib/src/queries.rs index 9afa1a53806..a5629ded694 100644 --- a/api/lib/src/queries.rs +++ b/api/lib/src/queries.rs @@ -145,14 +145,13 @@ impl QueryApi { .await?) } - pub async fn get_update_state( + pub async fn pre_update_check( &self, block_hash: Option, account_id: Option, ) -> Result { - let block_hash = - block_hash.unwrap_or_else(|| self.state_chain_client.latest_finalized_hash()); - let account_id = account_id.unwrap_or_else(|| self.state_chain_client.account_id()); + let block_hash = block_hash.unwrap_or(self.state_chain_client.latest_finalized_hash()); + let account_id = account_id.unwrap_or(self.state_chain_client.account_id()); if self .state_chain_client @@ -170,10 +169,9 @@ impl QueryApi { block_hash, ) .await?; - for validator in current_validators.iter() { - if account_id == *validator { - return Ok(false) - } + + if current_validators.contains(&account_id) { + return Ok(false) } Ok(true)