class Peatio::Goldcoin::Blockchain
TODO: Processing of unconfirmed transactions from mempool isn't supported now.
Constants
- DEFAULT_FEATURES
Public Class Methods
new(custom_features = {})
click to toggle source
# File lib/peatio/goldcoin/blockchain.rb, line 9 def initialize(custom_features = {}) @features = DEFAULT_FEATURES.merge(custom_features).slice(*SUPPORTED_FEATURES) @settings = {} end
Public Instance Methods
configure(settings = {})
click to toggle source
# File lib/peatio/goldcoin/blockchain.rb, line 14 def configure(settings = {}) # Clean client state during configure. @client = nil @settings.merge!(settings.slice(*SUPPORTED_SETTINGS)) end
fetch_block!(block_number)
click to toggle source
# File lib/peatio/goldcoin/blockchain.rb, line 20 def fetch_block!(block_number) block_hash = client.json_rpc(:getblockhash, [block_number]) client.json_rpc(:getblock, [block_hash]) .fetch('tx').each_with_object([]) do |tx, txs_array| txs = build_transaction(tx).map do |ntx| Peatio::Transaction.new(ntx.merge(block_number: block_number)) end txs_array.append(*txs) end.yield_self { |txs_array| Peatio::Block.new(block_number, txs_array) } rescue Client::Error => e raise Peatio::Blockchain::ClientError, e end
latest_block_number()
click to toggle source
# File lib/peatio/goldcoin/blockchain.rb, line 34 def latest_block_number client.json_rpc(:getblockcount) rescue Client::Error => e raise Peatio::Blockchain::ClientError, e end