Skip to content

Commit

Permalink
Insert orphan blocks and search orphan blocks in same thread
Browse files Browse the repository at this point in the history
  • Loading branch information
eval-exec committed Sep 1, 2023
1 parent 4a99124 commit 0838474
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ pub struct ChainService {

orphan_blocks_broker: Arc<OrphanBlockPool>,

new_block_tx: Sender<Switch>,
new_block_rx: Receiver<Switch>,
new_block_tx: Sender<(Arc<BlockView>, Switch)>,
new_block_rx: Receiver<(Arc<BlockView>, Switch)>,

unverified_tx: Sender<UnverifiedBlock>,
unverified_rx: Receiver<UnverifiedBlock>,
Expand All @@ -264,7 +264,7 @@ impl ChainService {
channel::bounded::<UnverifiedBlock>(BLOCK_DOWNLOAD_WINDOW as usize * 3);

let (new_block_tx, new_block_rx) =
channel::bounded::<Switch>(BLOCK_DOWNLOAD_WINDOW as usize);
channel::bounded::<(Arc<BlockView>, Switch)>(BLOCK_DOWNLOAD_WINDOW as usize);

ChainService {
shared,
Expand Down Expand Up @@ -450,7 +450,8 @@ impl ChainService {
return;
},
recv(self.new_block_rx) -> msg => match msg {
Ok(switch) => {
Ok((block, switch)) => {
self.orphan_blocks_broker.insert(block);
self.search_orphan_pool(switch)
},
Err(err) => {
Expand Down Expand Up @@ -660,9 +661,7 @@ impl ChainService {
self.non_contextual_verify(&block)?;
}

self.orphan_blocks_broker.insert(block);

match self.new_block_tx.send(switch) {
match self.new_block_tx.send((block, switch)) {
Ok(_) => {}
Err(err) => {
error!("notify new block to orphan pool err: {}", err)
Expand Down

0 comments on commit 0838474

Please sign in to comment.