forked from SiLioLabs/PayFlow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmin_interval.rs
More file actions
24 lines (20 loc) · 714 Bytes
/
Copy pathmin_interval.rs
File metadata and controls
24 lines (20 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use soroban_sdk::Env;
use crate::events;
use crate::DataKey;
pub const DEFAULT_MIN_INTERVAL: u64 = 3600; // 1 hour
/// Returns the minimum allowed subscription interval in seconds.
/// Defaults to 3600 (1 hour) when unset.
pub fn get_min_interval(env: &Env) -> u64 {
env.storage()
.instance()
.get(&DataKey::MinInterval)
.unwrap_or(DEFAULT_MIN_INTERVAL)
}
/// Persists the minimum interval floor to instance storage and emits min_interval_set event.
pub fn set_min_interval(env: &Env, seconds: u64) {
let old = get_min_interval(env);
env.storage()
.instance()
.set(&DataKey::MinInterval, &seconds);
events::publish_min_interval_set(env, old, seconds);
}