mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-03 05:43:08 +00:00
55 lines
1.2 KiB
Rust
55 lines
1.2 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
pub mod errors;
|
|
pub mod message;
|
|
pub mod parser;
|
|
pub mod requests;
|
|
|
|
#[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>,
|
|
#[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()],
|
|
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()
|
|
}
|
|
}
|
|
}
|