Rpc: use rust convenient methods

This commit is contained in:
Kirill Fomichev 2021-09-27 11:57:23 +03:00 committed by Michael Vines
parent 49e85afdcd
commit ac79ae6848
1 changed files with 2 additions and 2 deletions

View File

@ -2993,7 +2993,7 @@ impl RpcClient {
} = serde_json::from_value::<Response<Vec<Option<UiAccount>>>>(response)?;
let accounts: Vec<Option<Account>> = accounts
.into_iter()
.map(|rpc_account| rpc_account.map(|a| a.decode()).flatten())
.map(|rpc_account| rpc_account.and_then(|a| a.decode()))
.collect();
Ok(Response {
context,
@ -4025,7 +4025,7 @@ fn parse_keyed_accounts(
accounts: Vec<RpcKeyedAccount>,
request: RpcRequest,
) -> ClientResult<Vec<(Pubkey, Account)>> {
let mut pubkey_accounts: Vec<(Pubkey, Account)> = Vec::new();
let mut pubkey_accounts: Vec<(Pubkey, Account)> = Vec::with_capacity(accounts.len());
for RpcKeyedAccount { pubkey, account } in accounts.into_iter() {
let pubkey = pubkey.parse().map_err(|_| {
ClientError::new_with_request(