summaryrefslogtreecommitdiff
path: root/internal/quorum/score.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2023-11-04 15:28:16 +0200
committerPaul Buetow <paul@buetow.org>2023-11-04 15:28:16 +0200
commit314aa39afda105969567c4f95b07147f372fcf98 (patch)
tree62ead034a09bb328e3995da887d29e8cdfe69b00 /internal/quorum/score.go
parent09ecd479863cf5db5b91776b64324660e23eeb97 (diff)
move Score to its own file
Diffstat (limited to 'internal/quorum/score.go')
-rw-r--r--internal/quorum/score.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/internal/quorum/score.go b/internal/quorum/score.go
new file mode 100644
index 0000000..d67b791
--- /dev/null
+++ b/internal/quorum/score.go
@@ -0,0 +1,26 @@
+package quorum
+
+import (
+ "fmt"
+ "time"
+)
+
+type Score struct {
+ ID string
+ Value int
+ time time.Time
+}
+
+func (s Score) Is(other Score) bool {
+ return s.ID == other.ID && s.Value == other.Value
+}
+
+type Scores []Score
+
+func (s Scores) Winner() (Score, error) {
+ if len(s) == 0 {
+ return Score{}, fmt.Errorf("emtpy score, no winner")
+ }
+
+ return s[0], nil
+}