Class: BlockchainLite::Bitcoin::Block::Header
- Inherits:
-
Object
- Object
- BlockchainLite::Bitcoin::Block::Header
- Defined in:
- lib/blockchain-lite/bitcoin/block.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#previous_hash ⇒ Object
readonly
Returns the value of attribute previous_hash.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Instance Method Summary collapse
-
#initialize(index, data, previous_hash) ⇒ Header
constructor
A new instance of Header.
Constructor Details
#initialize(index, data, previous_hash) ⇒ Header
Returns a new instance of Header.
26 27 28 29 30 31 32 |
# File 'lib/blockchain-lite/bitcoin/block.rb', line 26 def initialize(index, data, previous_hash) @index = index @timestamp = Time.now.utc ## note: use coordinated universal time (utc) @data = data @previous_hash = previous_hash @hash = calc_hash end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
22 23 24 |
# File 'lib/blockchain-lite/bitcoin/block.rb', line 22 def data @data end |
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
24 25 26 |
# File 'lib/blockchain-lite/bitcoin/block.rb', line 24 def hash @hash end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
20 21 22 |
# File 'lib/blockchain-lite/bitcoin/block.rb', line 20 def index @index end |
#previous_hash ⇒ Object (readonly)
Returns the value of attribute previous_hash.
23 24 25 |
# File 'lib/blockchain-lite/bitcoin/block.rb', line 23 def previous_hash @previous_hash end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
21 22 23 |
# File 'lib/blockchain-lite/bitcoin/block.rb', line 21 def @timestamp end |