Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Witness Inspector ('winspect.rb') for STEEM. Please have a look at the README.md file.
winspect.log
  • Title: winspect.rb - STEEM Witness Inspector
  • Tags: radiator ruby steem steemdev witness-category
  • Notes:

Overview

Witness Inspector will look at the witnesses you've voted for and finds their latest #witness-category posts so you can get all of the URLs on one screen.

Changes

  • Now querying all witnesses in parallel, to speed up the report.

Install

To use this Radiator script:

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

I've tested it on various versions of ruby, but I'm currently using:

ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin17]

First, clone this gist and install the dependencies:

$ git clone git@gist.github.com:8fd886f57978cdac3bac10ff58cbcdfa.git winspect
$ cd winspect
$ bundle install

Optional: edit the file winspect.yml to change chain and/or node url.


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.


Usage

To run the report:

$ ruby winspect.rb inertia

Example output:

# Unable to find #witness-category for aggroed https://www.steemit.com/@aggroed
# Unable to find #witness-category for arcange https://www.steemit.com/@arcange
# Unable to find #witness-category for ausbitbank https://www.steemit.com/@ausbitbank
# Unable to find #witness-category for cervantes https://www.steemit.com/@cervantes
# Unable to find #witness-category for followbtcnews https://www.steemit.com/@followbtcnews
# Unable to find #witness-category for jerrybanfield https://www.steemit.com/@jerrybanfield
# Unable to find #witness-category for qurator https://www.steemit.com/@qurator
# Unable to find #witness-category for steemgigs https://www.steemit.com/@steemgigs
# Unable to find #witness-category for teamsteem https://www.steemit.com/@teamsteem
# Unable to find #witness-category for themarkymark https://www.steemit.com/@themarkymark
{
    "2016-04-22T18:24:15" => "https://www.steemit.com/witness-category/@riverhead/witness-proposal-riverhead",
    "2017-05-31T16:52:36" => "https://www.steemit.com/witness-category/@jesta/jesta-witness-update-march-through-may",
    "2017-06-04T22:33:39" => "https://www.steemit.com/witness-category/@thecryptodrive/a-world-of-witnesses-geo-diversity-for-a-safer-tomorrow",
    "2017-09-08T12:02:39" => "https://www.steemit.com/witness-category/@furion/conductor-0-3-update-steem-witness-toolkit",
    "2017-09-19T05:36:57" => "https://www.steemit.com/witness-category/@anyx/anyx-cheetah-and-steemcleaners-witness-update-2017-09-18",
    "2017-12-25T16:51:21" => "https://www.steemit.com/witness-category/@pharesim/merry-xmas",
    "2018-01-03T20:09:00" => "https://www.steemit.com/witness-category/@good-karma/good-karma-witness-update-3rd-jan-2018-2f5a7a56bb2e2",
    "2018-01-04T12:35:51" => "https://www.steemit.com/witness-category/@pfunk/pfunk-new-year-witness-update",
    "2018-01-10T19:35:27" => "https://www.steemit.com/witness-category/@utopian-io/utopian-witness-backup-witness-and-failover-script-now-in-place-and-running",
    "2018-01-15T19:11:36" => "https://www.steemit.com/witness-category/@roelandp/blue-monday-life-blog-from-amsterdam-2018-what-will-it-bring-witness-updates-surf-plans-conference-plans-steemfest",
    "2018-01-23T17:23:42" => "https://www.steemit.com/witness-category/@reggaemuffin/witness-discussion-sbd-price-and-reverse-peg",
    "2018-03-04T13:36:15" => "https://www.steemit.com/witness-category/@blockbrothers/witness-update-week-9-2018-new-server-and-steemify-news",
    "2018-03-05T02:56:18" => "https://www.steemit.com/witness-category/@netuoso/state-of-the-witness-15-witness-upgraded-to-64gb-ram-steemcreate-updates-steemdevs-constantly-growing-appbase-testing-underway",
    "2018-03-11T12:39:06" => "https://www.steemit.com/witness-category/@klye/power-overwhelming-deploying-new-128gb-ram-witness-server",
    "2018-04-09T03:23:42" => "https://www.steemit.com/witness-category/@helo/steemit-quebec-witness-march-2018-update",
    "2018-04-20T22:13:27" => "https://www.steemit.com/witness-category/@someguy123/guide-optimise-your-rpc-server-for-better-performance",
    "2018-04-22T19:41:45" => "https://www.steemit.com/witness-category/@gtg/6tkskj-gtg-witness-log",
    "2018-04-24T18:13:51" => "https://www.steemit.com/witness-category/@fyrst-witness/mandatory-witness-voting-proxy-to-allow-users-to-keep-posting-commenting",
    "2018-04-27T00:06:33" => "https://www.steemit.com/witness-category/@emrebeyler/my-witness-node-updated-to-0-19-3",
    "2018-04-30T00:33:27" => "https://www.steemit.com/witness-category/@yabapmatt/yabapmatt-s-witness-update"
}

Check here to see an updated version of this script:

https://gist.github.com/inertia186/8fd886f57978cdac3bac10ff58cbcdfa


Troubleshooting

Problem: The node I'm using is down.

Is there a list of nodes?

Solution: Yes, special thanks to @jamzed.

https://geo.steem.pl/


![](http://i.imgur.com/mnOaF3K.png)

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

Get in touch!

If you're using winspect, 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 winspect as licensed under a Creative Commons CC0 License.

source 'https://rubygems.org'
gem 'radiator'
gem 'awesome_print'
GEM
remote: https://rubygems.org/
specs:
awesome_print (1.8.0)
bitcoin-ruby (0.0.18)
connection_pool (2.2.1)
ffi (1.9.23)
hashie (3.5.7)
json (2.1.0)
little-plugger (1.1.4)
logging (2.2.2)
little-plugger (~> 1.1)
multi_json (~> 1.10)
multi_json (1.13.1)
net-http-persistent (3.0.0)
connection_pool (~> 2.2)
radiator (0.4.1)
awesome_print (~> 1.7, >= 1.7.0)
bitcoin-ruby (~> 0.0, >= 0.0.11)
ffi (~> 1.9, >= 1.9.18)
hashie (~> 3.5, >= 3.5.5)
json (~> 2.0, >= 2.0.2)
logging (~> 2.2, >= 2.2.0)
net-http-persistent (>= 2.5.2)
PLATFORMS
ruby
DEPENDENCIES
awesome_print
radiator
BUNDLED WITH
1.16.1
require 'rubygems'
require 'bundler/setup'
require 'yaml'
Bundler.require
defined? Thread.report_on_exception and Thread.report_on_exception = true
CONFIG_PATH = __FILE__.sub(/\.rb$/, '.yml')
config = YAML.load_file(CONFIG_PATH)
options = {
chain: config[:chain_options][:chain].to_sym,
url: config[:chain_options][:url],
logger: Logger.new(__FILE__.sub(/\.rb$/, '.log'))
}
account_name = ARGV.first
if account_name.nil?
puts "Usage:"
puts "\truby #{__FILE__} <account_name>"
exit
end
api = Radiator::Api.new(options)
tag_api = Radiator::TagApi.new(options)
uri = case config[:chain_options][:chain].to_sym
when :steem then 'https://www.steemit.com'
when :golos then 'https://www.golos.io'
end
@report = {}
account = api.get_accounts([account_name.downcase]) do |accounts, error|
if !!error
ap error
exit
end
accounts.first
end
if account.nil?
puts "Unable to find account: #{account_name}"
exit
end
threads = account.witness_votes.map do |witness|
Thread.new do
query = {
tag: witness,
limit: 100,
filter_tags: ['witness-category'],
select_authors: [witness], # should filters reblogs, right?
truncate_body: 0 # don't need the body
}
catch :witness do; begin
tag_api.get_discussions_by_blog(query) do |discussions, error|
if !!error
puts error.to_json
exit
end
discussions.each do |content|
next unless content.author == witness # skips reblogs
next unless content.parent_author == ''
next unless content.parent_permlink == 'witness-category'
url = "@#{content.author}/#{content.permlink}"
created = content.created
@report[created] = "#{uri}/witness-category/#{url}"
throw :witness # only need the first match
end
puts "# Unable to find #witness-category for #{witness} #{uri}/@#{witness}"
end
end; end
end
end
threads.map(&:join)
ap @report.sort_by{ |k, v| k }.to_h
:chain_options:
:chain: steem
:url: https://api.steemit.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.