Skip to main content

jito_bundle/config/
network.rs

1use crate::constants::{JITO_BLOCK_ENGINE_URL, JITO_MAINNET_ENDPOINTS, JITO_TIPS_FLOOR_URL};
2
3#[derive(Debug, Clone)]
4pub enum Network {
5    Mainnet,
6    Custom {
7        block_engine_url: String,
8        tip_floor_url: String,
9    },
10}
11
12impl Network {
13    pub fn block_engine_url(&self) -> &str {
14        match self {
15            Network::Mainnet => JITO_BLOCK_ENGINE_URL,
16            Network::Custom {
17                block_engine_url, ..
18            } => block_engine_url,
19        }
20    }
21
22    pub fn tip_floor_url(&self) -> &str {
23        match self {
24            Network::Mainnet => JITO_TIPS_FLOOR_URL,
25            Network::Custom { tip_floor_url, .. } => tip_floor_url,
26        }
27    }
28
29    pub fn is_custom(&self) -> bool {
30        matches!(self, Network::Custom { .. })
31    }
32
33    pub fn send_endpoints(&self) -> Vec<String> {
34        match self {
35            Network::Mainnet => JITO_MAINNET_ENDPOINTS
36                .iter()
37                .map(|ep| format!("{JITO_BLOCK_ENGINE_URL}?endpoint={ep}"))
38                .collect(),
39            Network::Custom {
40                block_engine_url, ..
41            } => vec![block_engine_url.clone()],
42        }
43    }
44}