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

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