newton-aggregator 0.4.12

newton prover aggregator utils
Documentation
use newton_prover_core::config::{key::EcdsaKey, ConfigLoader};
use serde::{Deserialize, Serialize};

/// Aggregator Config
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct AggregatorConfig {
    /// IP address
    pub ip_address: String,

    /// Signer
    pub signer: EcdsaKey,

    /// Timeout in seconds for waiting for aggregation responses
    /// Default: 5 seconds (accommodates destination chain operations)
    #[serde(default = "default_aggregation_timeout_secs")]
    pub aggregation_timeout_secs: u64,
}

fn default_aggregation_timeout_secs() -> u64 {
    5
}

// Implement ConfigLoader trait - provides load_config method automatically
impl ConfigLoader for AggregatorConfig {
    const FILE_NAME: &'static str = "aggregator";
    const ENV_PREFIX: &'static str = "AGGREGATOR";
}

impl AggregatorConfig {
    /// Set IP address
    pub fn set_ip_address(&mut self, ip_address: String) {
        self.ip_address = ip_address;
    }

    /// Set signer
    pub fn set_signer(&mut self, signer: EcdsaKey) {
        self.signer = signer;
    }
}