diff options
| author | Paul Buetow <paul@buetow.org> | 2023-11-04 15:28:16 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2023-11-04 15:28:16 +0200 |
| commit | 314aa39afda105969567c4f95b07147f372fcf98 (patch) | |
| tree | 62ead034a09bb328e3995da887d29e8cdfe69b00 /internal/quorum/score.go | |
| parent | 09ecd479863cf5db5b91776b64324660e23eeb97 (diff) | |
move Score to its own file
Diffstat (limited to 'internal/quorum/score.go')
| -rw-r--r-- | internal/quorum/score.go | 26 |
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 +} |
