Class: Bytom::Block

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Block

Returns a new instance of Block.



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

def initialize(client)
  @client = client
end

Instance Method Details

#get_block(block_height: nil, block_hash: nil) ⇒ Object

Returns the detail block by block height or block hash.

Parameters:

  • block_height (String) (defaults to: nil)

    optional

  • block_hash (String) (defaults to: nil)

    optional



26
27
28
29
30
31
32
# File 'lib/bytom/api/block.rb', line 26

def get_block(block_height: nil, block_hash: nil)
  params = {
      block_height: block_height,
      block_hash: block_hash
  }
  client.make_request('/get-block', 'post', params: params)
end

#get_block_countObject



10
11
12
# File 'lib/bytom/api/block.rb', line 10

def get_block_count
  client.make_request('/get-block-count', 'post', params: {})
end

#get_block_hashObject

Returns the current block hash for blockchain.



16
17
18
# File 'lib/bytom/api/block.rb', line 16

def get_block_hash
  client.make_request('/get-block-hash', 'post', params: {})
end

#get_block_header(block_height: nil, block_hash: nil) ⇒ Object

Returns the detail block header by block height or block hash.

Parameters:

  • block_height (String) (defaults to: nil)

    optional

  • block_hash (String) (defaults to: nil)

    optional



40
41
42
43
44
45
46
# File 'lib/bytom/api/block.rb', line 40

def get_block_header(block_height: nil, block_hash: nil)
  params = {
      block_height: block_height,
      block_hash: block_hash
  }
  client.make_request('/get-block-header', 'post', params: params)
end

#get_difficulty(block_height: nil, block_hash: nil) ⇒ Object

Returns the block difficulty by block height or block hash.

Parameters:

  • block_height (String) (defaults to: nil)

    optional

  • block_hash (String) (defaults to: nil)

    optional



54
55
56
57
58
59
60
# File 'lib/bytom/api/block.rb', line 54

def get_difficulty(block_height: nil, block_hash: nil)
  params = {
      block_height: block_height,
      block_hash: block_hash
  }
  client.make_request('/get-difficulty', 'post', params: params)
end

#get_hash_rate(block_height: nil, block_hash: nil) ⇒ Object

Returns the block hash rate by block height or block hash, it returns the current block hash rate when request is empty.

Parameters:

  • block_height (String) (defaults to: nil)

    optional

  • block_hash (String) (defaults to: nil)

    optional



68
69
70
71
72
73
74
# File 'lib/bytom/api/block.rb', line 68

def get_hash_rate(block_height: nil, block_hash: nil)
  params = {
      block_height: block_height,
      block_hash: block_hash
  }
  client.make_request('/get-hash-rate', 'post', params: params)
end