changeset 46:8f5f20f6b685

Fix bug in vote collection for accepts
author Lewin Bormann <lbo@spheniscida.de>
date Fri, 26 Jul 2019 12:05:23 +0200
parents 5a328ba1b0e3
children 71b6822763da
files consensus_impl.go
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/consensus_impl.go	Fri Jul 26 11:38:14 2019 +0200
+++ b/consensus_impl.go	Fri Jul 26 12:05:23 2019 +0200
@@ -3,6 +3,7 @@
 import (
 	"fmt"
 	"sync"
+	"time"
 
 	"github.com/golang/glog"
 )
@@ -100,9 +101,13 @@
 			} else {
 				failedVotes++
 			}
-			if acquiredVotes >= requiredVotes {
+			if acquiredVotes >= requiredVotes || (acquiredVotes+failedVotes) >= len(p.members)-1 {
 				break loop
 			}
+		case <-time.NewTimer(5 * time.Second).C:
+			// This is not supposed to happen! Usually we wait for all votes/fails
+			glog.Error("timeout while waiting for accepts!")
+			break loop
 		}
 	}