pub struct Network {
pub network_type: BlockChainType,
pub slug: String,
pub name: String,
pub rpc_urls: Vec<RpcUrl>,
pub chain_id: Option<u64>,
pub network_passphrase: Option<String>,
pub block_time_ms: u64,
pub confirmation_blocks: u64,
pub cron_schedule: String,
pub max_past_blocks: Option<u64>,
pub store_blocks: Option<bool>,
}
Expand description
Configuration for connecting to and interacting with a blockchain network.
Defines connection details and operational parameters for a specific blockchain network, supporting both EVM and Stellar-based chains.
Fields§
§network_type: BlockChainType
Type of blockchain (EVM, Stellar, etc)
slug: String
Unique identifier for this network
name: String
Human-readable name of the network
rpc_urls: Vec<RpcUrl>
List of RPC endpoints with their weights for load balancing
chain_id: Option<u64>
Chain ID for EVM networks
network_passphrase: Option<String>
Network passphrase for Stellar networks
block_time_ms: u64
Average block time in milliseconds
confirmation_blocks: u64
Number of blocks needed for confirmation
cron_schedule: String
Cron expression for how often to check for new blocks
max_past_blocks: Option<u64>
Maximum number of past blocks to process
store_blocks: Option<bool>
Whether to store processed blocks
Implementations§
Source§impl Network
impl Network
Sourcepub fn get_recommended_past_blocks(&self) -> u64
pub fn get_recommended_past_blocks(&self) -> u64
Calculates the recommended minimum number of past blocks to maintain for this network.
This function computes a safe minimum value based on three factors:
- The number of blocks that occur during one cron interval (
blocks_per_cron
) - The required confirmation blocks for the network
- An additional buffer block (+1)
The formula used is: (cron_interval_ms / block_time_ms) + confirmation_blocks + 1
§Returns
u64
- The recommended minimum number of past blocks to maintain
§Note
If the cron schedule parsing fails, the blocks_per_cron component will be 0,
resulting in a minimum recommendation of confirmation_blocks + 1
Trait Implementations§
Source§impl ConfigLoader for Network
impl ConfigLoader for Network
Source§fn resolve_secrets<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Self, ConfigError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn resolve_secrets<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Self, ConfigError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Resolve all secrets in the network configuration
Source§fn load_all<'life0, 'async_trait, T>(
path: Option<&'life0 Path>,
) -> Pin<Box<dyn Future<Output = Result<T, ConfigError>> + Send + 'async_trait>>where
T: FromIterator<(String, Self)> + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
fn load_all<'life0, 'async_trait, T>(
path: Option<&'life0 Path>,
) -> Pin<Box<dyn Future<Output = Result<T, ConfigError>> + Send + 'async_trait>>where
T: FromIterator<(String, Self)> + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
Load all network configurations from a directory
Reads and parses all JSON files in the specified directory (or default config directory) as network configurations.
Source§fn load_from_path<'life0, 'async_trait>(
path: &'life0 Path,
) -> Pin<Box<dyn Future<Output = Result<Self, ConfigError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn load_from_path<'life0, 'async_trait>(
path: &'life0 Path,
) -> Pin<Box<dyn Future<Output = Result<Self, ConfigError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Load a network configuration from a specific file
Reads and parses a single JSON file as a network configuration.
Source§fn validate(&self) -> Result<(), ConfigError>
fn validate(&self) -> Result<(), ConfigError>
Validate the network configuration
Ensures that:
- The network has a valid name and slug
- At least one RPC URL is specified
- Required chain-specific parameters are present
- Block time and confirmation values are reasonable
Source§fn validate_protocol(&self)
fn validate_protocol(&self)
Validate the safety of the protocol used in the network
Returns if safe, or logs a warning message if unsafe.
Source§fn is_json_file(path: &Path) -> bool
fn is_json_file(path: &Path) -> bool
Source§impl<'de> Deserialize<'de> for Network
impl<'de> Deserialize<'de> for Network
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Network
Auto Trait Implementations§
impl Freeze for Network
impl RefUnwindSafe for Network
impl Send for Network
impl Sync for Network
impl Unpin for Network
impl UnwindSafe for Network
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Chain<T> for T
impl<T> Chain<T> for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more