fuel_core_relayer/
config.rsuse ethers_contract::EthEvent;
use ethers_core::types::H256;
use fuel_core_types::{
blockchain::primitives::DaBlockHeight,
fuel_types::Bytes20,
};
use once_cell::sync::Lazy;
use std::{
str::FromStr,
time::Duration,
};
pub(crate) static ETH_LOG_MESSAGE: Lazy<H256> =
Lazy::new(crate::abi::bridge::MessageSentFilter::signature);
pub(crate) static ETH_FORCED_TX: Lazy<H256> =
Lazy::new(crate::abi::bridge::TransactionFilter::signature);
#[derive(Clone, Debug)]
pub struct Config {
pub da_deploy_height: DaBlockHeight,
pub relayer: Option<Vec<url::Url>>,
pub eth_v2_listening_contracts: Vec<Bytes20>,
pub log_page_size: u64,
pub sync_minimum_duration: Duration,
pub syncing_call_frequency: Duration,
pub syncing_log_frequency: Duration,
pub metrics: bool,
}
#[allow(missing_docs)]
impl Config {
pub const DEFAULT_LOG_PAGE_SIZE: u64 = 10_000;
pub const DEFAULT_DA_DEPLOY_HEIGHT: u64 = 0;
pub const DEFAULT_SYNC_MINIMUM_DURATION: Duration = Duration::from_secs(5);
pub const DEFAULT_SYNCING_CALL_FREQ: Duration = Duration::from_secs(5);
pub const DEFAULT_SYNCING_LOG_FREQ: Duration = Duration::from_secs(60);
}
impl Default for Config {
fn default() -> Self {
Self {
da_deploy_height: DaBlockHeight::from(Self::DEFAULT_DA_DEPLOY_HEIGHT),
relayer: None,
eth_v2_listening_contracts: vec![Bytes20::from_str(
"0x03E4538018285e1c03CCce2F92C9538c87606911",
)
.unwrap()],
log_page_size: Self::DEFAULT_LOG_PAGE_SIZE,
sync_minimum_duration: Self::DEFAULT_SYNC_MINIMUM_DURATION,
syncing_call_frequency: Self::DEFAULT_SYNCING_CALL_FREQ,
syncing_log_frequency: Self::DEFAULT_SYNCING_LOG_FREQ,
metrics: false,
}
}
}
mod tests {
#[test]
fn conversion_str_h160_bytes() {
use std::str::FromStr;
let bytes20 = fuel_core_types::fuel_types::Bytes20::from_str(
"0x03E4538018285e1c03CCce2F92C9538c87606911",
)
.unwrap();
let h160 = ethers_core::types::H160::from_str(
"0x03E4538018285e1c03CCce2F92C9538c87606911",
)
.unwrap();
assert_eq!(bytes20.as_slice(), h160.as_bytes());
}
}