@@ 2,6 2,7 @@ package main
import (
"fmt"
+ "os"
"sort"
"strconv"
"unicode"
@@ 17,9 18,18 @@ func tui() (election *Election, merkleRoot []byte, electionKey string) {
switch buttonLabel {
case "Create Election":
election.candidates = createElection()
+ // TODO: slaves should check that len candidates >= 2
+ if election.candidates == nil || len(election.candidates) == 0 {
+ fmt.Printf("no candidates entered; exiting\n")
+ os.Exit(0)
+ }
merkleRoot = election.createMerkle(election.candidates)
case "Join Election":
electionKey := joinElection()
+ if electionKey == "" {
+ fmt.Printf("no election key given; exiting\n")
+ os.Exit(0)
+ }
merkleRoot, election.masterID = splitElectionKey(electionKey)
}
}