openzeppelin_monitor/models/core/
network.rs

1use serde::{Deserialize, Serialize};
2
3use crate::models::{BlockChainType, SecretValue};
4
5/// Configuration for missed block recovery job.
6///
7/// Defines parameters for the background job that retries fetching and processing
8/// blocks that were missed during normal monitoring cycles.
9#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
10#[serde(deny_unknown_fields)]
11pub struct BlockRecoveryConfig {
12	/// Whether the recovery job is enabled
13	pub enabled: bool,
14
15	/// Cron schedule for the recovery job (e.g., "0 */5 * * * *" for every 5 minutes)
16	pub cron_schedule: String,
17
18	/// Maximum number of blocks to attempt recovery per execution
19	pub max_blocks_per_run: u64,
20
21	/// Maximum age of missed blocks to consider (in blocks from current)
22	/// Blocks older than this are pruned and not recovered
23	pub max_block_age: u64,
24
25	/// Maximum number of retry attempts per block before marking as failed
26	pub max_retries: u32,
27
28	/// Delay in milliseconds between retry attempts for failed blocks
29	pub retry_delay_ms: u64,
30}
31
32/// Configuration for connecting to and interacting with a blockchain network.
33///
34/// Defines connection details and operational parameters for a specific blockchain network.
35#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
36#[serde(deny_unknown_fields)]
37pub struct Network {
38	/// Type of blockchain (EVM, Stellar, etc)
39	pub network_type: BlockChainType,
40
41	/// Unique identifier for this network
42	pub slug: String,
43
44	/// Human-readable name of the network
45	pub name: String,
46
47	/// List of RPC endpoints with their weights for load balancing
48	pub rpc_urls: Vec<RpcUrl>,
49
50	/// Chain ID for EVM networks
51	pub chain_id: Option<u64>,
52
53	/// Network passphrase for Stellar networks
54	pub network_passphrase: Option<String>,
55
56	/// Average block time in milliseconds
57	pub block_time_ms: u64,
58
59	/// Number of blocks needed for confirmation
60	pub confirmation_blocks: u64,
61
62	/// Cron expression for how often to check for new blocks
63	pub cron_schedule: String,
64
65	/// Maximum number of past blocks to process
66	pub max_past_blocks: Option<u64>,
67
68	/// Whether to store processed blocks
69	pub store_blocks: Option<bool>,
70
71	/// Configuration for missed block recovery job
72	pub recovery_config: Option<BlockRecoveryConfig>,
73}
74
75/// RPC endpoint configuration with load balancing weight
76#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
77#[serde(deny_unknown_fields)]
78pub struct RpcUrl {
79	/// Type of RPC endpoint (e.g. "rpc")
80	pub type_: String,
81
82	/// URL of the RPC endpoint (can be a secret value)
83	pub url: SecretValue,
84
85	/// Weight for load balancing (0-100)
86	pub weight: u32,
87}