Skip to content

Commit

Permalink
node: make databroker params field optional
Browse files Browse the repository at this point in the history
  • Loading branch information
herr-seppia committed Aug 20, 2024
1 parent 64e58e2 commit bb64b3d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
2 changes: 1 addition & 1 deletion node/src/databroker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub struct DataBrokerSrv {

impl DataBrokerSrv {
pub fn new(conf: conf::Params) -> Self {
info!("DataBrokerSrv::new with conf: {}", conf);
info!("DataBrokerSrv::new with conf: {conf:?}");
Self {
conf,
inbound: AsyncQueue::bounded(
Expand Down
35 changes: 17 additions & 18 deletions node/src/databroker/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,39 @@
//
// Copyright (c) DUSK NETWORK. All rights reserved.

use std::fmt::Formatter;

use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Copy, Clone)]
#[derive(Serialize, Deserialize, Copy, Clone, Debug)]
pub struct Params {
#[serde(default = "default_max_inv_entries")]
pub max_inv_entries: usize,
#[serde(default = "default_max_ongoing_requests")]
pub max_ongoing_requests: usize,
#[serde(default = "default_max_queue_size")]
pub max_queue_size: usize,

/// delay_on_resp_msg is in milliseconds. It mitigates stress on UDP
/// buffers when network latency is 0 (localnet network only)
pub delay_on_resp_msg: Option<u64>,
}

const fn default_max_inv_entries() -> usize {
100
}
const fn default_max_ongoing_requests() -> usize {
1000
}
const fn default_max_queue_size() -> usize {
1000
}

impl Default for Params {
fn default() -> Self {
Self {
max_inv_entries: 100,
max_ongoing_requests: 1000,
max_inv_entries: default_max_inv_entries(),
max_ongoing_requests: default_max_ongoing_requests(),
delay_on_resp_msg: None,
max_queue_size: 1000,
max_queue_size: default_max_queue_size(),
}
}
}

impl std::fmt::Display for Params {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(
f,
"max_inv_entries: {}, max_ongoing_requests: {} ,max_queue_size: {}",
self.max_inv_entries,
self.max_ongoing_requests,
self.max_queue_size
)
}
}

0 comments on commit bb64b3d

Please sign in to comment.