Class: Bytom::Block
- Inherits:
-
Object
- Object
- Bytom::Block
- Defined in:
- lib/bytom/api/block.rb
Instance Method Summary collapse
-
#get_block(block_height: nil, block_hash: nil) ⇒ Object
Returns the detail block by block height or block hash.
- #get_block_count ⇒ Object
-
#get_block_hash ⇒ Object
Returns the current block hash for blockchain.
-
#get_block_header(block_height: nil, block_hash: nil) ⇒ Object
Returns the detail block header by block height or block hash.
-
#get_difficulty(block_height: nil, block_hash: nil) ⇒ Object
Returns the block difficulty by block height or block hash.
-
#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.
-
#initialize(client) ⇒ Block
constructor
A new instance of Block.
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.
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_count ⇒ Object
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_hash ⇒ Object
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.
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.
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.
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 |