Skip to content

Commit

Permalink
Quick fix duplicate consensus work (#1226)
Browse files Browse the repository at this point in the history
* Fix duplicate block sent to consensus worker

* fmt

* compile
  • Loading branch information
fanlong authored and Peilun Li committed Apr 11, 2020
1 parent 1482349 commit eb8c914
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/src/sync/synchronization_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,9 @@ impl SynchronizationGraph {
'outer: loop {
'inner: loop {
match consensus_receiver.try_recv() {
Ok((hash, ignore_body)) => {
// FIXME: We need to investigate why duplicate hash may send to the consensus worker
Ok((hash, ignore_body)) => if !reverse_map.contains_key(&hash) {
debug!("Worker thread receive: block = {}", hash);
let header = data_man.block_header_by_hash(&hash).expect("Header must exist before sending to the consensus worker!");
let mut cnt: usize = 0;
let parent_hash = header.parent_hash();
Expand All @@ -1112,6 +1114,8 @@ impl SynchronizationGraph {
} else {
counter_map.insert(hash, (cnt, ignore_body));
}
} else {
warn!("Duplicate block = {} sent to the consensus worker", hash);
},
Err(TryRecvError::Empty) => break 'inner,
Err(TryRecvError::Closed) => break 'outer,
Expand Down

0 comments on commit eb8c914

Please sign in to comment.