Skip to content

Commit

Permalink
sbft: don't act as primary if we're not active in view
Browse files Browse the repository at this point in the history
Change-Id: Icab2222cae589f22e7e63050fe043ae56d5ea737
Signed-off-by: Simon Schubert <sis@zurich.ibm.com>
  • Loading branch information
corecode authored and Simon Schubert committed Nov 21, 2016
1 parent ab67f34 commit ef1b28f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions orderer/sbft/simplebft/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (s *SBFT) Request(req []byte) {
}

func (s *SBFT) handleRequest(req *Request, src uint64) {
if s.isPrimary() {
if s.isPrimary() && s.activeView {
s.batch = append(s.batch, req)
if s.batchSize() >= s.config.BatchSizeBytes {
s.maybeSendNextBatch()
Expand Down Expand Up @@ -56,7 +56,7 @@ func (s *SBFT) maybeSendNextBatch() {
s.batchTimer = nil
}

if !s.isPrimary() {
if !s.isPrimary() || !s.activeView {
return
}

Expand Down
6 changes: 6 additions & 0 deletions orderer/sbft/simplebft/simplebft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ func TestRestart(t *testing.T) {
for _, r := range repls {
r.sendViewChange()
}
sys.Run()

r1 := []byte{1, 2, 3}
repls[0].Request(r1)
Expand Down Expand Up @@ -429,6 +430,7 @@ func TestRestartAfterPrepare(t *testing.T) {
for _, r := range repls {
r.sendViewChange()
}
sys.Run()

r1 := []byte{1, 2, 3}
repls[0].Request(r1)
Expand Down Expand Up @@ -497,6 +499,7 @@ func TestRestartAfterCommit(t *testing.T) {
for _, r := range repls {
r.sendViewChange()
}
sys.Run()

r1 := []byte{1, 2, 3}
repls[0].Request(r1)
Expand Down Expand Up @@ -565,6 +568,7 @@ func TestRestartAfterCheckpoint(t *testing.T) {
for _, r := range repls {
r.sendViewChange()
}
sys.Run()

r1 := []byte{1, 2, 3}
repls[0].Request(r1)
Expand Down Expand Up @@ -653,6 +657,7 @@ func TestErroneousViewChange(t *testing.T) {
for _, r := range repls {
r.sendViewChange()
}
sys.Run()

r1 := []byte{1, 2, 3}
repls[0].Request(r1)
Expand Down Expand Up @@ -717,6 +722,7 @@ func TestRestartMissedViewChange(t *testing.T) {
r.sendViewChange()
}
}
sys.Run()

r2 := []byte{3, 1, 2}
repls[1].Request(r2)
Expand Down

0 comments on commit ef1b28f

Please sign in to comment.