From eb8c914c3ba4b8bcc84c4f112a29fa54741200f7 Mon Sep 17 00:00:00 2001 From: fanlong Date: Sat, 11 Apr 2020 02:53:33 -0400 Subject: [PATCH] Quick fix duplicate consensus work (#1226) * Fix duplicate block sent to consensus worker * fmt * compile --- core/src/sync/synchronization_graph.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/sync/synchronization_graph.rs b/core/src/sync/synchronization_graph.rs index d849207e63..6714dfb0d8 100644 --- a/core/src/sync/synchronization_graph.rs +++ b/core/src/sync/synchronization_graph.rs @@ -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(); @@ -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,