#State expiration behaviour

6 messages · Page 1 of 1 (latest)

marsh haven
#

Hi, I look at token example
pub fn read_balance(e: &Env, addr: Address) -> i128 { let key = DataKey::Balance(addr); if let Some(balance) = e.storage().persistent().get::<DataKey, i128>(&key) { e.storage() .persistent() .bump(&key, BALANCE_LIFETIME_THRESHOLD, BALANCE_BUMP_AMOUNT); balance } else { 0 } }
And I do not realize what will happen if the data is expired. Will it throw an error on the reading attempt? Or will it return zero? Or something else?
Thanks in advance.

pale sphinx
#

expired (or, as we are going to refer to it in the future 'archived') entries are not accessible until restored. if your transaction wants to access an expired entry, it will just fail immediately, before even getting to your contract logic

#

note, that the entries are not completely removed - they still influence the block hashes and thus can be restored if necessary

calm cradle
#

I think you'd get an error during simulation but i'm not sure, haven't actually tried making anything archive yet

mint zodiac
#

Simulation will still work even if is expired, it used to fail but with the current preview is working and it returns a value with the entries that need to be restored