Remove unnecessary Option from get_account_data

This commit is contained in:
Michael Vines 2019-03-16 08:54:22 -07:00
parent 4b04bc8612
commit ad252fe4c5
4 changed files with 5 additions and 6 deletions

View File

@ -53,14 +53,14 @@ impl RpcClient {
Ok(res)
}
pub fn get_account_data(&self, pubkey: &Pubkey) -> io::Result<Option<Vec<u8>>> {
pub fn get_account_data(&self, pubkey: &Pubkey) -> io::Result<Vec<u8>> {
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);

View File

@ -133,7 +133,7 @@ impl ThinClient {
result
}
pub fn get_account_data(&self, pubkey: &Pubkey) -> io::Result<Option<Vec<u8>>> {
pub fn get_account_data(&self, pubkey: &Pubkey) -> io::Result<Vec<u8>> {
self.rpc_client.get_account_data(pubkey)
}

View File

@ -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(());

View File

@ -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);