bhive.block module¶
-
class
bhive.block.Block(block, only_ops=False, only_virtual_ops=False, full=True, lazy=False, hive_instance=None)¶ Bases:
bhive.blockchainobject.BlockchainObjectRead a single block from the chain
- Parameters
block (int) – block number
hive_instance (Hive) – Hive instance
lazy (bool) – Use lazy loading
only_ops (bool) – Includes only operations, when set to True (default: False)
only_virtual_ops (bool) – Includes only virtual operations (default: False)
Instances of this class are dictionaries that come with additional methods (see below) that allow dealing with a block and its corresponding functions.
When only_virtual_ops is set to True, only_ops is always set to True.
In addition to the block data, the block number is stored as self[“id”] or self.identifier.
>>> from bhive.block import Block >>> block = Block(1) >>> print(block) <Block 1>
Note
This class comes with its own caching function to reduce the load on the API server. Instances of this class can be refreshed with
Account.refresh().-
property
block_num¶ Returns the block number
-
json()¶
-
property
json_operations¶ Returns all block operations as list, all dates are strings.
-
property
json_transactions¶ Returns all transactions as list, all dates are strings.
-
property
operations¶ Returns all block operations as list
-
ops_statistics(add_to_ops_stat=None)¶ Returns a statistic with the occurrence of the different operation types
-
refresh()¶ Even though blocks never change, you freshly obtain its contents from an API with this method
-
time()¶ Return a datetime instance for the timestamp of this block
-
property
transactions¶ Returns all transactions as list
-
class
bhive.block.BlockHeader(block, full=True, lazy=False, hive_instance=None)¶ Bases:
bhive.blockchainobject.BlockchainObjectRead a single block header from the chain
- Parameters
block (int) – block number
hive_instance (Hive) – Hive instance
lazy (bool) – Use lazy loading
In addition to the block data, the block number is stored as self[“id”] or self.identifier.
>>> from bhive.block import BlockHeader >>> block = BlockHeader(1) >>> print(block) <BlockHeader 1>
-
property
block_num¶ Returns the block number
-
json()¶
-
refresh()¶ Even though blocks never change, you freshly obtain its contents from an API with this method
-
time()¶ Return a datetime instance for the timestamp of this block