From 1ee9732325a9d0a2db3af37a1d82528a303ce3eb Mon Sep 17 00:00:00 2001 From: Eval EXEC Date: Thu, 21 Mar 2024 10:47:29 +0800 Subject: [PATCH] reduce channel length --- chain/src/init.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/chain/src/init.rs b/chain/src/init.rs index 6a8bf3162e8..9280ac7ec39 100644 --- a/chain/src/init.rs +++ b/chain/src/init.rs @@ -15,7 +15,7 @@ use std::sync::atomic::AtomicBool; use std::sync::Arc; use std::thread; -const ORPHAN_BLOCK_SIZE: usize = (BLOCK_DOWNLOAD_WINDOW * 2) as usize; +const ORPHAN_BLOCK_SIZE: usize = (BLOCK_DOWNLOAD_WINDOW) as usize; pub fn start_chain_services(builder: ChainServicesBuilder) -> ChainController { let orphan_blocks_broker = Arc::new(OrphanBlockPool::with_capacity(ORPHAN_BLOCK_SIZE)); @@ -24,7 +24,7 @@ pub fn start_chain_services(builder: ChainServicesBuilder) -> ChainController { let (unverified_queue_stop_tx, unverified_queue_stop_rx) = ckb_channel::bounded::<()>(1); let (unverified_tx, unverified_rx) = - channel::bounded::(BLOCK_DOWNLOAD_WINDOW as usize * 3); + channel::bounded::(BLOCK_DOWNLOAD_WINDOW as usize); let consumer_unverified_thread = thread::Builder::new() .name("consume_unverified_blocks".into()) @@ -44,8 +44,7 @@ pub fn start_chain_services(builder: ChainServicesBuilder) -> ChainController { }) .expect("start unverified_queue consumer thread should ok"); - let (lonely_block_tx, lonely_block_rx) = - channel::bounded::(BLOCK_DOWNLOAD_WINDOW as usize); + let (lonely_block_tx, lonely_block_rx) = channel::bounded::(0); let (search_orphan_pool_stop_tx, search_orphan_pool_stop_rx) = ckb_channel::bounded::<()>(1); @@ -68,7 +67,7 @@ pub fn start_chain_services(builder: ChainServicesBuilder) -> ChainController { }) .expect("start search_orphan_pool thread should ok"); - let (process_block_tx, process_block_rx) = channel::bounded(BLOCK_DOWNLOAD_WINDOW as usize); + let (process_block_tx, process_block_rx) = channel::bounded(0); let is_verifying_unverified_blocks_on_startup = Arc::new(AtomicBool::new(true));