diff --git a/cmd/soroban-rpc/lib/preflight/src/ledger_storage.rs b/cmd/soroban-rpc/lib/preflight/src/ledger_storage.rs index 80c07bc5d..51f37ee17 100644 --- a/cmd/soroban-rpc/lib/preflight/src/ledger_storage.rs +++ b/cmd/soroban-rpc/lib/preflight/src/ledger_storage.rs @@ -189,24 +189,6 @@ impl LedgerStorage { Ok((entry, expiration_seq)) } - fn get_including_persistent_expired( - &self, - key: &LedgerKey, - ) -> Result<(LedgerEntry, Option), Error> { - let entry_and_expiration = self.get(key, true)?; - // Explicitly discard temporary expired entries - if let Ok(expirable_entry) = - TryInto::>::try_into(&entry_and_expiration) - { - if expirable_entry.durability() == Temporary - && expirable_entry.has_expired(self.current_ledger_sequence) - { - return Err(Error::NotFound); - } - } - Ok(entry_and_expiration) - } - pub(crate) fn get_xdr(&self, key: &LedgerKey, include_expired: bool) -> Result, Error> { // TODO: this can be optimized since for entry types other than ContractCode/ContractData, // they don't need to be deserialized and serialized again @@ -246,9 +228,17 @@ impl LedgerStorage { impl SnapshotSource for LedgerStorage { fn get(&self, key: &Rc) -> Result<(Rc, Option), HostError> { if let Some(ref tracker) = self.restore_tracker { - let mut entry_and_expiration = self - .get_including_persistent_expired(key) - .map_err(HostError::from)?; + let mut entry_and_expiration = self.get(key, true)?; + // Explicitly discard temporary expired entries + if let Ok(expirable_entry) = + TryInto::>::try_into(&entry_and_expiration) + { + if expirable_entry.durability() == Temporary + && expirable_entry.has_expired(self.current_ledger_sequence) + { + return Err(HostError::from(Error::NotFound)); + } + } // If the entry expired, we modify the expiration to make it seem like it was restored entry_and_expiration.1 = tracker.track_and_restore(self.current_ledger_sequence, key, &entry_and_expiration);