diff options
author | Jimmy Hu <jimmy.hu@dexon.org> | 2019-04-15 18:50:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-15 18:50:35 +0800 |
commit | ccba7be9105c01eba0617e5ec0a791436200a132 (patch) | |
tree | 4c88741f37be02d4bdd46695ecd3e2e52a9fbcee /core/agreement-mgr.go | |
parent | d554efde81d4385158c039f906e213bcdfd0313b (diff) | |
download | dexon-consensus-ccba7be9105c01eba0617e5ec0a791436200a132.tar dexon-consensus-ccba7be9105c01eba0617e5ec0a791436200a132.tar.gz dexon-consensus-ccba7be9105c01eba0617e5ec0a791436200a132.tar.bz2 dexon-consensus-ccba7be9105c01eba0617e5ec0a791436200a132.tar.lz dexon-consensus-ccba7be9105c01eba0617e5ec0a791436200a132.tar.xz dexon-consensus-ccba7be9105c01eba0617e5ec0a791436200a132.tar.zst dexon-consensus-ccba7be9105c01eba0617e5ec0a791436200a132.zip |
core: optimize handling for bad block (#574)
* core: optimize handling for bad block
* fix test
Diffstat (limited to 'core/agreement-mgr.go')
-rw-r--r-- | core/agreement-mgr.go | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/core/agreement-mgr.go b/core/agreement-mgr.go index ef1730c..17def67 100644 --- a/core/agreement-mgr.go +++ b/core/agreement-mgr.go @@ -271,26 +271,34 @@ func (mgr *agreementMgr) notifyRoundEvents(evts []utils.RoundEventParam) error { return nil } -func (mgr *agreementMgr) processVote(v *types.Vote) (err error) { - if !mgr.recv.isNotary { - return nil - } - if mgr.voteFilter.Filter(v) { - return nil - } - if v.Position.Round == mgr.curRoundSetting.round { - if _, exist := mgr.curRoundSetting.dkgSet[v.ProposerID]; !exist { +func (mgr *agreementMgr) checkProposer( + round uint64, proposerID types.NodeID) error { + if round == mgr.curRoundSetting.round { + if _, exist := mgr.curRoundSetting.dkgSet[proposerID]; !exist { return ErrNotInNotarySet } - } else if v.Position.Round == mgr.curRoundSetting.round+1 { - setting := mgr.generateSetting(v.Position.Round) + } else if round == mgr.curRoundSetting.round+1 { + setting := mgr.generateSetting(round) if setting == nil { return ErrConfigurationNotReady } - if _, exist := setting.dkgSet[v.ProposerID]; !exist { + if _, exist := setting.dkgSet[proposerID]; !exist { return ErrNotInNotarySet } } + return nil +} + +func (mgr *agreementMgr) processVote(v *types.Vote) (err error) { + if !mgr.recv.isNotary { + return nil + } + if mgr.voteFilter.Filter(v) { + return nil + } + if err := mgr.checkProposer(v.Position.Round, v.ProposerID); err != nil { + return err + } if err = mgr.baModule.processVote(v); err == nil { mgr.baModule.updateFilter(mgr.voteFilter) mgr.voteFilter.AddVote(v) @@ -302,6 +310,9 @@ func (mgr *agreementMgr) processVote(v *types.Vote) (err error) { } func (mgr *agreementMgr) processBlock(b *types.Block) error { + if err := mgr.checkProposer(b.Position.Round, b.ProposerID); err != nil { + return err + } return mgr.baModule.processBlock(b) } |