Skip to content

Commit

Permalink
reduce channel length
Browse files Browse the repository at this point in the history
  • Loading branch information
eval-exec committed Mar 21, 2024
1 parent 6b2d4a0 commit 1ee9732
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions chain/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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::<LonelyBlockHash>(BLOCK_DOWNLOAD_WINDOW as usize * 3);
channel::bounded::<LonelyBlockHash>(BLOCK_DOWNLOAD_WINDOW as usize);

let consumer_unverified_thread = thread::Builder::new()
.name("consume_unverified_blocks".into())
Expand All @@ -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::<LonelyBlockHash>(BLOCK_DOWNLOAD_WINDOW as usize);
let (lonely_block_tx, lonely_block_rx) = channel::bounded::<LonelyBlockHash>(0);

let (search_orphan_pool_stop_tx, search_orphan_pool_stop_rx) = ckb_channel::bounded::<()>(1);

Expand All @@ -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));

Expand Down

0 comments on commit 1ee9732

Please sign in to comment.