diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-11-05 18:36:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-05 18:36:13 +0800 |
commit | f3e03e18d815d92493d3a85ecb3a0048247ecf71 (patch) | |
tree | f8b173ea6f013b30a996a875078907890d6a64de | |
parent | 916831419352e00876e8323b3e5243170107719b (diff) | |
download | dexon-consensus-f3e03e18d815d92493d3a85ecb3a0048247ecf71.tar.gz dexon-consensus-f3e03e18d815d92493d3a85ecb3a0048247ecf71.tar.zst dexon-consensus-f3e03e18d815d92493d3a85ecb3a0048247ecf71.zip |
core: Fix deadlock (#298)
-rw-r--r-- | core/consensus.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/core/consensus.go b/core/consensus.go index 2eed101..56c757b 100644 --- a/core/consensus.go +++ b/core/consensus.go @@ -159,6 +159,15 @@ func (recv *consensusBAReceiver) ConfirmBlock( recv.consensus.logger.Error("Failed to process block", "error", err) return } + // Clean the restartNotary channel so BA will not stuck by deadlock. +CleanChannelLoop: + for { + select { + case <-recv.restartNotary: + default: + break CleanChannelLoop + } + } if block.Timestamp.After(recv.changeNotaryTime) { recv.round++ recv.restartNotary <- true |