From 26e3b2b44b20ece8474fa3211a3481b042129ca7 Mon Sep 17 00:00:00 2001 From: Dan Tudor Date: Mon, 15 Mar 2021 18:59:47 +0000 Subject: [PATCH] Feature/answer range (#6) --- navcoind.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/navcoind.go b/navcoind.go index be935f9..18c22b7 100644 --- a/navcoind.go +++ b/navcoind.go @@ -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 }