~edwargix/tallyard

ad84ff99086f19270c401242da94dea016519c75 — David Florness 4 years ago e2b87a4
Parse join election messages after parsing elections file
1 files changed, 4 insertions(+), 1 deletions(-)

M election/election.go
M election/election.go => election/election.go +4 -1
@@ 41,7 41,6 @@ func NewElection(candidates []Candidate, createEventId id.EventID,
func (el *Election) UnmarshalJSON(b []byte) error {
	type Alias Election // create alias to prevent endless loop
	tmp := (*Alias)(el)

	err := json.Unmarshal(b, tmp)
	if err != nil {
		return err


@@ 50,5 49,9 @@ func (el *Election) UnmarshalJSON(b []byte) error {
	if el.LocalVoter != nil {
		el.Joins[el.LocalVoter.JoinEvt.ID] = el.LocalVoter.Voter
	}
	for _, voter := range el.Joins {
		// TODO: for some reason I can't get this to work in (*Voter).UnmarshalJSON
		voter.JoinEvt.Content.ParseRaw(JoinElectionMessage)
	}
	return nil
}