class Radiator::SSC::Blockchain

The “blockchain” endpoint

See: github.com/harpagon210/steemsmartcontracts/wiki/JSON-RPC-server#1-the-blockchain-endpoint-httplocalhost5000blockchain

Public Class Methods

new(options = {}) click to toggle source

@param options [::Hash] The attributes @option options [String] :url Specify the full node end-point. Default: api.steem-engine.com/rpc/blockchain

# File lib/radiator/ssc/blockchain.rb, line 9
def initialize(options = {})
  super
  @url = options[:url] || "#{@root_url}/blockchain"
end

Public Instance Methods

block_info(block_num) click to toggle source

Example using the defaults, backed by Steem Engine:

rpc = Radiator::SSC::Blockchain.new
rpc.block_info(1)

@param [Integer] block_num @return the block with the specified block number of the sidechain

# File lib/radiator/ssc/blockchain.rb, line 31
def block_info(block_num)
  request(method: 'getBlockInfo', params: {blockNumber: block_num})
end
latest_block_info() click to toggle source

Example using the defaults, backed by Steem Engine:

rpc = Radiator::SSC::Blockchain.new
rpc.latest_block_info

@return the latest block of the sidechain

# File lib/radiator/ssc/blockchain.rb, line 20
def latest_block_info
  request(method: 'getLatestBlockInfo')
end
transaction_info(trx_id) click to toggle source

Example using the defaults, backed by Steem Engine:

rpc = Radiator::SSC::Blockchain.new
rpc.transaction_info('9d288aab2eb66064dc0d4492cb281512386e2293')

@param [String] trx_id @return the specified transaction info of the sidechain

# File lib/radiator/ssc/blockchain.rb, line 42
def transaction_info(trx_id)
  request(method: 'getTransactionInfo', params: {txid: trx_id})
end

Protected Instance Methods

healthy?() click to toggle source
# File lib/radiator/ssc/blockchain.rb, line 46
def healthy?
  begin
    request(method: 'getBlockInfo', params: {blockNumber: -1}, skip_health_check: true).nil?
  rescue => e
    warn("Health check for #{uri.inspect} failed: #{e.inspect}")
    
    !!shutdown
  end
end