Skip to main content

light_client/indexer/
config.rs

1#[derive(Debug, Clone, PartialEq, Default)]
2pub struct IndexerRpcConfig {
3    pub slot: u64,
4    pub retry_config: RetryConfig,
5}
6impl IndexerRpcConfig {
7    pub fn new(slot: u64) -> Self {
8        Self {
9            slot,
10            retry_config: RetryConfig::default(),
11        }
12    }
13}
14
15#[derive(Debug, Clone, PartialEq)]
16pub struct RetryConfig {
17    pub num_retries: u32,
18    pub delay_ms: u64,
19    pub max_delay_ms: u64,
20}
21
22impl Default for RetryConfig {
23    fn default() -> Self {
24        Self {
25            num_retries: 10,
26            delay_ms: 400,
27            max_delay_ms: 8000,
28        }
29    }
30}
31
32#[cfg(test)]
33mod tests {
34    use super::*;
35
36    #[test]
37    fn test_retry_config_default_values() {
38        let config = RetryConfig::default();
39        assert_eq!(config.num_retries, 10);
40        assert_eq!(config.delay_ms, 400);
41        assert_eq!(config.max_delay_ms, 8000);
42    }
43
44    #[test]
45    fn test_indexer_rpc_config_new_sets_slot() {
46        let slot = 42u64;
47        let config = IndexerRpcConfig::new(slot);
48        assert_eq!(config.slot, slot);
49        assert_eq!(config.retry_config, RetryConfig::default());
50    }
51}