diff options
Diffstat (limited to 'vendor/github.com/dexon-foundation/dexon-consensus/core/agreement-mgr.go')
-rw-r--r-- | vendor/github.com/dexon-foundation/dexon-consensus/core/agreement-mgr.go | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement-mgr.go b/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement-mgr.go index f65903d25..17def6747 100644 --- a/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement-mgr.go +++ b/vendor/github.com/dexon-foundation/dexon-consensus/core/agreement-mgr.go @@ -271,34 +271,48 @@ 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) } + if err == ErrSkipButNoError { + err = nil + } return } 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) } |