summaryrefslogtreecommitdiff
path: root/internal/vote.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/vote.go')
-rw-r--r--internal/vote.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/internal/vote.go b/internal/vote.go
index 3aadd53..b2db2d9 100644
--- a/internal/vote.go
+++ b/internal/vote.go
@@ -6,10 +6,12 @@ import (
"time"
)
+const voteExpiry = 20 * time.Second
+
type vote struct {
- from string
- ids []string
- time time.Time
+ from string
+ ids []string
+ expiresAt time.Time
}
func newVote(config config, from, message string) vote {
@@ -22,5 +24,10 @@ func newVote(config config, from, message string) vote {
ids = append(ids, id)
}
- return vote{stripPort(from), ids, time.Now()}
+ return vote{stripPort(from), ids, time.Now().Add(voteExpiry)}
+}
+
+func (v vote) expired() bool {
+ now := time.Now()
+ return now.After(v.expiresAt) || now.Equal(v.expiresAt)
}