diff options
| author | Paul Buetow <paul@buetow.org> | 2023-06-05 00:04:47 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2023-06-05 00:04:47 +0300 |
| commit | 0419ce65005190c25b5a86559919c2185e6b632f (patch) | |
| tree | 60424af9d3af9440589766274d78081e0aa3046b /internal | |
| parent | fc88fadb7151d51bbe09857f34dde73a336a5f06 (diff) | |
fix
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/quorum/quorum.go | 11 | ||||
| -rw-r--r-- | internal/quorum/quorum_test.go | 2 |
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) } } |
