Sha256: 9c9d97e9593bd3c199df615539703484e07a0c3a73ff6282f8b178f48cbad9f8
Contents?: true
Size: 793 Bytes
Versions: 2
Compression:
Stored size: 793 Bytes
Contents
module Blockchain class Block attr_reader :hsh, :ver, :prev_block, :mrkl_root attr_reader :time, :bits, :fee, :nonce, :n_tx, :size attr_reader :block_index, :main_chain, :height, :received_time attr_reader :relayed_by, :tx # id can be block_hash or block_index def self.find(id) self.new(Blockchain.rawblock(id)) rescue nil end def initialize(b) @hsh = b.delete('hash') # hash is an unfortunate word b.each_key { |k| instance_variable_set("@#{k}", b[k]) } @time = DateTime.strptime(@time.to_s, '%s') @received_time = DateTime.strptime(@received_time.to_s, '%s') @tx.map! { |t| Blockchain::Transaction.new(t) } @fee = Btc.from_satoshis(fee) end def previous Block.find(@prev_block) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
blockchain-ruby-1.0.1 | lib/block.rb |
blockchain-ruby-1.0.0 | lib/block.rb |