misc changes

This commit is contained in:
Boog900 2024-10-26 21:21:01 +01:00
parent 3dc0049481
commit d1f3eb40bf
No known key found for this signature in database
GPG key ID: 42AB1287CB0041C2
8 changed files with 32 additions and 12 deletions

View file

@ -32,6 +32,7 @@ members = [
] ]
[profile.release] [profile.release]
panic = "abort"
lto = true # Build with LTO lto = true # Build with LTO
strip = "none" # Keep panic stack traces strip = "none" # Keep panic stack traces
codegen-units = 1 # Optimize for binary speed over compile times 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-stream = { version = "0.1.16", default-features = false }
tokio = { version = "1.40.0", 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> 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-subscriber = { version = "0.3.18", default-features = false }
tracing = { version = "0.1.40", default-features = false } tracing = { version = "0.1.40", default-features = false }

View file

@ -70,10 +70,10 @@ thread_local = { workspace = true }
tokio-util = { workspace = true } tokio-util = { workspace = true }
tokio-stream = { workspace = true } tokio-stream = { workspace = true }
tokio = { workspace = true } tokio = { workspace = true }
toml = { workspace = true, features = ["parse"]}
tower = { workspace = true } tower = { workspace = true }
tracing-subscriber = { workspace = true, features = ["std", "fmt", "default"] } tracing-subscriber = { workspace = true, features = ["std", "fmt", "default"] }
tracing = { workspace = true, features = ["default"] } tracing = { workspace = true, features = ["default"] }
toml = "0.8"
[lints] [lints]
workspace = true workspace = true

View file

@ -113,7 +113,7 @@ impl Config {
p2p_port: self.p2p.clear_net.general.p2p_port, p2p_port: self.p2p.clear_net.general.p2p_port,
// TODO: set this if a public RPC server is set. // TODO: set this if a public RPC server is set.
rpc_port: 0, 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),
} }
} }

View file

@ -42,7 +42,20 @@ pub struct SharedNetConfig {
/// port to use to accept p2p connections. /// port to use to accept p2p connections.
pub p2p_port: u16, pub p2p_port: u16,
/// The address book config. /// 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 { impl Default for SharedNetConfig {

View file

@ -28,9 +28,12 @@
//! - <https://docs.rs/dirs> //! - <https://docs.rs/dirs>
//---------------------------------------------------------------------------------------------------- Use //---------------------------------------------------------------------------------------------------- Use
use std::{
path::{Path, PathBuf},
sync::LazyLock,
};
use crate::network::Network; use crate::network::Network;
use std::path::Path;
use std::{path::PathBuf, sync::LazyLock};
//---------------------------------------------------------------------------------------------------- Const //---------------------------------------------------------------------------------------------------- Const
/// Cuprate's main directory. /// Cuprate's main directory.
@ -180,6 +183,7 @@ impl_path_lazylock! {
"txpool", "txpool",
} }
/// Joins the [`Path`] with a folder for the given [`Network`].
pub fn path_with_network(path: &Path, network: Network) -> PathBuf { pub fn path_with_network(path: &Path, network: Network) -> PathBuf {
path.join(network.to_string()) path.join(network.to_string())
} }

View file

@ -6,9 +6,10 @@
//! //!
//! `#[no_std]` compatible. //! `#[no_std]` compatible.
// TODO: move to types crate. // TODO: move to types crate.
use std::{
use std::fmt::{Display, Formatter}; fmt::{Display, Formatter},
use std::str::FromStr; str::FromStr,
};
const MAINNET_NETWORK_ID: [u8; 16] = [ const MAINNET_NETWORK_ID: [u8; 16] = [
0x12, 0x30, 0xF1, 0x71, 0x61, 0x04, 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x16, 0xA1, 0xA1, 0x10, 0x12, 0x30, 0xF1, 0x71, 0x61, 0x04, 0x41, 0x61, 0x17, 0x31, 0x00, 0x82, 0x16, 0xA1, 0xA1, 0x10,

View file

@ -51,8 +51,6 @@ impl<'a> From<&'a PeerSupportFlags> for &'a u32 {
} }
} }
//15515542498767257178
/// Basic Node Data, information on the connected peer /// Basic Node Data, information on the connected peer
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct BasicNodeData { pub struct BasicNodeData {

View file

@ -47,11 +47,13 @@ use std::{borrow::Cow, path::PathBuf};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use cuprate_database::{config::SyncMode, resize::ResizeAlgorithm}; 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 // re-exports
pub use cuprate_database_service::ReaderThreads; pub use cuprate_database_service::ReaderThreads;
use cuprate_helper::network::Network;
//---------------------------------------------------------------------------------------------------- ConfigBuilder //---------------------------------------------------------------------------------------------------- ConfigBuilder
/// Builder for [`Config`]. /// Builder for [`Config`].