Class: FlowClient::Block

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_client/block.rb

Overview

Represents a block

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBlock

Returns a new instance of Block.



14
15
16
17
18
19
20
21
22
# File 'lib/flow_client/block.rb', line 14

def initialize
  @id = nil
  @parent_id = nil
  @height = nil
  @timestamp = nil
  @collection_guarantees = []
  @block_seals = []
  @signatures = []
end

Instance Attribute Details

#block_sealsObject

Returns the value of attribute block_seals.



6
7
8
# File 'lib/flow_client/block.rb', line 6

def block_seals
  @block_seals
end

#collection_guaranteesObject

Returns the value of attribute collection_guarantees.



6
7
8
# File 'lib/flow_client/block.rb', line 6

def collection_guarantees
  @collection_guarantees
end

#heightObject

Returns the value of attribute height.



6
7
8
# File 'lib/flow_client/block.rb', line 6

def height
  @height
end

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/flow_client/block.rb', line 6

def id
  @id
end

#parent_idObject

Returns the value of attribute parent_id.



6
7
8
# File 'lib/flow_client/block.rb', line 6

def parent_id
  @parent_id
end

#signaturesObject

Returns the value of attribute signatures.



6
7
8
# File 'lib/flow_client/block.rb', line 6

def signatures
  @signatures
end

#timestampObject

Returns the value of attribute timestamp.



6
7
8
# File 'lib/flow_client/block.rb', line 6

def timestamp
  @timestamp
end

Class Method Details

.parse_grpc_block_response(block_response) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/flow_client/block.rb', line 24

def self.parse_grpc_block_response(block_response)
  block = Block.new
  block.id = block_response.block.id.unpack1("H*")
  block.parent_id = block_response.block.parent_id.unpack1("H*")
  block.height = block_response.block.height
  block.timestamp = FlowClient::Utils.parse_protobuf_timestamp(block_response.block.timestamp)
  block.collection_guarantees = block_response.block.collection_guarantees.to_a.map do |cg|
    FlowClient::CollectionGuarantee.parse_grpc_type(cg)
  end
  block.block_seals = block_response.block.block_seals.to_a.map do |seal|
    FlowClient::BlockSeal.parse_grpc_type(seal)
  end
  block.signatures = block_response.block.signatures.to_a.map { |sig| sig.unpack1("H*") }
  block
end