Rpc: use rust convenient methods

(cherry picked from commit ac79ae6848)
This commit is contained in:
Kirill Fomichev
2021-09-27 11:57:23 +03:00
committed by Michael Vines
parent 36c283026f
commit a90c338982

View File

@@ -2977,7 +2977,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,
@@ -3874,7 +3874,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(