Add RpcClient::get_multiple_accounts_with_config()

This commit is contained in:
Michael Vines 2021-09-03 11:03:06 -07:00 committed by mergify[bot]
parent f7a5c0301a
commit ae43ca3bfb
1 changed files with 17 additions and 3 deletions

View File

@ -2965,11 +2965,25 @@ impl RpcClient {
&self,
pubkeys: &[Pubkey],
commitment_config: CommitmentConfig,
) -> RpcResult<Vec<Option<Account>>> {
self.get_multiple_accounts_with_config(
pubkeys,
RpcAccountInfoConfig {
encoding: Some(UiAccountEncoding::Base64Zstd),
commitment: Some(self.maybe_map_commitment(commitment_config)?),
data_slice: None,
},
)
}
pub fn get_multiple_accounts_with_config(
&self,
pubkeys: &[Pubkey],
config: RpcAccountInfoConfig,
) -> RpcResult<Vec<Option<Account>>> {
let config = RpcAccountInfoConfig {
encoding: Some(UiAccountEncoding::Base64Zstd),
commitment: Some(self.maybe_map_commitment(commitment_config)?),
data_slice: None,
commitment: config.commitment.or_else(|| Some(self.commitment())),
..config
};
let pubkeys: Vec<_> = pubkeys.iter().map(|pubkey| pubkey.to_string()).collect();
let response = self.send(RpcRequest::GetMultipleAccounts, json!([pubkeys, config]))?;