Module: Harmony::Api::V1::Blockchain::Block
- Included in:
- Client
- Defined in:
- lib/harmony/api/v1/blockchain/block.rb
Instance Method Summary collapse
- #block_number ⇒ Object
- #get_block_by_hash(block_hash, full_txs: false) ⇒ Object
- #get_block_by_number(block_number, full_txs: false) ⇒ Object
- #get_block_signers(block_number:) ⇒ Object
- #get_block_transaction_count_by_hash(block_hash) ⇒ Object
- #get_block_transaction_count_by_number(block_number) ⇒ Object
- #get_blocks(start_block, end_block, with_signers: true, full_txs: false) ⇒ Object
- #latest_header ⇒ Object
Instance Method Details
#block_number ⇒ Object
44 45 46 |
# File 'lib/harmony/api/v1/blockchain/block.rb', line 44 def block_number response(post('blockNumber'))&.to_i(16) end |
#get_block_by_hash(block_hash, full_txs: false) ⇒ Object
13 14 15 16 |
# File 'lib/harmony/api/v1/blockchain/block.rb', line 13 def get_block_by_hash(block_hash, full_txs: false) params = [block_hash, full_txs] response(post('getBlockByHash', params: params)) end |
#get_block_by_number(block_number, full_txs: false) ⇒ Object
8 9 10 11 |
# File 'lib/harmony/api/v1/blockchain/block.rb', line 8 def get_block_by_number(block_number, full_txs: false) params = [Harmony::Api::Utilities.int_to_hex(block_number), full_txs] response(post('getBlockByNumber', params: params)) end |
#get_block_signers(block_number:) ⇒ Object
48 49 50 51 |
# File 'lib/harmony/api/v1/blockchain/block.rb', line 48 def get_block_signers(block_number:) params = [Harmony::Api::Utilities.int_to_hex(block_number)] response(post('getBlockSigners', params: params)) end |
#get_block_transaction_count_by_hash(block_hash) ⇒ Object
31 32 33 |
# File 'lib/harmony/api/v1/blockchain/block.rb', line 31 def get_block_transaction_count_by_hash(block_hash) response(post('getBlockTransactionCountByHash', params: [block_hash]))&.to_i(16) end |
#get_block_transaction_count_by_number(block_number) ⇒ Object
35 36 37 38 |
# File 'lib/harmony/api/v1/blockchain/block.rb', line 35 def get_block_transaction_count_by_number(block_number) params = [Harmony::Api::Utilities.int_to_hex(block_number)] response(post('getBlockTransactionCountByNumber', params: params))&.to_i(16) end |
#get_blocks(start_block, end_block, with_signers: true, full_txs: false) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/harmony/api/v1/blockchain/block.rb', line 18 def get_blocks(start_block, end_block, with_signers: true, full_txs: false) params = [ Harmony::Api::Utilities.int_to_hex(start_block), Harmony::Api::Utilities.int_to_hex(end_block), { 'withSigners' => with_signers, 'fullTx' => full_txs } ] response(post('getBlocks', params: params)) end |
#latest_header ⇒ Object
40 41 42 |
# File 'lib/harmony/api/v1/blockchain/block.rb', line 40 def latest_header response(post('latestHeader')) end |