From ad252fe4c51f6b706714591d8131c3ea161ba999 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Sat, 16 Mar 2019 08:54:22 -0700 Subject: [PATCH] Remove unnecessary Option from get_account_data --- client/src/rpc_request.rs | 4 ++-- client/src/thin_client.rs | 2 +- core/src/local_cluster.rs | 2 +- tests/thin_client.rs | 3 +-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/client/src/rpc_request.rs b/client/src/rpc_request.rs index f1518258e..94af49a76 100644 --- a/client/src/rpc_request.rs +++ b/client/src/rpc_request.rs @@ -53,14 +53,14 @@ impl RpcClient { Ok(res) } - pub fn get_account_data(&self, pubkey: &Pubkey) -> io::Result>> { + pub fn get_account_data(&self, pubkey: &Pubkey) -> io::Result> { let params = json!([format!("{}", pubkey)]); let response = self.make_rpc_request(RpcRequest::GetAccountInfo, Some(params)); match response { Ok(account_json) => { let account: Account = serde_json::from_value(account_json).expect("deserialize account"); - Ok(Some(account.data)) + Ok(account.data) } Err(error) => { debug!("get_account_data failed: {:?}", error); diff --git a/client/src/thin_client.rs b/client/src/thin_client.rs index 74a657db1..9b39b6e46 100644 --- a/client/src/thin_client.rs +++ b/client/src/thin_client.rs @@ -133,7 +133,7 @@ impl ThinClient { result } - pub fn get_account_data(&self, pubkey: &Pubkey) -> io::Result>> { + pub fn get_account_data(&self, pubkey: &Pubkey) -> io::Result> { self.rpc_client.get_account_data(pubkey) } diff --git a/core/src/local_cluster.rs b/core/src/local_cluster.rs index 6d03f67a1..6c97ad300 100644 --- a/core/src/local_cluster.rs +++ b/core/src/local_cluster.rs @@ -251,7 +251,7 @@ impl LocalCluster { info!("Checking for vote account registration"); let vote_account_user_data = client.get_account_data(&vote_account_pubkey); - if let Ok(Some(vote_account_user_data)) = vote_account_user_data { + if let Ok(vote_account_user_data) = vote_account_user_data { if let Ok(vote_state) = VoteState::deserialize(&vote_account_user_data) { if vote_state.delegate_id == delegate_id { return Ok(()); diff --git a/tests/thin_client.rs b/tests/thin_client.rs index aa87303eb..0404d17d3 100644 --- a/tests/thin_client.rs +++ b/tests/thin_client.rs @@ -114,8 +114,7 @@ fn test_register_vote_account() { for run in 0..=LAST { let account_user_data = client .get_account_data(&vote_account_id) - .expect("Expected valid response for account data") - .expect("Expected valid account data to exist after account creation"); + .expect("Expected valid response for account data"); let vote_state = VoteState::deserialize(&account_user_data);