Skip to content

Commit

Permalink
misc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Boog900 committed Oct 26, 2024
1 parent 3dc0049 commit d1f3eb4
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 12 deletions.
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 } # <https://github.com/tower-rs/tower/pull/796>
toml = { version = "0.8", default-features = false }
tracing-subscriber = { version = "0.3.18", default-features = false }
tracing = { version = "0.1.40", default-features = false }

Expand Down
2 changes: 1 addition & 1 deletion binaries/cuprated/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion binaries/cuprated/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}

Expand Down
15 changes: 14 additions & 1 deletion binaries/cuprated/src/config/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 6 additions & 2 deletions helper/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@
//! - <https://docs.rs/dirs>

//---------------------------------------------------------------------------------------------------- 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.
Expand Down Expand Up @@ -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())
}
Expand Down
7 changes: 4 additions & 3 deletions helper/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions net/wire/src/p2p/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions storage/blockchain/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`].
Expand Down

0 comments on commit d1f3eb4

Please sign in to comment.