Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display aggregate vote stats in listgovproposalvotes #1708

Closed
shohamc1 opened this issue Jan 26, 2023 · 1 comment · Fixed by #1714
Closed

Display aggregate vote stats in listgovproposalvotes #1708

shohamc1 opened this issue Jan 26, 2023 · 1 comment · Fixed by #1714
Assignees

Comments

@shohamc1
Copy link
Contributor

shohamc1 commented Jan 26, 2023

listgovproposalvotes just returns a list of votes of a proposal. There is no way to find aggregate stats such as total number of votes, total number of yes, no and neutral via the RPC, which means users and applications have to write additional scripts to find this information.

listgovproposalvotes should instead return the aggregate stats along with the raw data. This can be achieved with a new argument, which when enabled will return the aggregate stats.

Current

$ ./defi-cli -testnet listgovproposalvotes 'b1d19f0a1326655148ebdc967dbf0ffcbbf0bb822069737475c7deac3efc9af1' 'all' 0
[
  {
    "proposalId": "b1d19f0a1326655148ebdc967dbf0ffcbbf0bb822069737475c7deac3efc9af1",
    "masternodeId": "dba7c2e1d62e528b38ad3725966945fe7ecfee6339a304fd865a6a6944ab1a00",
    "cycle": 1,
    "vote": "YES"
  },
  {
    "proposalId": "b1d19f0a1326655148ebdc967dbf0ffcbbf0bb822069737475c7deac3efc9af1",
    "masternodeId": "0c883a4c9b371d04ffc3afffa0c3f25cf47e019e888742893fdd3ff37afd3500",
    "cycle": 1,
    "vote": "YES"
  },
...

After proposed change

$ ./defi-cli -testnet listgovproposalvotes 'b1d19f0a1326655148ebdc967dbf0ffcbbf0bb822069737475c7deac3efc9af1' 'all' 0 true
[
  {
    "proposalId": "b1d19f0a1326655148ebdc967dbf0ffcbbf0bb822069737475c7deac3efc9af1",
    "total": 100,
    "yes": 50,
    "no": 30,
    "neutral": 20
  }
]
$ ./defi-cli -testnet listgovproposalvotes
[
  {
    "proposalId": "b1d19f0a1326655148ebdc967dbf0ffcbbf0bb822069737475c7deac3efc9af1",
    "total": 100,
    "yes": 50,
    "no": 30,
    "neutral": 20
  },
  {
    "proposalId": "7025b328f77cfa7f79139ddbbf25a660798b93546ec4879276e05fe31de3b6e6",
    "total": 100,
    "yes": 50,
    "no": 20,
    "neutral": 30
  },
  ...
]
@prasannavl
Copy link
Member

Ah, this is neat. Can't break the existing API however. How about making proposalId optional and actually list out all aggregates in one go - this would be a new API, so we don't break existing usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants