Implement cli wallet command/api endpoint to retrieve voting info #260

Closed
opened 2022-01-20 15:08:16 +00:00 by serkixenos · 29 comments
serkixenos commented 2022-01-20 15:08:16 +00:00 (Migrated from gitlab.com)

We want to be able to retrieve the list of accounts who voted for certain votable object (committee member, witness, worker, son).

E.g.

get_voters committee_member_id | witness_id | worker_id | son_id | account_id | account_name

The output should be a list of account names that voted for votable object provided. Additional logic should be implemented to identify type of object, especially when account name or id is used, as single account can be owner of committee member, witness, worked or SON.

We also want to be able to retrieve the list of votable objects voted by certain account.

get_votes account_id | account_name

The output should be a list of votable object type and owner accounts names.

For collecting data required, we will use vote_id member of votable object structures. However, index structures are not optimized for fast retrieval of voting info, so retrieval might be slower than what we want.

We want to be able to retrieve the list of accounts who voted for certain votable object (committee member, witness, worker, son). E.g. ``` get_voters committee_member_id | witness_id | worker_id | son_id | account_id | account_name ``` The output should be a list of account names that voted for votable object provided. Additional logic should be implemented to identify type of object, especially when account name or id is used, as single account can be owner of committee member, witness, worked or SON. We also want to be able to retrieve the list of votable objects voted by certain account. ``` get_votes account_id | account_name ``` The output should be a list of votable object type and owner accounts names. For collecting data required, we will use vote_id member of votable object structures. However, index structures are not optimized for fast retrieval of voting info, so retrieval might be slower than what we want.
serkixenos commented 2022-01-20 15:08:17 +00:00 (Migrated from gitlab.com)

assigned to @vampik

assigned to @vampik
vampik commented 2022-01-20 17:09:12 +00:00 (Migrated from gitlab.com)

@serkixenos

Maybe we should also add separate functions for different types of object?

I mean:

get_committee_member_voters committee_member_id

get_witness_voters witness_id

get_worker_voters worker_id

get_son_voters son_id

@serkixenos Maybe we should also add separate functions for different types of object? I mean: `get_committee_member_voters committee_member_id` `get_witness_voters witness_id` `get_worker_voters worker_id` `get_son_voters son_id`
hbelakon commented 2022-01-21 04:32:34 +00:00 (Migrated from gitlab.com)

@vampik please estimate. I will put 2d/weight 2

@vampik please estimate. I will put 2d/weight 2
hbelakon commented 2022-01-21 04:32:47 +00:00 (Migrated from gitlab.com)

changed time estimate to 16h

changed time estimate to 16h
vampik commented 2022-01-21 04:39:20 +00:00 (Migrated from gitlab.com)

changed time estimate to 24h

changed time estimate to 24h
vampik commented 2022-02-04 06:20:54 +00:00 (Migrated from gitlab.com)

mentioned in commit 889265406a

mentioned in commit 889265406a56af658eaebe034bca41aa88432109
vampik commented 2022-02-04 11:28:57 +00:00 (Migrated from gitlab.com)

mentioned in commit cd737b57fe

mentioned in commit cd737b57fe8efed4affe847e235340b213655bf1
vampik commented 2022-02-04 11:28:57 +00:00 (Migrated from gitlab.com)

mentioned in commit eb43bc3635

mentioned in commit eb43bc3635d6332fab9f9c2f152f9dff3b2ba56b
vampik commented 2022-02-04 11:28:57 +00:00 (Migrated from gitlab.com)

mentioned in commit 2d237469a0

mentioned in commit 2d237469a0f7e092d646dfc2126130aea43ebb64
vampik commented 2022-02-04 11:28:57 +00:00 (Migrated from gitlab.com)

mentioned in commit 0f3ea3d637

mentioned in commit 0f3ea3d637f0c83805950641897cc776150d54c9
vampik commented 2022-02-07 06:30:52 +00:00 (Migrated from gitlab.com)

mentioned in commit 6bcea17f28

mentioned in commit 6bcea17f28a660cd9655b7583e1584a85447f73d
vampik commented 2022-02-07 06:31:31 +00:00 (Migrated from gitlab.com)

added 24h of time spent

added 24h of time spent
vampik commented 2022-02-07 06:33:01 +00:00 (Migrated from gitlab.com)

Have added functions (both to database_api and wallet_api):

get_votes account_id | account_name

get_voters committee_member_id | witness_id | worker_id | son_id | account_id | account_name

Have added functions (both to `database_api` and `wallet_api`): `get_votes account_id | account_name` `get_voters committee_member_id | witness_id | worker_id | son_id | account_id | account_name`
vampik commented 2022-02-07 06:33:30 +00:00 (Migrated from gitlab.com)

Also have added this functions to Unit Test

Also have added this functions to Unit Test
vampik commented 2022-02-07 06:38:26 +00:00 (Migrated from gitlab.com)

mentioned in merge request !59

mentioned in merge request !59
vampik commented 2022-02-08 08:05:48 +00:00 (Migrated from gitlab.com)

mentioned in commit 558e3c0045

mentioned in commit 558e3c004596ffadc0b58f7dbabd8dde36a7cd4c
vampik commented 2022-02-08 08:05:48 +00:00 (Migrated from gitlab.com)

mentioned in commit 504680f727

mentioned in commit 504680f727fc4d7dbfbe91b9589f14419370ca58
vampik commented 2022-02-08 08:05:48 +00:00 (Migrated from gitlab.com)

mentioned in commit 9c7c3d2e14

mentioned in commit 9c7c3d2e14ef183b2c261c9ac52fc2d837394f88
vampik commented 2022-02-08 08:06:12 +00:00 (Migrated from gitlab.com)

fixed get_workers_by_account()

fixed get_workers_by_account()
vampik commented 2022-02-08 08:06:56 +00:00 (Migrated from gitlab.com)

Additionaly i have made all members for voters_info and votes_info as optional

Additionaly i have made all members for `voters_info` and `votes_info` as optional
serkixenos commented 2022-02-08 14:14:12 +00:00 (Migrated from gitlab.com)

assigned to @prandnum and unassigned @vampik

assigned to @prandnum and unassigned @vampik
vampik commented 2022-02-09 06:25:08 +00:00 (Migrated from gitlab.com)

assigned to @vampik

assigned to @vampik
vampik commented 2022-02-09 06:49:33 +00:00 (Migrated from gitlab.com)

@prandnum

Here is new functionality:

Function get_votes (return list's of objects this account has voted for):

get_votes account_id | account_name

Function get_voters (return list's of accounts that have voted for this committee_member/witness/worker/son).
As account can be owner of committee member, witness, worked or SON at the same time, can return voters both for witness and son, for example.

get_voters committee_member_id | witness_id | worker_id | son_id | account_id | account_name

@prandnum Here is new functionality: Function get_votes (return list's of objects this account has voted for): `get_votes account_id | account_name` Function get_voters (return list's of accounts that have voted for this committee_member/witness/worker/son). As account can be owner of committee member, witness, worked or SON at the same time, can return voters both for witness and son, for example. `get_voters committee_member_id | witness_id | worker_id | son_id | account_id | account_name`
vampik commented 2022-02-09 07:00:56 +00:00 (Migrated from gitlab.com)

@prandnum

For testing database_api separately from cli_wallet we can use curl commands:

Example for get_votes:

curl --data '{"method": "call", "params": ["database", "get_votes", ["nathan"]], "jsonrpc": "2.0", "id": 1}' localhost:8090

Example for get_voters:

curl --data '{"method": "call", "params": ["database", "get_voters", ["1.6.2"]], "jsonrpc": "2.0", "id": 1}' localhost:8090

@prandnum For testing database_api separately from cli_wallet we can use curl commands: Example for get_votes: `curl --data '{"method": "call", "params": ["database", "get_votes", ["nathan"]], "jsonrpc": "2.0", "id": 1}' localhost:8090` Example for get_voters: `curl --data '{"method": "call", "params": ["database", "get_voters", ["1.6.2"]], "jsonrpc": "2.0", "id": 1}' localhost:8090`
serkixenos commented 2022-02-09 16:06:26 +00:00 (Migrated from gitlab.com)
API reference https://devs.peerplays.tech/api-reference/peerplays-core-api
prandnum commented 2022-02-10 19:50:04 +00:00 (Migrated from gitlab.com)
curl --data '{"method": "call", "params": ["database", "get_votes", ["nathan"]], "jsonrpc": "2.0", "id": 1}' localhost:8090

{"id":1,"jsonrpc":"2.0","result":{}}

curl --data '{"method": "call", "params": ["database", "get_voters", ["1.6.1"]], "jsonrpc": "2.0", "id": 1}' localhost:8090

{"id":1,"jsonrpc":"2.0","result":{"voters_for_committee_member":{"vote_id":"0:11","voters":[]},"voters_for_witness":{"vote_id":"1:0","voters":[]}}}
``` curl --data '{"method": "call", "params": ["database", "get_votes", ["nathan"]], "jsonrpc": "2.0", "id": 1}' localhost:8090 {"id":1,"jsonrpc":"2.0","result":{}} curl --data '{"method": "call", "params": ["database", "get_voters", ["1.6.1"]], "jsonrpc": "2.0", "id": 1}' localhost:8090 {"id":1,"jsonrpc":"2.0","result":{"voters_for_committee_member":{"vote_id":"0:11","voters":[]},"voters_for_witness":{"vote_id":"1:0","voters":[]}}} ```
prandnum (Migrated from gitlab.com) closed this issue 2022-02-10 19:50:13 +00:00
vampik commented 2022-02-10 21:11:09 +00:00 (Migrated from gitlab.com)

mentioned in commit d7e24bfb07

mentioned in commit d7e24bfb0761437529455c7164364f1c05683e6d
serkixenos commented 2022-02-10 21:11:09 +00:00 (Migrated from gitlab.com)

mentioned in commit a284f42ac9

mentioned in commit a284f42ac95a04c9a6a03f53a94fe99727d038d4
vampik commented 2022-02-28 10:49:37 +00:00 (Migrated from gitlab.com)

mentioned in issue #280

mentioned in issue #280
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Peerplays_Blockchain/peerplays_migrated#260
No description provided.