aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMission Liao <mission.liao@dexon.org>2018-10-24 11:27:10 +0800
committerGitHub <noreply@github.com>2018-10-24 11:27:10 +0800
commit5212bb83e8c257cfd85f9e891740369ecad36a91 (patch)
treeb87ee320f6402415fd96ab397884d4de1b1d07d6
parent23779823a7816d07c41fd7c135c6c0edf39182db (diff)
downloaddexon-consensus-5212bb83e8c257cfd85f9e891740369ecad36a91.tar
dexon-consensus-5212bb83e8c257cfd85f9e891740369ecad36a91.tar.gz
dexon-consensus-5212bb83e8c257cfd85f9e891740369ecad36a91.tar.bz2
dexon-consensus-5212bb83e8c257cfd85f9e891740369ecad36a91.tar.lz
dexon-consensus-5212bb83e8c257cfd85f9e891740369ecad36a91.tar.xz
dexon-consensus-5212bb83e8c257cfd85f9e891740369ecad36a91.tar.zst
dexon-consensus-5212bb83e8c257cfd85f9e891740369ecad36a91.zip
core: fix panic when proposed block is nil (#248)
-rw-r--r--core/consensus.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/core/consensus.go b/core/consensus.go
index c7bef4b..9e6768c 100644
--- a/core/consensus.go
+++ b/core/consensus.go
@@ -81,6 +81,10 @@ func (recv *consensusBAReceiver) ProposeVote(vote *types.Vote) {
func (recv *consensusBAReceiver) ProposeBlock() common.Hash {
block := recv.consensus.proposeBlock(recv.chainID, recv.round)
+ if block == nil {
+ recv.consensus.logger.Error("unable to propose block")
+ return nullBlockHash
+ }
recv.consensus.baModules[recv.chainID].addCandidateBlock(block)
if err := recv.consensus.preProcessBlock(block); err != nil {
recv.consensus.logger.Error("Failed to pre-process block", "error", err)