mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-02 21:33:09 +00:00
73 lines
1.6 KiB
Rust
73 lines
1.6 KiB
Rust
use std::time::Duration;
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
pub mod errors;
|
|
pub mod message;
|
|
pub mod parser;
|
|
|
|
#[derive(Serialize, Deserialize, Clone, Copy, Debug)]
|
|
pub struct RpcPollingConfig {
|
|
pub polling_interval: Duration,
|
|
pub polling_timeout: Duration,
|
|
}
|
|
|
|
impl Default for RpcPollingConfig {
|
|
fn default() -> Self {
|
|
Self {
|
|
polling_interval: Duration::from_millis(500),
|
|
polling_timeout: Duration::from_secs(10),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
|
pub struct RpcLimitsConfig {
|
|
/// Maximum byte size of the json payload.
|
|
pub json_payload_max_size: usize,
|
|
}
|
|
|
|
impl Default for RpcLimitsConfig {
|
|
fn default() -> Self {
|
|
Self {
|
|
json_payload_max_size: 10 * 1024 * 1024,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
|
pub struct RpcConfig {
|
|
pub addr: String,
|
|
pub cors_allowed_origins: Vec<String>,
|
|
pub polling_config: RpcPollingConfig,
|
|
#[serde(default)]
|
|
pub limits_config: RpcLimitsConfig,
|
|
}
|
|
|
|
impl Default for RpcConfig {
|
|
fn default() -> Self {
|
|
RpcConfig {
|
|
addr: "0.0.0.0:3040".to_owned(),
|
|
cors_allowed_origins: vec!["*".to_owned()],
|
|
polling_config: RpcPollingConfig::default(),
|
|
limits_config: RpcLimitsConfig::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl RpcConfig {
|
|
pub fn new(addr: &str) -> Self {
|
|
RpcConfig {
|
|
addr: addr.to_owned(),
|
|
..Default::default()
|
|
}
|
|
}
|
|
|
|
pub fn with_port(port: u16) -> Self {
|
|
RpcConfig {
|
|
addr: format!("0.0.0.0:{port}"),
|
|
..Default::default()
|
|
}
|
|
}
|
|
}
|