diff --git a/binaries/cuprated/Cargo.toml b/binaries/cuprated/Cargo.toml index c01e2cca..a04c0be2 100644 --- a/binaries/cuprated/Cargo.toml +++ b/binaries/cuprated/Cargo.toml @@ -30,7 +30,7 @@ tracing-subscriber = { workspace = true, features = ["default"] } #workspace = true [profile.dev] -panic = 'abort' +panic = "abort" [profile.release] -panic = 'abort' +panic = "abort" diff --git a/binaries/cuprated/src/blockchain.rs b/binaries/cuprated/src/blockchain.rs index c0b7e6ce..366f9620 100644 --- a/binaries/cuprated/src/blockchain.rs +++ b/binaries/cuprated/src/blockchain.rs @@ -2,28 +2,29 @@ //! //! Will contain the chain manager and syncer. -use crate::blockchain::manager::BlockchainManager; -use crate::blockchain::types::{ - ChainService, ConcreteBlockVerifierService, ConcreteTxVerifierService, - ConsensusBlockchainReadHandle, -}; +use tokio::sync::mpsc; +use tower::{Service, ServiceExt}; + use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle}; use cuprate_consensus::{generate_genesis_block, BlockChainContextService, ContextConfig}; use cuprate_cryptonight::cryptonight_hash_v0; -use cuprate_p2p::block_downloader::BlockDownloaderConfig; -use cuprate_p2p::NetworkInterface; +use cuprate_p2p::{block_downloader::BlockDownloaderConfig, NetworkInterface}; use cuprate_p2p_core::{ClearNet, Network}; -use cuprate_types::blockchain::{ - BlockchainReadRequest, BlockchainResponse, BlockchainWriteRequest, +use cuprate_types::{ + blockchain::{BlockchainReadRequest, BlockchainWriteRequest}, + VerifiedBlockInformation, }; -use cuprate_types::VerifiedBlockInformation; -use tokio::sync::mpsc; -use tower::{Service, ServiceExt}; mod manager; mod syncer; mod types; +use manager::BlockchainManager; +use types::{ + ChainService, ConcreteBlockVerifierService, ConcreteTxVerifierService, + ConsensusBlockchainReadHandle, +}; + pub async fn check_add_genesis( blockchain_read_handle: &mut BlockchainReadHandle, blockchain_write_handle: &mut BlockchainWriteHandle, diff --git a/binaries/cuprated/src/config.rs b/binaries/cuprated/src/config.rs index d613c1fc..1fd02f74 100644 --- a/binaries/cuprated/src/config.rs +++ b/binaries/cuprated/src/config.rs @@ -1 +1,21 @@ //! cuprated config + +use cuprate_blockchain::config::{ + Config as BlockchainConfig, ConfigBuilder as BlockchainConfigBuilder, +}; + +pub fn config() -> CupratedConfig { + // TODO: read config options from the conf files & cli args. + + CupratedConfig {} +} + +pub struct CupratedConfig { + // TODO: expose config options we want to allow changing. +} + +impl CupratedConfig { + pub fn blockchain_config(&self) -> BlockchainConfig { + BlockchainConfigBuilder::new().fast().build() + } +} diff --git a/binaries/cuprated/src/main.rs b/binaries/cuprated/src/main.rs index 5ccb8382..023c3a81 100644 --- a/binaries/cuprated/src/main.rs +++ b/binaries/cuprated/src/main.rs @@ -1,9 +1,11 @@ use crate::blockchain::check_add_genesis; +use crate::config::CupratedConfig; use clap::Parser; use cuprate_p2p::block_downloader::BlockDownloaderConfig; use cuprate_p2p::P2PConfig; use cuprate_p2p_core::Network; use std::time::Duration; +use tokio::runtime::Runtime; use tracing::Level; mod blockchain; @@ -12,22 +14,15 @@ mod p2p; mod rpc; mod txpool; -#[derive(Parser)] -struct Args {} fn main() { - let _args = Args::parse(); + let config = config::config(); - tracing_subscriber::fmt() - .with_max_level(Level::DEBUG) - .init(); + init_log(&config); let (mut bc_read_handle, mut bc_write_handle, _) = - cuprate_blockchain::service::init(cuprate_blockchain::config::Config::default()).unwrap(); + cuprate_blockchain::service::init(config.blockchain_config()).unwrap(); - let async_rt = tokio::runtime::Builder::new_multi_thread() - .enable_all() - .build() - .unwrap(); + let async_rt = init_tokio_rt(&config); async_rt.block_on(async move { check_add_genesis(&mut bc_read_handle, &mut bc_write_handle, &Network::Mainnet).await; @@ -62,6 +57,21 @@ fn main() { block_verifier, ); - tokio::time::sleep(Duration::MAX).await; + futures::future::pending::<()>().await; }); + + // TODO: add command handling. +} + +fn init_log(_config: &CupratedConfig) { + tracing_subscriber::fmt() + .with_max_level(Level::DEBUG) + .init(); +} + +fn init_tokio_rt(_config: &CupratedConfig) -> Runtime { + tokio::runtime::Builder::new_multi_thread() + .enable_all() + .build() + .unwrap() } diff --git a/consensus/src/transactions.rs b/consensus/src/transactions.rs index 82d3100e..23f7a4d1 100644 --- a/consensus/src/transactions.rs +++ b/consensus/src/transactions.rs @@ -393,7 +393,7 @@ async fn verify_transactions_decoy_info( where D: Database + Clone + Sync + Send + 'static, { - if hf == HardFork::V1 { + if hf == HardFork::V1 || txs.is_empty() { return Ok(()); }