Skip to content
Open
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
7 changes: 7 additions & 0 deletions src/kaspad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ pub struct Config {
network: Network,
data_folder: Option<PathBuf>,
enable_upnp: bool,
#[serde(default)]
archival: bool,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field needs to be tagged with #[serde(default)], otherwise the previous version of the config file will fail to load (as the field is missing), resetting the entire config (as currently, it will fall back to a general error handling).

The default value for bool is false. You changed the new() ctor, which is what is used to create a new config, however, when config is deserialized, it uses serde.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, i see that without default, old configuration treated as invalid and khost starts as new deployment.

outgoing_peers: Option<u16>,
max_incoming_peers: Option<u16>,
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -92,6 +94,7 @@ impl Config {
network,
data_folder: None,
enable_upnp: false,
archival: false,
outgoing_peers: Some(32),
max_incoming_peers: Some(256),
grpc: Some(Interface::Local(grpc)),
Expand Down Expand Up @@ -156,6 +159,10 @@ impl From<&Config> for Vec<String> {
args.push("--disable-upnp");
}

if config.archival {
args.push("--archival");
}

if let Some(outgoing_peers) = config.outgoing_peers {
args.push(format!("--outpeers={outgoing_peers}"));
}
Expand Down