How corrupt is your private Steem Engine node?

Words
83
Reading
1 min
Listen
Play
7y

Here's a script to check if your Steem Engine node is corrupt. It checks the block sequence as well as transaction organization.

First, install ruby. I like to use the Ruby Version Manager for this part.

Next, install Radiator:

gem install radiator

Then create a file called verify_steem_engine.rb (note: we assume the node is on http://127.0.0.1:5000):

block_agent = Radiator::SSC::Blockchain.new(root_url: 'http://127.0.0.1:5000')
block_num = 0
previous_hash = nil
trx_ids = {}

while !!(block = block_agent.block_info(block_num))
  block_num % 1000 == 0 and print '.'
  
  if !!previous_hash && previous_hash != block.previousHash
    puts "\nprevious_hash:      #{previous_hash}"
    puts "block.previousHash: #{block.previousHash}"
    abort("Problem detected at block_num: #{block_num}")
  end
  
  block.transactions.each do |trx|
    (trx_id = trx.transactionId) == 0 and next
    trx_id, idx = trx_id.split('-')
    
    if trx_ids.keys.include?(trx_id) && trx_ids[trx_id] != block_num
      puts "\nFound duplicate transaction id (#{trx_id}) already seen in block: #{trx_ids[trx_id]}"
      abort("Problem detected at block_num: #{block_num}")
    end
    
    trx_ids[trx_id] = block_num
  end
  
  block_num += 1
  previous_hash = block['hash']
end

puts "\nVerify complete, ending with block: #{block_num}"

Finally, run it:

ruby -r radiator verify_steem_engine.rb

If everything is fine, you'll see a result like this:

........................................................................................
Verify complete, ending with block: 95497

Otherwise, if there's something amiss, I recommend you delete the data directory, download the latest blocks.log file, and replay it.

How corrupt is your private Steem Engine node? | Ecency