RustClient: propagate error in chain data fetcher instead of panicking (#952)

(cherry picked from commit e4098b4550)
This commit is contained in:
Serge Farny 2024-04-25 14:30:57 +02:00
parent f4c6a086c1
commit 36feea23b7
1 changed files with 4 additions and 3 deletions

View File

@ -248,10 +248,11 @@ impl crate::AccountFetcher for AccountFetcher {
keys: &[Pubkey],
) -> anyhow::Result<Vec<(Pubkey, AccountSharedData)>> {
let chain_data = self.chain_data.read().unwrap();
Ok(keys
let result = keys
.iter()
.map(|pk| (*pk, chain_data.account(pk).unwrap().account.clone()))
.collect::<Vec<_>>())
.map(|pk| chain_data.account(pk).map(|x| (*pk, x.account.clone())))
.collect::<anyhow::Result<Vec<_>>>();
result
}
async fn get_slot(&self) -> anyhow::Result<u64> {