Hive Developer logo

Hive Developer Portal

RB: Get Voters List On Post

This example will output the active vote totals for the post/comment passed as an argument to the script.

Full, runnable src of Get Voters List On Post can be downloaded as part of: tutorials/ruby (or download just this tutorial: devportal-master-tutorials-ruby-06_get_voters_list_on_post.zip).

Also see:

Script

voter_list.rb

First, we ask the blockchain for the active votes on a post or comment. Then, we count the upvotes, downvotes, and unvotes (which are votes that have been removed after being cast in a previous transaction).

Then, we sort the votes by rshares to find the top voter.

To Run

First, set up your workstation using the steps provided in Getting Started. Then you can create and execute the script (or clone from this repository):

git clone https://gitlab.syncad.com/hive/devportal.git
cd devportal/tutorials/ruby/06_get_voters_list_on_post
bundle install
ruby voter_list.rb https://hive.blog/communityfork/@hiveio/announcing-the-launch-of-hive-blockchain

Example Output

Upvotes: 997
Downvotes: 3
Unvotes: 0
Total: 1000
Top Voter: blocktrades