evm_oracle_state/
config.rs1use alloy_primitives::Address;
2
3use crate::FeedId;
4
5#[derive(Clone, Debug)]
7pub struct FeedConfig {
8 pub proxy: Address,
10 pub id: Option<FeedId>,
12 pub label: Option<String>,
14 pub base: Option<String>,
16 pub quote: Option<String>,
18 pub staleness: StalenessPolicy,
20}
21
22impl Default for FeedConfig {
23 fn default() -> Self {
24 Self {
25 proxy: Address::ZERO,
26 id: None,
27 label: None,
28 base: None,
29 quote: None,
30 staleness: StalenessPolicy::default(),
31 }
32 }
33}
34
35#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
37pub struct StalenessPolicy {
38 max_age_secs: Option<u64>,
39 allow_zero_or_negative_answer: bool,
40}
41
42impl StalenessPolicy {
43 pub fn max_age(max_age_secs: u64) -> Self {
45 Self {
46 max_age_secs: Some(max_age_secs),
47 allow_zero_or_negative_answer: false,
48 }
49 }
50
51 pub fn allow_zero_or_negative_answer(mut self, allow: bool) -> Self {
53 self.allow_zero_or_negative_answer = allow;
54 self
55 }
56
57 pub(crate) fn max_age_secs(&self) -> Option<u64> {
58 self.max_age_secs
59 }
60
61 pub(crate) fn allows_zero_or_negative_answer(&self) -> bool {
62 self.allow_zero_or_negative_answer
63 }
64}