Skip to content

Commit

Permalink
Feature/answer range (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
dantudor authored Mar 15, 2021
1 parent 18eaa5b commit 26e3b2b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions navcoind.go
Original file line number Diff line number Diff line change
Expand Up @@ -843,25 +843,28 @@ func (b *Navcoind) GetConsensusParameters(extended bool) (consensusParameters []
}

// GetConsultation returns information about the consultation with the given hash.
func (b *Navcoind) GetConsultation(hash string) (consultation Consultation, err error) {
func (b *Navcoind) GetConsultation(hash string) (Consultation, error) {
var consultation Consultation

r, err := b.client.call("getconsultation", []string{hash})
if err = handleError(err, &r); err != nil {
return
return consultation, err
}
err = json.Unmarshal(r.Result, &consultation)

if consultation.Version>>1&1 == 1 {
var answers []map[string]int
if err := json.Unmarshal(consultation.RawAnswers, &answers); err != nil {
return
return consultation, err
}
consultation.RangeAnswers = answers[0]
} else {
var answers []*Answer
if err := json.Unmarshal(consultation.RawAnswers, &answers); err != nil {
return
return consultation, err
}
consultation.Answers = answers
}
return

return consultation, err
}

0 comments on commit 26e3b2b

Please sign in to comment.