openzeppelin_monitor::models

Struct Network

Source
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

Calculates the recommended minimum number of past blocks to maintain for this network.

This function computes a safe minimum value based on three factors:

  1. The number of blocks that occur during one cron interval (blocks_per_cron)
  2. The required confirmation blocks for the network
  3. 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 Clone for Network

Source§

fn clone(&self) -> Network

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

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,

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,

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,

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>

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)

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

Check if a file is a JSON file based on extension
Source§

impl Debug for Network

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Network

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Network

Source§

fn eq(&self, other: &Network) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Network

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Network

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Chain<T> for T

§

fn len(&self) -> usize

The number of items that this chain link consists of.
§

fn append_to(self, v: &mut Vec<T>)

Append the elements in this link to the chain.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<T> Container<T> for T
where T: Clone,

§

type Iter = Once<T>

An iterator over the items within this container, by value.
§

fn get_iter(&self) -> <T as Container<T>>::Iter

Iterate over the elements of the container (using internal iteration because GATs are unstable).
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T> TryClone for T
where T: Clone,

§

fn try_clone(&self) -> Result<T, Error>

Clones self, possibly returning an error.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<'de, T> BorrowedRpcObject<'de> for T
where T: RpcBorrow<'de> + RpcSend,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> OrderedContainer<T> for T
where T: Clone,

§

impl<'de, T> RpcBorrow<'de> for T
where T: Deserialize<'de> + Debug + Send + Sync + Unpin,

§

impl<T> RpcObject for T
where T: RpcSend + RpcRecv,

§

impl<T> RpcRecv for T
where T: DeserializeOwned + Debug + Send + Sync + Unpin + 'static,

§

impl<T> RpcSend for T
where T: Serialize + Clone + Debug + Send + Sync + Unpin,