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

This commit is contained in:
Serge Farny 2024-04-25 14:30:57 +02:00 committed by GitHub
parent ed715ce855
commit e4098b4550
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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> {