From 22c04663bf832506b14fa1d2ab5a88d519bbd659 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 20 May 2023 00:19:53 +0300 Subject: votes can expire --- internal/quorum.go | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'internal/quorum.go') diff --git a/internal/quorum.go b/internal/quorum.go index 1307f20..1c8e451 100644 --- a/internal/quorum.go +++ b/internal/quorum.go @@ -2,17 +2,30 @@ package internal import ( "log" - "time" ) -type quorum struct { - ID string - Age time.Duration - Votes int -} +type quorumMap map[string]vote -type quorumMap map[string]quorum +type score struct { + id string + score int +} func (q quorumMap) vote(v vote) { log.Printf("Adding vote %v", v) + q[v.from] = v +} + +func (q quorumMap) score() (scores []score) { + /* + scoreMap := make(map[string]int) + var expired []string + + for from, vote := range q { + + for _, id := range vote.ids { + } + } + */ + return } -- cgit v1.2.3