From ec08b01687d6c62d782f52a2c74600242a1e07b2 Mon Sep 17 00:00:00 2001 From: jjy Date: Sun, 7 Apr 2019 19:19:03 +0800 Subject: [PATCH] refactor: ChainState use tx_pool_config.txs_verify_cache_size --- shared/src/chain_state.rs | 9 ++------- shared/src/shared.rs | 15 ++------------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/shared/src/chain_state.rs b/shared/src/chain_state.rs index 44a29147f0..d658b267dd 100644 --- a/shared/src/chain_state.rs +++ b/shared/src/chain_state.rs @@ -36,12 +36,7 @@ pub struct ChainState { } impl ChainState { - pub fn new( - store: &Arc, - consensus: Arc, - txs_verify_cache_size: usize, - tx_pool_config: TxPoolConfig, - ) -> Self { + pub fn new(store: &Arc, consensus: Arc, tx_pool_config: TxPoolConfig) -> Self { // check head in store or save the genesis block as head let tip_header = { let genesis = consensus.genesis_block(); @@ -54,8 +49,8 @@ impl ChainState { } }; + let txs_verify_cache = LruCache::new(tx_pool_config.txs_verify_cache_size); let tx_pool = TxPool::new(tx_pool_config); - let txs_verify_cache = LruCache::new(txs_verify_cache_size); let tip_number = tip_header.number(); let proposal_window = consensus.tx_proposal_window(); diff --git a/shared/src/shared.rs b/shared/src/shared.rs index dabba066e6..06c52e8ee2 100644 --- a/shared/src/shared.rs +++ b/shared/src/shared.rs @@ -38,19 +38,13 @@ impl ::std::clone::Clone for Shared { } impl Shared { - pub fn new( - store: CI, - consensus: Consensus, - txs_verify_cache_size: usize, - tx_pool_config: TxPoolConfig, - ) -> Self { + pub fn new(store: CI, consensus: Consensus, tx_pool_config: TxPoolConfig) -> Self { let store = Arc::new(store); let consensus = Arc::new(consensus); let chain_state = { Arc::new(Mutex::new(ChainState::new( &store, Arc::clone(&consensus), - txs_verify_cache_size, tx_pool_config, ))) }; @@ -299,11 +293,6 @@ impl SharedBuilder { let store = ChainKVStore::new(self.db.unwrap()); let consensus = self.consensus.unwrap_or_else(Consensus::default); let tx_pool_config = self.tx_pool_config.unwrap_or_else(Default::default); - Shared::new( - store, - consensus, - tx_pool_config.txs_verify_cache_size, - tx_pool_config, - ) + Shared::new(store, consensus, tx_pool_config) } }