introduce cpu_pool to read_msg (#477)
* introduce cpu_pool to read_msg * cleanup and less unwrap() in handler * expose cpu_pool as part of net_adapter (reuse across all peer connections and handlers) * fix DummyAdaptor for test usage * add new() to DummyAdapter for convenience
This commit is contained in:
@@ -16,6 +16,8 @@ use std::net::SocketAddr;
|
||||
use std::sync::{Arc, RwLock};
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
use cpupool::CpuPool;
|
||||
|
||||
use chain::{self, ChainAdapter};
|
||||
use core::core::{self, Output};
|
||||
use core::core::block::BlockHeader;
|
||||
@@ -36,9 +38,14 @@ pub struct NetToChainAdapter {
|
||||
p2p_server: OneTime<Arc<p2p::Server>>,
|
||||
tx_pool: Arc<RwLock<pool::TransactionPool<PoolToChainAdapter>>>,
|
||||
syncing: AtomicBool,
|
||||
cpu_pool: CpuPool,
|
||||
}
|
||||
|
||||
impl NetAdapter for NetToChainAdapter {
|
||||
fn cpu_pool(&self) -> CpuPool {
|
||||
self.cpu_pool.clone()
|
||||
}
|
||||
|
||||
fn total_difficulty(&self) -> Difficulty {
|
||||
self.chain.total_difficulty()
|
||||
}
|
||||
@@ -275,6 +282,7 @@ impl NetToChainAdapter {
|
||||
p2p_server: OneTime::new(),
|
||||
tx_pool: tx_pool,
|
||||
syncing: AtomicBool::new(true),
|
||||
cpu_pool: CpuPool::new(1),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user