regult.rb - Proxy Sentinel

in #radiator6 years ago (edited)

Overview

Regult (regult.rb) is a proxy sentinel that streams the blockchain, looking for proxy/unproxy operations to update a local text file with a list of accounts that proxy their witness vote to a particular account you're interested in tracking.

In addition to streaming the blockchain, in order to save time and resources, this script will also initialize the list from data on Steem SQL. Since Steem SQL is a paid service, I figure using Steem SQL should be optional. If you can manually initialize the proxy-list.txt file using some other method, using Steem SQL should not be required.

It's also possible to just let Regult build the proxy-list.txt file from the Genesis block, but that's a bad idea if you're using a public node. Don't do that.


Install

To use this Radiator script:

Linux
$ sudo apt-get update
$ sudo apt-get install ruby-full git openssl libssl1.0.0 libssl-dev
$ sudo apt-get upgrade
$ gem install bundler
macOS
$ gem install bundler

I've tested it on various versions of ruby. The oldest one I got it to work was:

ruby 2.2.5p319 (2016-04-26 revision 54774) [x86_64-darwin17]

First, clone this gist and install the dependencies:

$ git clone https://gist.github.com/cfce5b47fa0f5b1eae0c6dd9c653ca7d.git regult
$ cd regult
$ bundle install

You should edit regult.yml and point it at the correct account (proxy_target_account).

If you intend to use Steem SQL, you can provide the credentials in authorize-steem-sql.sh, then use this terminal command to enable Steem SQL just before running this script:

source authorize-steem-sql.sh

Now you can skip to ruby regult.rb.

Otherwise, if you do not intend to use Steem SQL, in order to avoid long replays, get a list of accounts that currently proxy to proxy_target_account and create a file called proxy-list.txt with the entire list of account names only, one account name per line (you can typically get this list from steemdb.com, for example: https://steemdb.com/@jesta/proxied is a list of accounts that proxy to jesta).

Then create a file called last-block-num.txt and add a single line with the latest block number, or whatever number you'd like to begin streaming from.

Once those two files exist, you can run this script and the proxy-list.txt file will be kept current whenever a relevant proxy/unproxy operation is seen.

Then run it:

$ ruby regult.rb

Regult will now do it's thing. Check here to see an updated version of this script:


Upgrade

Typically, you can upgrade to the latest version by this command, from the original directory you cloned into:

$ git pull

Usually, this works fine as long as you haven't modified anything. If you get an error, try this:

$ git stash --all
$ git pull --rebase
$ git stash pop

If you're still having problems, I suggest starting a new clone.


Troubleshooting

Problem: What does this error mean?
regult.yml:1: syntax error, unexpected ':', expecting end-of-input
Solution: You ran ruby regult.yml but you should run ruby regult.rb.
Problem: The node I'm using is down.

Is there a list of nodes?

Solution: Yes, special thanks to @jamzed.

https://geo.steem.pl/








art by randychen

See my previous Ruby How To posts in: #radiator #ruby

Get in touch!

If you're using Regult, I'd love to hear from you. Drop me a line and tell me what you think! I'm @inertia on STEEM and SteemSpeak.

License

I don't believe in intellectual "property". If you do, consider Regult as licensed under a Creative Commons CC0 License.

Sort:  

Nice organized post, but while I follow your posts I must say that I still face some issues to understanding the tools and their use. Maybe in the overview you can put up some examples and explain at what the tool is used for in a more "human" way as I would really like to learn, but not sure from were to start when I find such information. I know that it all makes sense for you as you are like the fish in the water with all these technologies and tools, but I think that explaining a little bit with a broad sense would make others follow and try these new things. Thanks, nevertheless!

It solves a problem that cannot be solved by typical methods. In this case, say I want to know all of the accounts that proxy their witness votes to me at any given time. The blockchain knows, but it’s not telling. This script figures it out without needing to read the entire 824 days worth of blocks from beginning to end.

Nice trick to get that info revealed using this script, thanks for the info!

I'm learning so much from your commits @inertia! Thank you for all your work man. By the way, a question I've been meaning to ask: why did you go with Ruby to begin with? Did you know how to code in ruby before? If I understand it correctly, there are things like SteemPy that can achieve similar results, correct? Just curious to know your reasons from a programmer's perspective. Thanks again!

CREATE YOUR OWN @REVIEWME PROFILE TO START EARNING CREDIBILITY STARS FROM THE COMMUNITY!

CREATING YOUR PROFILE IS EASY! JUST FOLLOW THE STEPS HERE ☜(ˆ▿ˆc)

You can trade your earned credstars for SBD!

I've been meaning to post about why I'm into ruby. But in a nutshell, I got into it in 2004 when Ruby on Rails started getting popular. And I've been working with it professionally since 2012.

Cool stuff, you're motivating me to learn more and your tools are a dream come true for anyone who's starting to study the steem blockchain and the different languages one can use. A post on your history with Ruby would be nice!