From eaca6c35b506b2c686493ac71b996cc4fade53a0 Mon Sep 17 00:00:00 2001 From: Cy Rossignol Date: Tue, 17 Nov 2020 18:57:42 -0600 Subject: [PATCH] Fix answer offset in "votedetails" RPC The answer offset value output in the "id" property contained a counter instead of the actual offset of the choice from the original poll. --- src/rpcvoting.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rpcvoting.cpp b/src/rpcvoting.cpp index decd0fcea7..df8678ee63 100644 --- a/src/rpcvoting.cpp +++ b/src/rpcvoting.cpp @@ -133,12 +133,12 @@ UniValue VoteDetailsToJson(const PollResult& result) UniValue answers(UniValue::VARR); PollResult::Weight total_weight = 0; - for (size_t i = 0; i < detail.m_responses.size(); ++i) { + for (const auto& answer_pair : detail.m_responses) { UniValue answer(UniValue::VOBJ); - answer.pushKV("id", (int)i); - answer.pushKV("weight", ValueFromAmount(detail.m_responses[i].second)); + answer.pushKV("id", (int)answer_pair.first); + answer.pushKV("weight", ValueFromAmount(answer_pair.second)); - total_weight += detail.m_responses[i].second; + total_weight += answer_pair.second; answers.push_back(answer); }