Skip to content

Commit ef1b28f

Browse files
corecodeSimon Schubert
authored and
Simon Schubert
committed
sbft: don't act as primary if we're not active in view
Change-Id: Icab2222cae589f22e7e63050fe043ae56d5ea737 Signed-off-by: Simon Schubert <[email protected]>
1 parent ab67f34 commit ef1b28f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

orderer/sbft/simplebft/request.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func (s *SBFT) Request(req []byte) {
2424
}
2525

2626
func (s *SBFT) handleRequest(req *Request, src uint64) {
27-
if s.isPrimary() {
27+
if s.isPrimary() && s.activeView {
2828
s.batch = append(s.batch, req)
2929
if s.batchSize() >= s.config.BatchSizeBytes {
3030
s.maybeSendNextBatch()
@@ -56,7 +56,7 @@ func (s *SBFT) maybeSendNextBatch() {
5656
s.batchTimer = nil
5757
}
5858

59-
if !s.isPrimary() {
59+
if !s.isPrimary() || !s.activeView {
6060
return
6161
}
6262

orderer/sbft/simplebft/simplebft_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ func TestRestart(t *testing.T) {
352352
for _, r := range repls {
353353
r.sendViewChange()
354354
}
355+
sys.Run()
355356

356357
r1 := []byte{1, 2, 3}
357358
repls[0].Request(r1)
@@ -429,6 +430,7 @@ func TestRestartAfterPrepare(t *testing.T) {
429430
for _, r := range repls {
430431
r.sendViewChange()
431432
}
433+
sys.Run()
432434

433435
r1 := []byte{1, 2, 3}
434436
repls[0].Request(r1)
@@ -497,6 +499,7 @@ func TestRestartAfterCommit(t *testing.T) {
497499
for _, r := range repls {
498500
r.sendViewChange()
499501
}
502+
sys.Run()
500503

501504
r1 := []byte{1, 2, 3}
502505
repls[0].Request(r1)
@@ -565,6 +568,7 @@ func TestRestartAfterCheckpoint(t *testing.T) {
565568
for _, r := range repls {
566569
r.sendViewChange()
567570
}
571+
sys.Run()
568572

569573
r1 := []byte{1, 2, 3}
570574
repls[0].Request(r1)
@@ -653,6 +657,7 @@ func TestErroneousViewChange(t *testing.T) {
653657
for _, r := range repls {
654658
r.sendViewChange()
655659
}
660+
sys.Run()
656661

657662
r1 := []byte{1, 2, 3}
658663
repls[0].Request(r1)
@@ -717,6 +722,7 @@ func TestRestartMissedViewChange(t *testing.T) {
717722
r.sendViewChange()
718723
}
719724
}
725+
sys.Run()
720726

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

0 commit comments

Comments
 (0)