diff --git a/src/consts.rs b/src/consts.rs new file mode 100644 index 0000000..02549be --- /dev/null +++ b/src/consts.rs @@ -0,0 +1,8 @@ +use std::time::Duration; + +/// DA_RETRY_COUNT determines how many times to retry epoch submission. +pub const DA_RETRY_COUNT: u64 = 5; +/// DA_RETRY_COUNT determines how long to wait between failed submissions. +pub const DA_RETRY_INTERVAL: Duration = Duration::from_secs(5); +/// CHANNEL_BUFFER_SIZE determines the default channel size. +pub const CHANNEL_BUFFER_SIZE: usize = 5; diff --git a/src/da.rs b/src/da.rs index ccc500d..66011c4 100644 --- a/src/da.rs +++ b/src/da.rs @@ -1,4 +1,5 @@ use crate::{ + consts::CHANNEL_BUFFER_SIZE, error::{DataAvailabilityError, DatabaseError, DeimosError, GeneralError}, utils::Signable, zk_snark::{Bls12Proof, VerifyingKey}, @@ -145,8 +146,7 @@ impl CelestiaConnection { auth_token: Option<&str>, namespace_hex: &String, ) -> Result { - // TODO: Make buffer size constant - let (tx, rx) = channel(5); + let (tx, rx) = channel(CHANNEL_BUFFER_SIZE); let client = Client::new(&connection_string, auth_token) .await diff --git a/src/lib.rs b/src/lib.rs index 763aca5..d941211 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,5 @@ mod cfg; +pub mod consts; pub mod da; pub mod error; pub mod node_types; @@ -6,6 +7,5 @@ pub mod storage; pub mod utils; mod webserver; pub mod zk_snark; - #[macro_use] extern crate log; diff --git a/src/node_types.rs b/src/node_types.rs index 446d33a..7b31ea8 100644 --- a/src/node_types.rs +++ b/src/node_types.rs @@ -1,3 +1,4 @@ +use crate::consts::{CHANNEL_BUFFER_SIZE, DA_RETRY_COUNT, DA_RETRY_INTERVAL}; use crate::error::DataAvailabilityError; use async_trait::async_trait; use crypto_hash::{hex_digest, Algorithm}; @@ -26,13 +27,6 @@ use crate::{ }, }; -/// DA_RETRY_COUNT determines how many times to retry epoch submission. -const DA_RETRY_COUNT: u64 = 5; -/// DA_RETRY_COUNT determines how long to wait between failed submissions. -const DA_RETRY_INTERVAL: Duration = Duration::from_secs(5); -/// CHANNEL_BUFFER_SIZE determines the size of the channel buffer for the DA backlog. -const CHANNEL_BUFFER_SIZE: usize = 5; - #[async_trait] pub trait NodeType { async fn start(self: Arc) -> std::result::Result<(), std::io::Error>;