Class: Bitcoin::Storage::Models::Block
- Inherits:
-
Protocol::Block
- Object
- Protocol::Block
- Bitcoin::Storage::Models::Block
- Defined in:
- lib/bitcoin/storage/models.rb
Overview
Block retrieved from storage. (see Bitcoin::Protocol::Block)
Constant Summary
Constants inherited from Protocol::Block
Protocol::Block::BLOCK_VERSION_AUXPOW, Protocol::Block::BLOCK_VERSION_CHAIN_END, Protocol::Block::BLOCK_VERSION_CHAIN_START, Protocol::Block::BLOCK_VERSION_DEFAULT
Instance Attribute Summary collapse
-
#bits ⇒ Object
Returns the value of attribute bits.
-
#chain ⇒ Object
readonly
Returns the value of attribute chain.
-
#depth ⇒ Object
readonly
Returns the value of attribute depth.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#mrkl_root ⇒ Object
Returns the value of attribute mrkl_root.
-
#nonce ⇒ Object
Returns the value of attribute nonce.
-
#prev_block ⇒ Object
Returns the value of attribute prev_block.
-
#store ⇒ Object
readonly
Returns the value of attribute store.
-
#time ⇒ Object
Returns the value of attribute time.
-
#tx ⇒ Object
Returns the value of attribute tx.
-
#ver ⇒ Object
Returns the value of attribute ver.
-
#work ⇒ Object
readonly
Returns the value of attribute work.
Attributes inherited from Protocol::Block
Instance Method Summary collapse
-
#get_next_block ⇒ Object
get the block that builds upon this one.
-
#get_prev_block ⇒ Object
get the block this one builds upon.
-
#initialize(store, data) ⇒ Block
constructor
A new instance of Block.
Methods inherited from Protocol::Block
#==, binary_from_hash, binary_from_json, #binary_hash, #bip34_block_height, #block_work, #decimaltarget, #difficulty, from_file, from_hash, from_json, from_json_file, #header_info, #header_to_json, #hextarget, #parse_data, #parse_data_from_io, #prev_block_hex, #recalc_block_hash, #recalc_mrkl_root, #to_hash, #to_json, #to_json_file, #to_payload, #validator, #verify_mrkl_root
Constructor Details
#initialize(store, data) ⇒ Block
Returns a new instance of Block.
19 20 21 22 23 24 25 26 |
# File 'lib/bitcoin/storage/models.rb', line 19 def initialize store, data @store = store @id = data[:id] @depth = data[:depth] @chain = data[:chain] @work = data[:work] @tx = [] end |
Instance Attribute Details
#bits ⇒ Object
Returns the value of attribute bits.
16 17 18 |
# File 'lib/bitcoin/storage/models.rb', line 16 def bits @bits end |
#chain ⇒ Object (readonly)
Returns the value of attribute chain.
17 18 19 |
# File 'lib/bitcoin/storage/models.rb', line 17 def chain @chain end |
#depth ⇒ Object (readonly)
Returns the value of attribute depth.
17 18 19 |
# File 'lib/bitcoin/storage/models.rb', line 17 def depth @depth end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
17 18 19 |
# File 'lib/bitcoin/storage/models.rb', line 17 def id @id end |
#mrkl_root ⇒ Object
Returns the value of attribute mrkl_root.
16 17 18 |
# File 'lib/bitcoin/storage/models.rb', line 16 def mrkl_root @mrkl_root end |
#nonce ⇒ Object
Returns the value of attribute nonce.
16 17 18 |
# File 'lib/bitcoin/storage/models.rb', line 16 def nonce @nonce end |
#prev_block ⇒ Object
Returns the value of attribute prev_block.
16 17 18 |
# File 'lib/bitcoin/storage/models.rb', line 16 def prev_block @prev_block end |
#store ⇒ Object (readonly)
Returns the value of attribute store.
17 18 19 |
# File 'lib/bitcoin/storage/models.rb', line 17 def store @store end |
#time ⇒ Object
Returns the value of attribute time.
16 17 18 |
# File 'lib/bitcoin/storage/models.rb', line 16 def time @time end |
#tx ⇒ Object
Returns the value of attribute tx.
16 17 18 |
# File 'lib/bitcoin/storage/models.rb', line 16 def tx @tx end |
#ver ⇒ Object
Returns the value of attribute ver.
16 17 18 |
# File 'lib/bitcoin/storage/models.rb', line 16 def ver @ver end |
#work ⇒ Object (readonly)
Returns the value of attribute work.
17 18 19 |
# File 'lib/bitcoin/storage/models.rb', line 17 def work @work end |
Instance Method Details
#get_next_block ⇒ Object
get the block that builds upon this one
34 35 36 |
# File 'lib/bitcoin/storage/models.rb', line 34 def get_next_block @store.get_block_by_prev_hash(@hash) end |
#get_prev_block ⇒ Object
get the block this one builds upon
29 30 31 |
# File 'lib/bitcoin/storage/models.rb', line 29 def get_prev_block @store.get_block(@prev_block.reverse_hth) end |