ViNo-community/vite-node-bot

Add command for voter count

Closed this issue · 2 comments

Add command for voter count (number of people voting)

https://docs.vite.org/go-vite/api/rpc/contract_v2.html#contract-getsbpvotelist

Return current number of votes of all SBP nodes

Parameters:

Returns:

Array
sbpName: string Name of SBP
blockProducingAddress: string address Block producing addresss
votes: string bigint Number of votes

Input:

{
	"jsonrpc": "2.0",
	"id": 1,
	"method": "contract_getSBPVoteList",
	"params": []
}

Output:

{
    "jsonrpc": "2.0",
    "id": 1,
    "result": [
        {
            "sbpName": "s1",
            "blockProducingAddress": "vite_e41be57d38c796984952fad618a9bc91637329b5255cb18906",
            "votes": "100000000000000000000"
        },
        {
            "sbpName": "s2",
            "blockProducingAddress": "vite_0acbb1335822c8df4488f3eea6e9000eabb0f19d8802f57c87",
            "votes": "50000000000000000000"
        }
    ]
}

Grab output data where sbpName equals our SBP node (i.e. ViNo Community Node) and sum up number of votes.

Display information with !vote

No arguments gives full ranked list of SBPs with their respective votes.

Argument specifies SBP to display information for.