diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2018-11-30 17:28:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-30 17:28:22 +0800 |
commit | 81c3d2d4446b5daee09529f58bc17cad3284edbf (patch) | |
tree | 1afdfc1ea5646ea558fc66c9493c3a29a38ff168 | |
parent | 043e340017df85ec058e1a22645c57272cd45772 (diff) | |
download | dexon-consensus-81c3d2d4446b5daee09529f58bc17cad3284edbf.tar dexon-consensus-81c3d2d4446b5daee09529f58bc17cad3284edbf.tar.gz dexon-consensus-81c3d2d4446b5daee09529f58bc17cad3284edbf.tar.bz2 dexon-consensus-81c3d2d4446b5daee09529f58bc17cad3284edbf.tar.lz dexon-consensus-81c3d2d4446b5daee09529f58bc17cad3284edbf.tar.xz dexon-consensus-81c3d2d4446b5daee09529f58bc17cad3284edbf.tar.zst dexon-consensus-81c3d2d4446b5daee09529f58bc17cad3284edbf.zip |
core: Fix stuffs (#351)
* Use non-blocking app in consensus core
* Prevent panic when getting nextHeight
-rw-r--r-- | core/agreement-mgr.go | 7 | ||||
-rw-r--r-- | core/consensus.go | 2 | ||||
-rw-r--r-- | core/consensus_test.go | 3 |
3 files changed, 10 insertions, 2 deletions
diff --git a/core/agreement-mgr.go b/core/agreement-mgr.go index f695e36..6f50bfc 100644 --- a/core/agreement-mgr.go +++ b/core/agreement-mgr.go @@ -387,7 +387,12 @@ Loop: for { nextHeight, err = mgr.lattice.NextHeight(recv.round, setting.chainID) if err != nil { - panic(err) + mgr.logger.Debug("Error getting next height", + "error", err, + "round", recv.round, + "chainID", setting.chainID) + err = nil + nextHeight = oldPos.Height } if isStop(oldPos) || nextHeight == 0 { break diff --git a/core/consensus.go b/core/consensus.go index 3c83c51..253c9a5 100644 --- a/core/consensus.go +++ b/core/consensus.go @@ -401,7 +401,7 @@ func NewConsensus( ID: ID, ccModule: newCompactionChain(gov), lattice: lattice, - app: app, + app: newNonBlocking(app, debugApp), gov: gov, db: db, network: network, diff --git a/core/consensus_test.go b/core/consensus_test.go index 7d4d6b4..dab5440 100644 --- a/core/consensus_test.go +++ b/core/consensus_test.go @@ -420,6 +420,9 @@ func (s *ConsensusTestSuite) TestSimpleDeliverBlock() { req.Equal(t, app.Delivered[b11.Hash].ConsensusTime) } for _, obj := range objs { + if nb, ok := obj.con.app.(*nonBlocking); ok { + nb.wait() + } verify(obj.app) } } |