diff --git a/Cargo.toml b/Cargo.toml index 386586328..9865e1683 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ members = [ ] [profile.release] +panic = "abort" lto = true # Build with LTO strip = "none" # Keep panic stack traces codegen-units = 1 # Optimize for binary speed over compile times @@ -115,6 +116,7 @@ tokio-util = { version = "0.7.12", default-features = false } tokio-stream = { version = "0.1.16", default-features = false } tokio = { version = "1.40.0", default-features = false } tower = { git = "https://github.com/Cuprate/tower.git", rev = "6c7faf0", default-features = false } # +toml = { version = "0.8", default-features = false } tracing-subscriber = { version = "0.3.18", default-features = false } tracing = { version = "0.1.40", default-features = false } diff --git a/binaries/cuprated/Cargo.toml b/binaries/cuprated/Cargo.toml index 0521b1fd6..3de2f151d 100644 --- a/binaries/cuprated/Cargo.toml +++ b/binaries/cuprated/Cargo.toml @@ -70,10 +70,10 @@ thread_local = { workspace = true } tokio-util = { workspace = true } tokio-stream = { workspace = true } tokio = { workspace = true } +toml = { workspace = true, features = ["parse"]} tower = { workspace = true } tracing-subscriber = { workspace = true, features = ["std", "fmt", "default"] } tracing = { workspace = true, features = ["default"] } -toml = "0.8" [lints] workspace = true diff --git a/binaries/cuprated/src/config.rs b/binaries/cuprated/src/config.rs index 290f5c271..b553c078d 100644 --- a/binaries/cuprated/src/config.rs +++ b/binaries/cuprated/src/config.rs @@ -113,7 +113,7 @@ impl Config { p2p_port: self.p2p.clear_net.general.p2p_port, // TODO: set this if a public RPC server is set. rpc_port: 0, - address_book_config: self.p2p.clear_net.general.address_book_config.clone(), + address_book_config: self.p2p.clear_net.general.address_book_config(self.network), } } diff --git a/binaries/cuprated/src/config/p2p.rs b/binaries/cuprated/src/config/p2p.rs index 64b5c3536..81e5b5fae 100644 --- a/binaries/cuprated/src/config/p2p.rs +++ b/binaries/cuprated/src/config/p2p.rs @@ -42,7 +42,20 @@ pub struct SharedNetConfig { /// port to use to accept p2p connections. pub p2p_port: u16, /// The address book config. - pub address_book_config: AddressBookConfig, + address_book_config: AddressBookConfig, +} + +impl SharedNetConfig { + /// Returns the [`AddressBookConfig`]. + pub fn address_book_config(&self, network: Network) -> AddressBookConfig { + // HACK: we add the network here so we don't need to define another address book config. + let mut address_book_config = self.address_book_config.clone(); + address_book_config + .peer_store_folder + .push(network.to_string()); + + address_book_config + } } impl Default for SharedNetConfig { diff --git a/helper/src/fs.rs b/helper/src/fs.rs index a145ea0e2..7abde8936 100644 --- a/helper/src/fs.rs +++ b/helper/src/fs.rs @@ -28,9 +28,12 @@ //! - //---------------------------------------------------------------------------------------------------- Use +use std::{ + path::{Path, PathBuf}, + sync::LazyLock, +}; + use crate::network::Network; -use std::path::Path; -use std::{path::PathBuf, sync::LazyLock}; //---------------------------------------------------------------------------------------------------- Const /// Cuprate's main directory. @@ -180,6 +183,7 @@ impl_path_lazylock! { "txpool", } +/// Joins the [`Path`] with a folder for the given [`Network`]. pub fn path_with_network(path: &Path, network: Network) -> PathBuf { path.join(network.to_string()) } diff --git a/helper/src/network.rs b/helper/src/network.rs index 6d7740b04..2836781d5 100644 --- a/helper/src/network.rs +++ b/helper/src/network.rs @@ -6,9 +6,10 @@ //! //! `#[no_std]` compatible. // TODO: move to types crate. - -use std::fmt::{Display, Formatter}; -use std::str::FromStr; +use std::{ + fmt::{Display, Formatter}, + str::FromStr, +}; const MAINNET_NETWORK_ID: [u8; 16] = [ 0x12, 0x30, 0xF1, 0x71, 0x61, 0x04, 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x16, 0xA1, 0xA1, 0x10, diff --git a/net/wire/src/p2p/common.rs b/net/wire/src/p2p/common.rs index 5beb26bdc..d95a6203a 100644 --- a/net/wire/src/p2p/common.rs +++ b/net/wire/src/p2p/common.rs @@ -51,8 +51,6 @@ impl<'a> From<&'a PeerSupportFlags> for &'a u32 { } } -//15515542498767257178 - /// Basic Node Data, information on the connected peer #[derive(Debug, Clone, PartialEq, Eq)] pub struct BasicNodeData { diff --git a/storage/blockchain/src/config.rs b/storage/blockchain/src/config.rs index e4b2f4ca1..2bd35e0ef 100644 --- a/storage/blockchain/src/config.rs +++ b/storage/blockchain/src/config.rs @@ -47,11 +47,13 @@ use std::{borrow::Cow, path::PathBuf}; use serde::{Deserialize, Serialize}; use cuprate_database::{config::SyncMode, resize::ResizeAlgorithm}; -use cuprate_helper::fs::{path_with_network, CUPRATE_BLOCKCHAIN_DIR}; +use cuprate_helper::{ + fs::{path_with_network, CUPRATE_BLOCKCHAIN_DIR}, + network::Network, +}; // re-exports pub use cuprate_database_service::ReaderThreads; -use cuprate_helper::network::Network; //---------------------------------------------------------------------------------------------------- ConfigBuilder /// Builder for [`Config`].