mirror of
https://github.com/Cuprate/cuprate.git
synced 2025-01-08 20:09:44 +00:00
misc changes
This commit is contained in:
parent
f25588d348
commit
1c93ea14b4
5 changed files with 58 additions and 27 deletions
|
@ -30,7 +30,7 @@ tracing-subscriber = { workspace = true, features = ["default"] }
|
|||
#workspace = true
|
||||
|
||||
[profile.dev]
|
||||
panic = 'abort'
|
||||
panic = "abort"
|
||||
|
||||
[profile.release]
|
||||
panic = 'abort'
|
||||
panic = "abort"
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
|
|
|
@ -393,7 +393,7 @@ async fn verify_transactions_decoy_info<D>(
|
|||
where
|
||||
D: Database + Clone + Sync + Send + 'static,
|
||||
{
|
||||
if hf == HardFork::V1 {
|
||||
if hf == HardFork::V1 || txs.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue