summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/quorum/quorum.go11
-rw-r--r--internal/quorum/quorum_test.go2
2 files changed, 10 insertions, 3 deletions
diff --git a/internal/quorum/quorum.go b/internal/quorum/quorum.go
index 79fea11..44834f3 100644
--- a/internal/quorum/quorum.go
+++ b/internal/quorum/quorum.go
@@ -40,6 +40,7 @@ func (quo Quorum) Start(ctx context.Context) <-chan []string {
select {
case <-time.After(vote.Expiry):
if liveNodes, changed := quo.liveNodes(); changed {
+ quo.score()
liveNodesCh <- liveNodes
}
case vote := <-quo.voteCh:
@@ -108,15 +109,19 @@ func (quo *Quorum) liveNodes() ([]string, bool) {
}
for _, x := range newLiveNodes {
+ var found bool
for _, y := range quo.prevLiveNodes {
if x == y {
- continue
+ found = true
+ break
}
- return newLiveNodes, false
+ }
+ if !found {
+ return newLiveNodes, true
}
}
- return newLiveNodes, true
+ return newLiveNodes, false
}
func (quo Quorum) deleteExpiredVotes() (liveNodes []string) {
diff --git a/internal/quorum/quorum_test.go b/internal/quorum/quorum_test.go
index e1463e2..e8c02a7 100644
--- a/internal/quorum/quorum_test.go
+++ b/internal/quorum/quorum_test.go
@@ -142,7 +142,9 @@ func TestLiveNodes(t *testing.T) {
t.Errorf("Expected live node list to be changed: %v", liveNodes)
}
+ t.Log(quo.prevLiveNodes)
if liveNodes, changed := quo.liveNodes(); changed {
+ t.Log(quo.prevLiveNodes)
t.Errorf("Expected live node list not to be changed: %v", liveNodes)
}
}