Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node: make databroker params field optional #2158

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
)
}
}
Loading