Skip to content

Commit

Permalink
Merge "fix acceptance of sbft new-view messages"
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanLevi authored and Gerrit Code Review committed Dec 13, 2016
2 parents 16e028f + 0e3a6cf commit d5b10c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
8 changes: 3 additions & 5 deletions orderer/sbft/simplebft/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (s *SBFT) handleHello(h *Hello, src uint64) {
s.deliverBatch(h.Batch)
}

if h.NewView != nil {
if h.NewView != nil && s.view <= h.NewView.View {
if s.primaryIDView(h.NewView.View) != src {
log.Warningf("replica %d: invalid hello with new view from non-primary %d", s.id, src)
return
Expand All @@ -96,10 +96,8 @@ func (s *SBFT) handleHello(h *Hello, src uint64) {
return
}

if s.view <= h.NewView.View {
s.view = h.NewView.View
s.activeView = true
}
s.view = h.NewView.View
s.activeView = true

s.maybeDeliverUsingXset(h.NewView)
}
Expand Down
20 changes: 11 additions & 9 deletions orderer/sbft/simplebft/newview.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,18 @@ func (s *SBFT) checkNewViewSignatures(nv *NewView) ([]*ViewChange, error) {
}

func (s *SBFT) handleNewView(nv *NewView, src uint64) {
if src != s.primaryIDView(nv.View) {
log.Warningf("replica %d: invalid new view from %d for %d", s.id, src, nv.View)
if nv.View < s.view {
log.Debugf("replica %d: discarding old new view from %d for %d, we are in %d", s.id, src, nv.View, s.view)
return
}

if onv := s.replicaState[s.primaryIDView(nv.View)].newview; onv != nil && onv.View >= nv.View {
log.Debugf("replica %d: discarding duplicate new view for %d", s.id, nv.View)
if nv.View == s.view && s.activeView {
log.Debugf("replica %d: discarding new view from %d for %d, we are already active in %d", s.id, src, nv.View, s.view)
return
}

if src != s.primaryIDView(nv.View) {
log.Warningf("replica %d: invalid new view from %d for %d", s.id, src, nv.View)
return
}

Expand Down Expand Up @@ -135,11 +140,8 @@ func (s *SBFT) handleNewView(nv *NewView, src uint64) {
}

s.replicaState[s.primaryIDView(nv.View)].newview = nv

if nv.View > s.view {
s.view = nv.View
s.activeView = false
}
s.view = nv.View
s.activeView = false

s.processNewView()
}
Expand Down

0 comments on commit d5b10c9

Please sign in to comment.