Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add get_account to BenchTpsClient #26068

Merged
merged 2 commits into from
Jun 21, 2022

Conversation

KirillLykov
Copy link
Contributor

Problem

There is no method get_account for BenchTpsClient which is needed for follow up PRs adding durable nonce transactions.

Summary of Changes

  • Adds get_account method

Comment on lines 88 to 97
let account = SyncClient::get_account(self, pubkey).map_err(|err| err.into());
if let Ok(account) = account {
if account.is_none() {
return Err(BenchTpsError::Custom("Account was not found".to_string()));
}
Ok(account.unwrap())
} else {
Err(account.err().unwrap())
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let account = SyncClient::get_account(self, pubkey).map_err(|err| err.into());
if let Ok(account) = account {
if account.is_none() {
return Err(BenchTpsError::Custom("Account was not found".to_string()));
}
Ok(account.unwrap())
} else {
Err(account.err().unwrap())
}
}
SyncClient::get_account(self, pubkey)
.map_err(|err| err.into())
.and_then(|account| account.ok_or(BenchTpsError::Custom("Account was not found".to_string())))

Simpler and more rust-y. (Suggestion probably needs formatting)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, could we emulate the logic in RpcClient::get_account so we don't have to have this one-off custom error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and_then looks cool, thanks!

@KirillLykov KirillLykov merged commit 4031a37 into solana-labs:master Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants