Class: BlockchainLite::Bitcoin::Block::Header

Inherits:
Object
  • Object
show all
Defined in:
lib/blockchain-lite/bitcoin/block.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#dataObject (readonly)

Returns the value of attribute data.



22
23
24
# File 'lib/blockchain-lite/bitcoin/block.rb', line 22

def data
  @data
end

#hashObject (readonly)

Returns the value of attribute hash.



24
25
26
# File 'lib/blockchain-lite/bitcoin/block.rb', line 24

def hash
  @hash
end

#indexObject (readonly)

Returns the value of attribute index.



20
21
22
# File 'lib/blockchain-lite/bitcoin/block.rb', line 20

def index
  @index
end

#previous_hashObject (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

#timestampObject (readonly)

Returns the value of attribute timestamp.



21
22
23
# File 'lib/blockchain-lite/bitcoin/block.rb', line 21

def timestamp
  @timestamp
end