mirror of
https://github.com/Cuprate/cuprate.git
synced 2025-01-09 12:29:45 +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
|
#workspace = true
|
||||||
|
|
||||||
[profile.dev]
|
[profile.dev]
|
||||||
panic = 'abort'
|
panic = "abort"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
panic = 'abort'
|
panic = "abort"
|
||||||
|
|
|
@ -2,28 +2,29 @@
|
||||||
//!
|
//!
|
||||||
//! Will contain the chain manager and syncer.
|
//! Will contain the chain manager and syncer.
|
||||||
|
|
||||||
use crate::blockchain::manager::BlockchainManager;
|
use tokio::sync::mpsc;
|
||||||
use crate::blockchain::types::{
|
use tower::{Service, ServiceExt};
|
||||||
ChainService, ConcreteBlockVerifierService, ConcreteTxVerifierService,
|
|
||||||
ConsensusBlockchainReadHandle,
|
|
||||||
};
|
|
||||||
use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle};
|
use cuprate_blockchain::service::{BlockchainReadHandle, BlockchainWriteHandle};
|
||||||
use cuprate_consensus::{generate_genesis_block, BlockChainContextService, ContextConfig};
|
use cuprate_consensus::{generate_genesis_block, BlockChainContextService, ContextConfig};
|
||||||
use cuprate_cryptonight::cryptonight_hash_v0;
|
use cuprate_cryptonight::cryptonight_hash_v0;
|
||||||
use cuprate_p2p::block_downloader::BlockDownloaderConfig;
|
use cuprate_p2p::{block_downloader::BlockDownloaderConfig, NetworkInterface};
|
||||||
use cuprate_p2p::NetworkInterface;
|
|
||||||
use cuprate_p2p_core::{ClearNet, Network};
|
use cuprate_p2p_core::{ClearNet, Network};
|
||||||
use cuprate_types::blockchain::{
|
use cuprate_types::{
|
||||||
BlockchainReadRequest, BlockchainResponse, BlockchainWriteRequest,
|
blockchain::{BlockchainReadRequest, BlockchainWriteRequest},
|
||||||
|
VerifiedBlockInformation,
|
||||||
};
|
};
|
||||||
use cuprate_types::VerifiedBlockInformation;
|
|
||||||
use tokio::sync::mpsc;
|
|
||||||
use tower::{Service, ServiceExt};
|
|
||||||
|
|
||||||
mod manager;
|
mod manager;
|
||||||
mod syncer;
|
mod syncer;
|
||||||
mod types;
|
mod types;
|
||||||
|
|
||||||
|
use manager::BlockchainManager;
|
||||||
|
use types::{
|
||||||
|
ChainService, ConcreteBlockVerifierService, ConcreteTxVerifierService,
|
||||||
|
ConsensusBlockchainReadHandle,
|
||||||
|
};
|
||||||
|
|
||||||
pub async fn check_add_genesis(
|
pub async fn check_add_genesis(
|
||||||
blockchain_read_handle: &mut BlockchainReadHandle,
|
blockchain_read_handle: &mut BlockchainReadHandle,
|
||||||
blockchain_write_handle: &mut BlockchainWriteHandle,
|
blockchain_write_handle: &mut BlockchainWriteHandle,
|
||||||
|
|
|
@ -1 +1,21 @@
|
||||||
//! cuprated config
|
//! 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::blockchain::check_add_genesis;
|
||||||
|
use crate::config::CupratedConfig;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use cuprate_p2p::block_downloader::BlockDownloaderConfig;
|
use cuprate_p2p::block_downloader::BlockDownloaderConfig;
|
||||||
use cuprate_p2p::P2PConfig;
|
use cuprate_p2p::P2PConfig;
|
||||||
use cuprate_p2p_core::Network;
|
use cuprate_p2p_core::Network;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
use tokio::runtime::Runtime;
|
||||||
use tracing::Level;
|
use tracing::Level;
|
||||||
|
|
||||||
mod blockchain;
|
mod blockchain;
|
||||||
|
@ -12,22 +14,15 @@ mod p2p;
|
||||||
mod rpc;
|
mod rpc;
|
||||||
mod txpool;
|
mod txpool;
|
||||||
|
|
||||||
#[derive(Parser)]
|
|
||||||
struct Args {}
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _args = Args::parse();
|
let config = config::config();
|
||||||
|
|
||||||
tracing_subscriber::fmt()
|
init_log(&config);
|
||||||
.with_max_level(Level::DEBUG)
|
|
||||||
.init();
|
|
||||||
|
|
||||||
let (mut bc_read_handle, mut bc_write_handle, _) =
|
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()
|
let async_rt = init_tokio_rt(&config);
|
||||||
.enable_all()
|
|
||||||
.build()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
async_rt.block_on(async move {
|
async_rt.block_on(async move {
|
||||||
check_add_genesis(&mut bc_read_handle, &mut bc_write_handle, &Network::Mainnet).await;
|
check_add_genesis(&mut bc_read_handle, &mut bc_write_handle, &Network::Mainnet).await;
|
||||||
|
@ -62,6 +57,21 @@ fn main() {
|
||||||
block_verifier,
|
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
|
where
|
||||||
D: Database + Clone + Sync + Send + 'static,
|
D: Database + Clone + Sync + Send + 'static,
|
||||||
{
|
{
|
||||||
if hf == HardFork::V1 {
|
if hf == HardFork::V1 || txs.is_empty() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue