TODOs, clarity

This commit is contained in:
Ian Gulliver
2023-06-01 08:46:56 -07:00
parent 755ddc99f7
commit 4da068ed5c
2 changed files with 5 additions and 1 deletions

View File

@@ -142,6 +142,7 @@ func (c *Candidate) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
w.Header().Set("Content-Type", "application/json")
// TODO: Sign responses
enc := json.NewEncoder(w)

View File

@@ -23,6 +23,7 @@ type vote struct {
VoterID string `json:"voterID"`
LastSeenCandidateID string `json:"lastSeenCandidateID"`
NumPollsSinceChange int `json:"numPollsSinceChange"`
// TODO: Add timestamp
// Used internally by Candidate
received time.Time
@@ -30,6 +31,7 @@ type vote struct {
type voteResponse struct {
CandidateID string `json:"candidateID"`
// TODO: Add timestamp
}
func NewVoter(url string, signingKey string) *Voter {
@@ -63,6 +65,7 @@ func (v *Voter) AddCandidate(c *Candidate) {
}
func (v *Voter) loop(update <-chan time.Duration, done chan<- bool) {
// TODO: Need a JitterTicker
t := time.NewTicker(5 * time.Second)
defer t.Stop()
defer close(done)
@@ -77,7 +80,7 @@ func (v *Voter) loop(update <-chan time.Duration, done chan<- bool) {
func (v *Voter) poll(update <-chan time.Duration, t *time.Ticker) bool {
t2 := &time.Timer{}
if v.vote.NumPollsSinceChange < 11 {
if v.vote.NumPollsSinceChange <= 10 {
t2 = time.NewTimer(100 * time.Millisecond)
defer t2.Stop()
}