From 16019def84f61d4adc9e25e4bd2d0a6c8bf36c40 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 20 May 2023 01:41:36 +0300 Subject: run expiry after expiryTime automatically --- internal/quorum.go | 1 - internal/run.go | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/quorum.go b/internal/quorum.go index b506bfb..179efb1 100644 --- a/internal/quorum.go +++ b/internal/quorum.go @@ -27,7 +27,6 @@ func (q quorumMap) winner(config config) (string, error) { } func (q quorumMap) score(config config) (scores []score) { - q.cleanExpired() scoreMap := make(map[string]int) for _, vote := range q { diff --git a/internal/run.go b/internal/run.go index 8f73b19..50a5b6f 100644 --- a/internal/run.go +++ b/internal/run.go @@ -3,6 +3,7 @@ package internal import ( "context" "log" + "time" ) func Run(ctx context.Context, configFile string) { @@ -25,6 +26,8 @@ func Run(ctx context.Context, configFile string) { continue } log.Printf("The current leader node is %s", winner) + case <-time.After(voteExpiry): + quorum.cleanExpired() case <-ctx.Done(): return } -- cgit v1.2.3