bitshares.aio.blockchain module

class bitshares.aio.blockchain.Blockchain(*args, **kwargs)[source]

Bases: bitshares.aio.instance.BlockchainInstance, bitshares.aio.blockchain.Blockchain

This class allows to access the blockchain and read data from it.

Parameters:
  • blockchain_instance (bitshares.aio.bitshares.BitShares) – BitShares instance
  • mode (str) – (default) Irreversible block (irreversible) or actual head block (head)
  • max_block_wait_repetition (int) – (default) 3 maximum wait time for next block ismax_block_wait_repetition * block_interval

This class let’s you deal with blockchain related data and methods.

awaitTxConfirmation(transaction, limit=10)[source]

Returns the transaction as seen by the blockchain after being included into a block

Note

If you want instant confirmation, you need to instantiate class:.blockchain.Blockchain with mode="head", otherwise, the call will wait until confirmed in an irreversible block.

Note

This method returns once the blockchain has included a transaction with the same signature. Even though the signature is not usually used to identify a transaction, it still cannot be forfeited and is derived from the transaction contented and thus identifies a transaction uniquely.

bitshares

Alias for the specific blockchain.

block_time(block_num)[source]

Returns a datetime of the block with the given block number.

Parameters:block_num (int) – Block number
block_timestamp(block_num)[source]

Returns the timestamp of the block with the given block number.

Parameters:block_num (int) – Block number
blockchain
blockchain_instance_class

alias of bitshares.aio.instance.BlockchainInstance

blocks(start=None, stop=None)[source]

Yields blocks starting from start.

Parameters:
  • start (int) – Starting block
  • stop (int) – Stop at this block
  • mode (str) – We here have the choice between “head” (the last block) and “irreversible” (the block that is confirmed by 2/3 of all block producers and is thus irreversible)
chain

Short form for blockchain (for the lazy)

chainParameters()[source]

The blockchain parameters, such as fees, and committee-controlled parameters are returned here

config()[source]

Returns object 2.0.0

define_classes()[source]

Needs to define instance variables that provide classes

get_all_accounts(start='', stop='', steps=1000.0, **kwargs)[source]

Yields account names between start and stop.

Parameters:
  • start (str) – Start at this account name
  • stop (str) – Stop at this account name
  • steps (int) – Obtain steps ret with a single call from RPC
get_block_interval()[source]

This call returns the block interval

get_chain_properties()[source]

Return chain properties

get_current_block()[source]

This call returns the current block

Note

The block number returned depends on the mode used when instanciating from this class.

get_current_block_num()[source]

This call returns the current block

Note

The block number returned depends on the mode used when instanciating from this class.

get_instance_class()

Should return the Chain instance class, e.g. bitshares.BitShares

get_network()[source]

Identify the network

Returns:Network parameters
Return type:dict
info()[source]

This call returns the dynamic global properties

classmethod inject(cls)
is_irreversible_mode()[source]
ops(start=None, stop=None, **kwargs)[source]

Yields all operations (excluding virtual operations) starting from start.

Parameters:
  • start (int) – Starting block
  • stop (int) – Stop at this block
  • mode (str) – We here have the choice between “head” (the last block) and “irreversible” (the block that is confirmed by 2/3 of all block producers and is thus irreversible)
  • only_virtual_ops (bool) – Only yield virtual operations

This call returns a list that only carries one operation and its type!

participation_rate
classmethod set_shared_blockchain_instance(instance)

This method allows us to override default instance for all users of SharedInstance.instance.

Parameters:instance (chaininstance) – Chain instance
classmethod set_shared_config(config)

This allows to set a config that will be used when calling shared_blockchain_instance and allows to define the configuration without requiring to actually create an instance

set_shared_instance()

This method allows to set the current instance as default

shared_blockchain_instance()

This method will initialize SharedInstance.instance and return it. The purpose of this method is to have offer single default instance that can be reused by multiple classes.

stream(opNames=[], *args, **kwargs)[source]

Yield specific operations (e.g. comments) only

Parameters:
  • opNames (array) – List of operations to filter for
  • start (int) – Start at this block
  • stop (int) – Stop at this block
  • mode (str) –

    We here have the choice between * “head”: the last block * “irreversible”: the block that is confirmed by 2/3 of all

    block producers and is thus irreversible!

The dict output is formated such that type caries the operation type, timestamp and block_num are taken from the block the operation was stored in and the other key depend on the actualy operation.

update_chain_parameters()[source]
wait_for_and_get_block(block_number, blocks_waiting_for=None)[source]

Get the desired block from the chain, if the current head block is smaller (for both head and irreversible) then we wait, but a maxmimum of blocks_waiting_for * max_block_wait_repetition time before failure.

Parameters:
  • block_number (int) – desired block number
  • blocks_waiting_for (int) – (default) difference between block_number and current head how many blocks we are willing to wait, positive int