Contract: contracts/refund/src/lib.rs
Description
Analytics are recomputed from the full refund dataset on every call. In a live system with thousands of refunds, this is a several-hundred-millisecond operation that fails at scale. The result is deterministic for a given ledger range and can be cached.
Fix
Cache the analytics result under DataKey::AnalyticsCache(window_start, window_end) → Vec<(reason_code, count)>. Invalidate the cache only when a new refund is processed within that window.
Contract:
contracts/refund/src/lib.rsDescription
Analytics are recomputed from the full refund dataset on every call. In a live system with thousands of refunds, this is a several-hundred-millisecond operation that fails at scale. The result is deterministic for a given ledger range and can be cached.
Fix
Cache the analytics result under
DataKey::AnalyticsCache(window_start, window_end) → Vec<(reason_code, count)>. Invalidate the cache only when a new refund is processed within that window.