Skip to content

Commit 7467aee

Browse files
committed
fix: extend storage TTL on every invoice save
Soroban persistent storage entries expire if TTL is not extended. Recurring and long-lived invoices risk becoming inaccessible. Set min_ttl=100_000 ledgers, max_ttl=6_307_200 (~1 year at 5s/ledger) on every save_invoice call. Closes #5
1 parent cdc648d commit 7467aee

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Rust
22
target
3-
sharpy
4-
test_snapshots//
3+
/sharpy
4+
test_snapshots/
55
Cargo.lock
66
*.rlib
77
*.so

contracts/sharpy/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ fn load_invoice(env: &Env, id: u64) -> Invoice {
4343

4444
fn save_invoice(env: &Env, id: u64, invoice: &Invoice) {
4545
env.storage().persistent().set(&invoice_key(id), invoice);
46+
// Extend TTL to ~1 year (in ledgers at ~5s each: 365*24*3600/5 = 6_307_200)
47+
env.storage().persistent().extend_ttl(&invoice_key(id), 100_000, 6_307_200);
4648
}
4749

4850
fn append_audit(env: &Env, id: u64, action: Symbol, actor: &Address) {

0 commit comments

Comments
 (0)