rpc: get_feature_activation_slot should not error for inactive features (#32778)

This commit is contained in:
Ashwin Sekar 2023-08-09 18:28:47 -07:00 committed by GitHub
parent 85a9ebc0af
commit eae455c34b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 8 deletions

View File

@ -4029,15 +4029,22 @@ impl RpcClient {
} }
pub fn get_feature_activation_slot(&self, feature_id: &Pubkey) -> ClientResult<Option<Slot>> { pub fn get_feature_activation_slot(&self, feature_id: &Pubkey) -> ClientResult<Option<Slot>> {
self.get_account(feature_id) self.get_account_with_commitment(feature_id, self.commitment())
.and_then(|feature_account| { .and_then(|maybe_feature_account| {
bincode::deserialize(feature_account.data()).map_err(|_| { maybe_feature_account
ClientError::from(ErrorKind::Custom( .value
"Failed to deserialize feature account".to_string(), .map(|feature_account| {
)) bincode::deserialize(feature_account.data()).map_err(|_| {
}) ClientError::from(ErrorKind::Custom(
"Failed to deserialize feature account".to_string(),
))
})
})
.transpose()
})
.map(|maybe_feature: Option<Feature>| {
maybe_feature.and_then(|feature| feature.activated_at)
}) })
.map(|feature: Feature| feature.activated_at)
} }
fn invoke<T, F: std::future::Future<Output = ClientResult<T>>>(&self, f: F) -> ClientResult<T> { fn invoke<T, F: std::future::Future<Output = ClientResult<T>>>(&self, f: F) -> ClientResult<T> {