code
stringlengths
66
870k
docstring
stringlengths
19
26.7k
func_name
stringlengths
1
138
language
stringclasses
1 value
repo
stringlengths
7
68
path
stringlengths
5
324
url
stringlengths
46
389
license
stringclasses
7 values
def update_types(config, reference, list_sep=':'): """Return a new configuration where all the values types are aligned with the ones in the default configuration """ def _coerce(current, value): # Coerce a value to the `current` type. try: # First we try to apply current to...
Return a new configuration where all the values types are aligned with the ones in the default configuration
update_types
python
bigchaindb/bigchaindb
bigchaindb/config_utils.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/config_utils.py
Apache-2.0
def set_config(config): """Set bigchaindb.config equal to the default config dict, then update that with whatever is in the provided config dict, and then set bigchaindb.config['CONFIGURED'] = True Args: config (dict): the config dict to read for changes to the default co...
Set bigchaindb.config equal to the default config dict, then update that with whatever is in the provided config dict, and then set bigchaindb.config['CONFIGURED'] = True Args: config (dict): the config dict to read for changes to the default config Note: Any pre...
set_config
python
bigchaindb/bigchaindb
bigchaindb/config_utils.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/config_utils.py
Apache-2.0
def update_config(config): """Update bigchaindb.config with whatever is in the provided config dict, and then set bigchaindb.config['CONFIGURED'] = True Args: config (dict): the config dict to read for changes to the default config """ # Update the default config wit...
Update bigchaindb.config with whatever is in the provided config dict, and then set bigchaindb.config['CONFIGURED'] = True Args: config (dict): the config dict to read for changes to the default config
update_config
python
bigchaindb/bigchaindb
bigchaindb/config_utils.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/config_utils.py
Apache-2.0
def write_config(config, filename=None): """Write the provided configuration to a specific location. Args: config (dict): a dictionary with the configuration to load. filename (str): the name of the file that will store the new configuration. Defaults to ``None``. If ``None``, the H...
Write the provided configuration to a specific location. Args: config (dict): a dictionary with the configuration to load. filename (str): the name of the file that will store the new configuration. Defaults to ``None``. If ``None``, the HOME of the current user and the string ``.bigcha...
write_config
python
bigchaindb/bigchaindb
bigchaindb/config_utils.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/config_utils.py
Apache-2.0
def autoconfigure(filename=None, config=None, force=False): """Run ``file_config`` and ``env_config`` if the module has not been initialized. """ if not force and is_configured(): logger.debug('System already configured, skipping autoconfiguration') return # start with the current c...
Run ``file_config`` and ``env_config`` if the module has not been initialized.
autoconfigure
python
bigchaindb/bigchaindb
bigchaindb/config_utils.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/config_utils.py
Apache-2.0
def load_validation_plugin(name=None): """Find and load the chosen validation plugin. Args: name (string): the name of the entry_point, as advertised in the setup.py of the providing package. Returns: an uninstantiated subclass of ``bigchaindb.validation.AbstractValidationRules...
Find and load the chosen validation plugin. Args: name (string): the name of the entry_point, as advertised in the setup.py of the providing package. Returns: an uninstantiated subclass of ``bigchaindb.validation.AbstractValidationRules``
load_validation_plugin
python
bigchaindb/bigchaindb
bigchaindb/config_utils.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/config_utils.py
Apache-2.0
def init_chain(self, genesis): """Initialize chain upon genesis or a migration""" app_hash = '' height = 0 known_chain = self.bigchaindb.get_latest_abci_chain() if known_chain is not None: chain_id = known_chain['chain_id'] if known_chain['is_synced']: ...
Initialize chain upon genesis or a migration
init_chain
python
bigchaindb/bigchaindb
bigchaindb/core.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/core.py
Apache-2.0
def check_tx(self, raw_transaction): """Validate the transaction before entry into the mempool. Args: raw_tx: a raw string (in bytes) transaction. """ self.abort_if_abci_chain_is_not_synced() logger.debug('check_tx: %s', raw_transaction) transaction...
Validate the transaction before entry into the mempool. Args: raw_tx: a raw string (in bytes) transaction.
check_tx
python
bigchaindb/bigchaindb
bigchaindb/core.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/core.py
Apache-2.0
def begin_block(self, req_begin_block): """Initialize list of transaction. Args: req_begin_block: block object which contains block header and block hash. """ self.abort_if_abci_chain_is_not_synced() chain_shift = 0 if self.chain is None else self.chain['...
Initialize list of transaction. Args: req_begin_block: block object which contains block header and block hash.
begin_block
python
bigchaindb/bigchaindb
bigchaindb/core.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/core.py
Apache-2.0
def deliver_tx(self, raw_transaction): """Validate the transaction before mutating the state. Args: raw_tx: a raw string (in bytes) transaction. """ self.abort_if_abci_chain_is_not_synced() logger.debug('deliver_tx: %s', raw_transaction) transaction = self....
Validate the transaction before mutating the state. Args: raw_tx: a raw string (in bytes) transaction.
deliver_tx
python
bigchaindb/bigchaindb
bigchaindb/core.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/core.py
Apache-2.0
def end_block(self, request_end_block): """Calculate block hash using transaction ids and previous block hash to be stored in the next block. Args: height (int): new height of the chain. """ self.abort_if_abci_chain_is_not_synced() chain_shift = 0 if self.c...
Calculate block hash using transaction ids and previous block hash to be stored in the next block. Args: height (int): new height of the chain.
end_block
python
bigchaindb/bigchaindb
bigchaindb/core.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/core.py
Apache-2.0
def commit(self): """Store the new height and along with block hash.""" self.abort_if_abci_chain_is_not_synced() data = self.block_txn_hash.encode('utf-8') # register a new block only when new transactions are received if self.block_txn_ids: self.bigchaindb.store_b...
Store the new height and along with block hash.
commit
python
bigchaindb/bigchaindb
bigchaindb/core.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/core.py
Apache-2.0
def __init__(self, event_type, event_data): """Creates a new event. Args: event_type (int): the type of the event, see :class:`~bigchaindb.events.EventTypes` event_data (obj): the data of the event. """ self.type = event_type self.data = ...
Creates a new event. Args: event_type (int): the type of the event, see :class:`~bigchaindb.events.EventTypes` event_data (obj): the data of the event.
__init__
python
bigchaindb/bigchaindb
bigchaindb/events.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/events.py
Apache-2.0
def get_subscriber_queue(self, event_types=None): """Create a new queue for a specific combination of event types and return it. Returns: a :class:`multiprocessing.Queue`. Raises: RuntimeError if called after `run` """ try: self.start...
Create a new queue for a specific combination of event types and return it. Returns: a :class:`multiprocessing.Queue`. Raises: RuntimeError if called after `run`
get_subscriber_queue
python
bigchaindb/bigchaindb
bigchaindb/events.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/events.py
Apache-2.0
def dispatch(self, event): """Given an event, send it to all the subscribers. Args event (:class:`~bigchaindb.events.EventTypes`): the event to dispatch to all the subscribers. """ for event_types, queues in self.queues.items(): if event.type & e...
Given an event, send it to all the subscribers. Args event (:class:`~bigchaindb.events.EventTypes`): the event to dispatch to all the subscribers.
dispatch
python
bigchaindb/bigchaindb
bigchaindb/events.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/events.py
Apache-2.0
def filter_spent_outputs(self, outputs): """Remove outputs that have been spent Args: outputs: list of TransactionLink """ links = [o.to_dict() for o in outputs] txs = list(query.get_spending_transactions(self.connection, links)) spends = {TransactionLink.fro...
Remove outputs that have been spent Args: outputs: list of TransactionLink
filter_spent_outputs
python
bigchaindb/bigchaindb
bigchaindb/fastquery.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/fastquery.py
Apache-2.0
def filter_unspent_outputs(self, outputs): """Remove outputs that have not been spent Args: outputs: list of TransactionLink """ links = [o.to_dict() for o in outputs] txs = list(query.get_spending_transactions(self.connection, links)) spends = {TransactionLi...
Remove outputs that have not been spent Args: outputs: list of TransactionLink
filter_unspent_outputs
python
bigchaindb/bigchaindb
bigchaindb/fastquery.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/fastquery.py
Apache-2.0
def __init__(self, connection=None): """Initialize the Bigchain instance A Bigchain instance has several configuration parameters (e.g. host). If a parameter value is passed as an argument to the Bigchain __init__ method, then that is the value it will have. Otherwise, the param...
Initialize the Bigchain instance A Bigchain instance has several configuration parameters (e.g. host). If a parameter value is passed as an argument to the Bigchain __init__ method, then that is the value it will have. Otherwise, the parameter value will come from an environment variabl...
__init__
python
bigchaindb/bigchaindb
bigchaindb/lib.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/lib.py
Apache-2.0
def update_utxoset(self, transaction): """Update the UTXO set given ``transaction``. That is, remove the outputs that the given ``transaction`` spends, and add the outputs that the given ``transaction`` creates. Args: transaction (:obj:`~bigchaindb.models.Transaction`): A ne...
Update the UTXO set given ``transaction``. That is, remove the outputs that the given ``transaction`` spends, and add the outputs that the given ``transaction`` creates. Args: transaction (:obj:`~bigchaindb.models.Transaction`): A new transaction incoming into the sy...
update_utxoset
python
bigchaindb/bigchaindb
bigchaindb/lib.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/lib.py
Apache-2.0
def store_unspent_outputs(self, *unspent_outputs): """Store the given ``unspent_outputs`` (utxos). Args: *unspent_outputs (:obj:`tuple` of :obj:`dict`): Variable length tuple or list of unspent outputs. """ if unspent_outputs: return backend.query...
Store the given ``unspent_outputs`` (utxos). Args: *unspent_outputs (:obj:`tuple` of :obj:`dict`): Variable length tuple or list of unspent outputs.
store_unspent_outputs
python
bigchaindb/bigchaindb
bigchaindb/lib.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/lib.py
Apache-2.0
def get_unspent_outputs(self): """Get the utxoset. Returns: generator of unspent_outputs. """ cursor = backend.query.get_unspent_outputs(self.connection) return (record for record in cursor)
Get the utxoset. Returns: generator of unspent_outputs.
get_unspent_outputs
python
bigchaindb/bigchaindb
bigchaindb/lib.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/lib.py
Apache-2.0
def delete_unspent_outputs(self, *unspent_outputs): """Deletes the given ``unspent_outputs`` (utxos). Args: *unspent_outputs (:obj:`tuple` of :obj:`dict`): Variable length tuple or list of unspent outputs. """ if unspent_outputs: return backend.qu...
Deletes the given ``unspent_outputs`` (utxos). Args: *unspent_outputs (:obj:`tuple` of :obj:`dict`): Variable length tuple or list of unspent outputs.
delete_unspent_outputs
python
bigchaindb/bigchaindb
bigchaindb/lib.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/lib.py
Apache-2.0
def get_transactions_filtered(self, asset_id, operation=None, last_tx=None): """Get a list of transactions filtered on some criteria """ txids = backend.query.get_txids_filtered(self.connection, asset_id, operation, last_tx) for txid in tx...
Get a list of transactions filtered on some criteria
get_transactions_filtered
python
bigchaindb/bigchaindb
bigchaindb/lib.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/lib.py
Apache-2.0
def get_outputs_filtered(self, owner, spent=None): """Get a list of output links filtered on some criteria Args: owner (str): base58 encoded public_key. spent (bool): If ``True`` return only the spent outputs. If ``False`` return only unspent outputs. I...
Get a list of output links filtered on some criteria Args: owner (str): base58 encoded public_key. spent (bool): If ``True`` return only the spent outputs. If ``False`` return only unspent outputs. If spent is not specified (``None``) ...
get_outputs_filtered
python
bigchaindb/bigchaindb
bigchaindb/lib.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/lib.py
Apache-2.0
def get_block(self, block_id): """Get the block with the specified `block_id`. Returns the block corresponding to `block_id` or None if no match is found. Args: block_id (int): block id of the block to get. """ block = backend.query.get_block(self.connectio...
Get the block with the specified `block_id`. Returns the block corresponding to `block_id` or None if no match is found. Args: block_id (int): block id of the block to get.
get_block
python
bigchaindb/bigchaindb
bigchaindb/lib.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/lib.py
Apache-2.0
def get_block_containing_tx(self, txid): """Retrieve the list of blocks (block ids) containing a transaction with transaction id `txid` Args: txid (str): transaction id of the transaction to query Returns: Block id list (list(int)) """ blocks ...
Retrieve the list of blocks (block ids) containing a transaction with transaction id `txid` Args: txid (str): transaction id of the transaction to query Returns: Block id list (list(int))
get_block_containing_tx
python
bigchaindb/bigchaindb
bigchaindb/lib.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/lib.py
Apache-2.0
def validate_transaction(self, tx, current_transactions=[]): """Validate a transaction against the current status of the database.""" transaction = tx # CLEANUP: The conditional below checks for transaction in dict format. # It would be better to only have a single format for the trans...
Validate a transaction against the current status of the database.
validate_transaction
python
bigchaindb/bigchaindb
bigchaindb/lib.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/lib.py
Apache-2.0
def migrate_abci_chain(self): """Generate and record a new ABCI chain ID. New blocks are not accepted until we receive an InitChain ABCI request with the matching chain ID and validator set. Chain ID is generated based on the current chain and height. `chain-X` => `chain-X-migra...
Generate and record a new ABCI chain ID. New blocks are not accepted until we receive an InitChain ABCI request with the matching chain ID and validator set. Chain ID is generated based on the current chain and height. `chain-X` => `chain-X-migrated-at-height-5`. `chain-X-migrat...
migrate_abci_chain
python
bigchaindb/bigchaindb
bigchaindb/lib.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/lib.py
Apache-2.0
def setup_logging(): """Function to configure log hadlers. .. important:: Configuration, if needed, should be applied before invoking this decorator, as starting the subscriber process for logging will configure the root logger for the child process based on the state of :obj:`...
Function to configure log hadlers. .. important:: Configuration, if needed, should be applied before invoking this decorator, as starting the subscriber process for logging will configure the root logger for the child process based on the state of :obj:`bigchaindb.config` at the mo...
setup_logging
python
bigchaindb/bigchaindb
bigchaindb/log.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/log.py
Apache-2.0
def validate(self, bigchain, current_transactions=[]): """Validate transaction spend Args: bigchain (BigchainDB): an instantiated bigchaindb.BigchainDB object. Returns: The transaction (Transaction) if the transaction is valid else it raises an exception descr...
Validate transaction spend Args: bigchain (BigchainDB): an instantiated bigchaindb.BigchainDB object. Returns: The transaction (Transaction) if the transaction is valid else it raises an exception describing the reason why the transaction is invalid. ...
validate
python
bigchaindb/bigchaindb
bigchaindb/models.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/models.py
Apache-2.0
def merkleroot(hashes): """Computes the merkle root for a given list. Args: hashes (:obj:`list` of :obj:`bytes`): The leaves of the tree. Returns: str: Merkle root in hexadecimal form. """ # XXX TEMPORARY -- MUST REVIEW and possibly CHANGE # The idea here is that the UTXO SET ...
Computes the merkle root for a given list. Args: hashes (:obj:`list` of :obj:`bytes`): The leaves of the tree. Returns: str: Merkle root in hexadecimal form.
merkleroot
python
bigchaindb/bigchaindb
bigchaindb/tendermint_utils.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/tendermint_utils.py
Apache-2.0
def public_key64_to_address(base64_public_key): """Note this only compatible with Tendermint 0.19.x""" ed25519_public_key = public_key_from_base64(base64_public_key) encoded_public_key = amino_encoded_public_key(ed25519_public_key) return hashlib.new('ripemd160', encoded_public_key).hexdigest().upper()
Note this only compatible with Tendermint 0.19.x
public_key64_to_address
python
bigchaindb/bigchaindb
bigchaindb/tendermint_utils.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/tendermint_utils.py
Apache-2.0
def condition_details_has_owner(condition_details, owner): """Check if the public_key of owner is in the condition details as an Ed25519Fulfillment.public_key Args: condition_details (dict): dict with condition details owner (str): base58 public key of owner Returns: bool: True...
Check if the public_key of owner is in the condition details as an Ed25519Fulfillment.public_key Args: condition_details (dict): dict with condition details owner (str): base58 public key of owner Returns: bool: True if the public key is found in the condition details, False otherw...
condition_details_has_owner
python
bigchaindb/bigchaindb
bigchaindb/utils.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/utils.py
Apache-2.0
def run(self, instance): """Run the recorded chain of methods on `instance`. Args: instance: an object. """ last = instance for item in self.stack: if isinstance(item, str): last = getattr(last, item) else: la...
Run the recorded chain of methods on `instance`. Args: instance: an object.
run
python
bigchaindb/bigchaindb
bigchaindb/utils.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/utils.py
Apache-2.0
def tendermint_version_is_compatible(running_tm_ver): """ Check Tendermint compatability with BigchainDB server :param running_tm_ver: Version number of the connected Tendermint instance :type running_tm_ver: str :return: True/False depending on the compatability with BigchainDB server :rtype: ...
Check Tendermint compatability with BigchainDB server :param running_tm_ver: Version number of the connected Tendermint instance :type running_tm_ver: str :return: True/False depending on the compatability with BigchainDB server :rtype: bool
tendermint_version_is_compatible
python
bigchaindb/bigchaindb
bigchaindb/utils.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/utils.py
Apache-2.0
def connect(backend=None, host=None, port=None, name=None, max_tries=None, connection_timeout=None, replicaset=None, ssl=None, login=None, password=None, ca_cert=None, certfile=None, keyfile=None, keyfile_passphrase=None, crlfile=None): """Create a new connection to the database ...
Create a new connection to the database backend. All arguments default to the current configuration's values if not given. Args: backend (str): the name of the backend to use. host (str): the host to connect to. port (int): the port to connect to. name (str): the name of th...
connect
python
bigchaindb/bigchaindb
bigchaindb/backend/connection.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/backend/connection.py
Apache-2.0
def __init__(self, host=None, port=None, dbname=None, connection_timeout=None, max_tries=None, **kwargs): """Create a new :class:`~.Connection` instance. Args: host (str): the host to connect to. port (int): the port to connect to. d...
Create a new :class:`~.Connection` instance. Args: host (str): the host to connect to. port (int): the port to connect to. dbname (str): the name of the database to use. connection_timeout (int, optional): the milliseconds to wait until timing out...
__init__
python
bigchaindb/bigchaindb
bigchaindb/backend/connection.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/backend/connection.py
Apache-2.0
def init_database(connection=None, dbname=None): """Initialize the configured backend for use with BigchainDB. Creates a database with :attr:`dbname` with any required tables and supporting indexes. Args: connection (:class:`~bigchaindb.backend.connection.Connection`): an existing ...
Initialize the configured backend for use with BigchainDB. Creates a database with :attr:`dbname` with any required tables and supporting indexes. Args: connection (:class:`~bigchaindb.backend.connection.Connection`): an existing connection to use to initialize the database. ...
init_database
python
bigchaindb/bigchaindb
bigchaindb/backend/schema.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/backend/schema.py
Apache-2.0
def validate_language_key(obj, key): """Validate all nested "language" key in `obj`. Args: obj (dict): dictionary whose "language" key is to be validated. Returns: None: validation successful Raises: ValidationError: will raise exception in case language is...
Validate all nested "language" key in `obj`. Args: obj (dict): dictionary whose "language" key is to be validated. Returns: None: validation successful Raises: ValidationError: will raise exception in case language is not valid.
validate_language_key
python
bigchaindb/bigchaindb
bigchaindb/backend/schema.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/backend/schema.py
Apache-2.0
def validate_language(value): """Check if `value` is a valid language. https://docs.mongodb.com/manual/reference/text-search-languages/ Args: value (str): language to validated Returns: None: validation successful Raises: ValidationError: will ra...
Check if `value` is a valid language. https://docs.mongodb.com/manual/reference/text-search-languages/ Args: value (str): language to validated Returns: None: validation successful Raises: ValidationError: will raise exception in case language is not...
validate_language
python
bigchaindb/bigchaindb
bigchaindb/backend/schema.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/backend/schema.py
Apache-2.0
def __init__(self, replicaset=None, ssl=None, login=None, password=None, ca_cert=None, certfile=None, keyfile=None, keyfile_passphrase=None, crlfile=None, **kwargs): """Create a new Connection instance. Args: replicaset (str, optional): the name of the repl...
Create a new Connection instance. Args: replicaset (str, optional): the name of the replica set to connect to. **kwargs: arbitrary keyword arguments provided by the configuration's ``database`` settings
__init__
python
bigchaindb/bigchaindb
bigchaindb/backend/localmongodb/connection.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/backend/localmongodb/connection.py
Apache-2.0
def _connect(self): """Try to connect to the database. Raises: :exc:`~ConnectionError`: If the connection to the database fails. :exc:`~AuthenticationError`: If there is a OperationFailure due to Authentication failure after connecting to the data...
Try to connect to the database. Raises: :exc:`~ConnectionError`: If the connection to the database fails. :exc:`~AuthenticationError`: If there is a OperationFailure due to Authentication failure after connecting to the database. :exc:`~Config...
_connect
python
bigchaindb/bigchaindb
bigchaindb/backend/localmongodb/connection.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/backend/localmongodb/connection.py
Apache-2.0
def run_configure(args): """Run a script to configure the current node.""" config_path = args.config or bigchaindb.config_utils.CONFIG_DEFAULT_PATH config_file_exists = False # if the config path is `-` then it's stdout if config_path != '-': config_file_exists = os.path.exists(config_path)...
Run a script to configure the current node.
run_configure
python
bigchaindb/bigchaindb
bigchaindb/commands/bigchaindb.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/commands/bigchaindb.py
Apache-2.0
def run_election_new_upsert_validator(args, bigchain): """Initiates an election to add/update/remove a validator to an existing BigchainDB network :param args: dict args = { 'public_key': the public key of the proposed peer, (str) 'power': the proposed validator power for the new peer, ...
Initiates an election to add/update/remove a validator to an existing BigchainDB network :param args: dict args = { 'public_key': the public key of the proposed peer, (str) 'power': the proposed validator power for the new peer, (str) 'node_id': the node_id of the new peer (str) ...
run_election_new_upsert_validator
python
bigchaindb/bigchaindb
bigchaindb/commands/bigchaindb.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/commands/bigchaindb.py
Apache-2.0
def run_election_approve(args, bigchain): """Approve an election :param args: dict args = { 'election_id': the election_id of the election (str) 'sk': the path to the private key of the signer (str) } :param bigchain: an instance of BigchainDB :return: success log messag...
Approve an election :param args: dict args = { 'election_id': the election_id of the election (str) 'sk': the path to the private key of the signer (str) } :param bigchain: an instance of BigchainDB :return: success log message or `False` in case of error
run_election_approve
python
bigchaindb/bigchaindb
bigchaindb/commands/bigchaindb.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/commands/bigchaindb.py
Apache-2.0
def run_election_show(args, bigchain): """Retrieves information about an election :param args: dict args = { 'election_id': the transaction_id for an election (str) } :param bigchain: an instance of BigchainDB """ election = bigchain.get_transaction(args.election_id) if...
Retrieves information about an election :param args: dict args = { 'election_id': the transaction_id for an election (str) } :param bigchain: an instance of BigchainDB
run_election_show
python
bigchaindb/bigchaindb
bigchaindb/commands/bigchaindb.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/commands/bigchaindb.py
Apache-2.0
def run_start(args): """Start the processes to run the node""" # Configure Logging setup_logging() logger.info('BigchainDB Version %s', bigchaindb.__version__) run_recover(bigchaindb.lib.BigchainDB()) if not args.skip_initialize_database: logger.info('Initializing database') _...
Start the processes to run the node
run_start
python
bigchaindb/bigchaindb
bigchaindb/commands/bigchaindb.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/commands/bigchaindb.py
Apache-2.0
def configure_bigchaindb(command): """Decorator to be used by command line functions, such that the configuration of bigchaindb is performed before the execution of the command. Args: command: The command to decorate. Returns: The command wrapper function. """ @functools.w...
Decorator to be used by command line functions, such that the configuration of bigchaindb is performed before the execution of the command. Args: command: The command to decorate. Returns: The command wrapper function.
configure_bigchaindb
python
bigchaindb/bigchaindb
bigchaindb/commands/utils.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/commands/utils.py
Apache-2.0
def input_on_stderr(prompt='', default=None, convert=None): """Output a string to stderr and wait for input. Args: prompt (str): the message to display. default: the default value to return if the user leaves the field empty convert (callable): a callable to be used to conve...
Output a string to stderr and wait for input. Args: prompt (str): the message to display. default: the default value to return if the user leaves the field empty convert (callable): a callable to be used to convert the value the user inserted. If None, the type of ...
input_on_stderr
python
bigchaindb/bigchaindb
bigchaindb/commands/utils.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/commands/utils.py
Apache-2.0
def start(parser, argv, scope): """Utility function to execute a subcommand. The function will look up in the ``scope`` if there is a function called ``run_<parser.args.command>`` and will run it using ``parser.args`` as first positional argument. Args: parser: an ArgumentParser instance. ...
Utility function to execute a subcommand. The function will look up in the ``scope`` if there is a function called ``run_<parser.args.command>`` and will run it using ``parser.args`` as first positional argument. Args: parser: an ArgumentParser instance. argv: the list of command line ...
start
python
bigchaindb/bigchaindb
bigchaindb/commands/utils.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/commands/utils.py
Apache-2.0
def generate_key_pair(): """Generates a cryptographic key pair. Returns: :class:`~bigchaindb.common.crypto.CryptoKeypair`: A :obj:`collections.namedtuple` with named fields :attr:`~bigchaindb.common.crypto.CryptoKeypair.private_key` and :attr:`~bigchaindb.common.crypto.CryptoKey...
Generates a cryptographic key pair. Returns: :class:`~bigchaindb.common.crypto.CryptoKeypair`: A :obj:`collections.namedtuple` with named fields :attr:`~bigchaindb.common.crypto.CryptoKeypair.private_key` and :attr:`~bigchaindb.common.crypto.CryptoKeypair.public_key`.
generate_key_pair
python
bigchaindb/bigchaindb
bigchaindb/common/crypto.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/crypto.py
Apache-2.0
def key_pair_from_ed25519_key(hex_private_key): """Generate base58 encode public-private key pair from a hex encoded private key""" priv_key = crypto.Ed25519SigningKey(bytes.fromhex(hex_private_key)[:32], encoding='bytes') public_key = priv_key.get_verifying_key() return CryptoKeypair(private_key=priv_k...
Generate base58 encode public-private key pair from a hex encoded private key
key_pair_from_ed25519_key
python
bigchaindb/bigchaindb
bigchaindb/common/crypto.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/crypto.py
Apache-2.0
def __init__(self, fulfillment, owners_before, fulfills=None): """Create an instance of an :class:`~.Input`. Args: fulfillment (:class:`cryptoconditions.Fulfillment`): A Fulfillment to be signed with a private key. owners_before (:obj:`list` of :o...
Create an instance of an :class:`~.Input`. Args: fulfillment (:class:`cryptoconditions.Fulfillment`): A Fulfillment to be signed with a private key. owners_before (:obj:`list` of :obj:`str`): A list of owners after a Transaction was co...
__init__
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def to_dict(self): """Transforms the object to a Python dictionary. Note: If an Input hasn't been signed yet, this method returns a dictionary representation. Returns: dict: The Input as an alternative serialization format. """ ...
Transforms the object to a Python dictionary. Note: If an Input hasn't been signed yet, this method returns a dictionary representation. Returns: dict: The Input as an alternative serialization format.
to_dict
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def from_dict(cls, data): """Transforms a Python dictionary to an Input object. Note: Optionally, this method can also serialize a Cryptoconditions- Fulfillment that is not yet signed. Args: data (dict): The Input to be transformed. ...
Transforms a Python dictionary to an Input object. Note: Optionally, this method can also serialize a Cryptoconditions- Fulfillment that is not yet signed. Args: data (dict): The Input to be transformed. Returns: :cla...
from_dict
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def _fulfillment_to_details(fulfillment): """Encode a fulfillment as a details dictionary Args: fulfillment: Crypto-conditions Fulfillment object """ if fulfillment.type_name == 'ed25519-sha-256': return { 'type': 'ed25519-sha-256', 'public_key': base58.b58encod...
Encode a fulfillment as a details dictionary Args: fulfillment: Crypto-conditions Fulfillment object
_fulfillment_to_details
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def _fulfillment_from_details(data, _depth=0): """Load a fulfillment for a signing spec dictionary Args: data: tx.output[].condition.details dictionary """ if _depth == 100: raise ThresholdTooDeep() if data['type'] == 'ed25519-sha-256': public_key = base58.b58decode(data['p...
Load a fulfillment for a signing spec dictionary Args: data: tx.output[].condition.details dictionary
_fulfillment_from_details
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def __init__(self, txid=None, output=None): """Create an instance of a :class:`~.TransactionLink`. Note: In an IPLD implementation, this class is not necessary anymore, as an IPLD link can simply point to an object, as well as an objects properties. S...
Create an instance of a :class:`~.TransactionLink`. Note: In an IPLD implementation, this class is not necessary anymore, as an IPLD link can simply point to an object, as well as an objects properties. So instead of having a (de)serializable ...
__init__
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def from_dict(cls, link): """Transforms a Python dictionary to a TransactionLink object. Args: link (dict): The link to be transformed. Returns: :class:`~bigchaindb.common.transaction.TransactionLink` """ try: return cls(link[...
Transforms a Python dictionary to a TransactionLink object. Args: link (dict): The link to be transformed. Returns: :class:`~bigchaindb.common.transaction.TransactionLink`
from_dict
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def to_dict(self): """Transforms the object to a Python dictionary. Returns: (dict|None): The link as an alternative serialization format. """ if self.txid is None and self.output is None: return None else: return { 'tr...
Transforms the object to a Python dictionary. Returns: (dict|None): The link as an alternative serialization format.
to_dict
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def __init__(self, fulfillment, public_keys=None, amount=1): """Create an instance of a :class:`~.Output`. Args: fulfillment (:class:`cryptoconditions.Fulfillment`): A Fulfillment to extract a Condition from. public_keys (:obj:`list` of :obj:`str`...
Create an instance of a :class:`~.Output`. Args: fulfillment (:class:`cryptoconditions.Fulfillment`): A Fulfillment to extract a Condition from. public_keys (:obj:`list` of :obj:`str`, optional): A list of owners before a Transaction w...
__init__
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def to_dict(self): """Transforms the object to a Python dictionary. Note: A dictionary serialization of the Input the Output was derived from is always provided. Returns: dict: The Output as an alternative serialization format. ""...
Transforms the object to a Python dictionary. Note: A dictionary serialization of the Input the Output was derived from is always provided. Returns: dict: The Output as an alternative serialization format.
to_dict
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def generate(cls, public_keys, amount): """Generates a Output from a specifically formed tuple or list. Note: If a ThresholdCondition has to be generated where the threshold is always the number of subconditions it is split between, a list of the foll...
Generates a Output from a specifically formed tuple or list. Note: If a ThresholdCondition has to be generated where the threshold is always the number of subconditions it is split between, a list of the following structure is sufficient: [(a...
generate
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def _gen_condition(cls, initial, new_public_keys): """Generates ThresholdSha256 conditions from a list of new owners. Note: This method is intended only to be used with a reduce function. For a description on how to use this method, see :meth:`~.Outpu...
Generates ThresholdSha256 conditions from a list of new owners. Note: This method is intended only to be used with a reduce function. For a description on how to use this method, see :meth:`~.Output.generate`. Args: initial (:clas...
_gen_condition
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def from_dict(cls, data): """Transforms a Python dictionary to an Output object. Note: To pass a serialization cycle multiple times, a Cryptoconditions Fulfillment needs to be present in the passed-in dictionary, as Condition URIs are not serializable...
Transforms a Python dictionary to an Output object. Note: To pass a serialization cycle multiple times, a Cryptoconditions Fulfillment needs to be present in the passed-in dictionary, as Condition URIs are not serializable anymore. ...
from_dict
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def __init__(self, operation, asset, inputs=None, outputs=None, metadata=None, version=None, hash_id=None, tx_dict=None): """The constructor allows to create a customizable Transaction. Note: When no `version` is provided, one is being generated by t...
The constructor allows to create a customizable Transaction. Note: When no `version` is provided, one is being generated by this method. Args: operation (str): Defines the operation of the Transaction. asset (dict): Asset payload ...
__init__
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def unspent_outputs(self): """UnspentOutput: The outputs of this transaction, in a data structure containing relevant information for storing them in a UTXO set, and performing validation. """ if self.operation == self.CREATE: self._asset_id = self._id elif se...
UnspentOutput: The outputs of this transaction, in a data structure containing relevant information for storing them in a UTXO set, and performing validation.
unspent_outputs
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def spent_outputs(self): """Tuple of :obj:`dict`: Inputs of this transaction. Each input is represented as a dictionary containing a transaction id and output index. """ return ( input_.fulfills.to_dict() for input_ in self.inputs if input_.fulfills ...
Tuple of :obj:`dict`: Inputs of this transaction. Each input is represented as a dictionary containing a transaction id and output index.
spent_outputs
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def create(cls, tx_signers, recipients, metadata=None, asset=None): """A simple way to generate a `CREATE` transaction. Note: This method currently supports the following Cryptoconditions use cases: - Ed25519 - ThresholdSha256 ...
A simple way to generate a `CREATE` transaction. Note: This method currently supports the following Cryptoconditions use cases: - Ed25519 - ThresholdSha256 Additionally, it provides support for the following BigchainDB...
create
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def transfer(cls, inputs, recipients, asset_id, metadata=None): """A simple way to generate a `TRANSFER` transaction. Note: Different cases for threshold conditions: Combining multiple `inputs` with an arbitrary number of `recipients` can yield inter...
A simple way to generate a `TRANSFER` transaction. Note: Different cases for threshold conditions: Combining multiple `inputs` with an arbitrary number of `recipients` can yield interesting cases for the creation of threshold conditions we'd ...
transfer
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def to_inputs(self, indices=None): """Converts a Transaction's outputs to spendable inputs. Note: Takes the Transaction's outputs and derives inputs from that can then be passed into `Transaction.transfer` as `inputs`. A list of intege...
Converts a Transaction's outputs to spendable inputs. Note: Takes the Transaction's outputs and derives inputs from that can then be passed into `Transaction.transfer` as `inputs`. A list of integers can be passed to `indices` that ...
to_inputs
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def add_input(self, input_): """Adds an input to a Transaction's list of inputs. Args: input_ (:class:`~bigchaindb.common.transaction. Input`): An Input to be added to the Transaction. """ if not isinstance(input_, Input): raise TypeEr...
Adds an input to a Transaction's list of inputs. Args: input_ (:class:`~bigchaindb.common.transaction. Input`): An Input to be added to the Transaction.
add_input
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def add_output(self, output): """Adds an output to a Transaction's list of outputs. Args: output (:class:`~bigchaindb.common.transaction. Output`): An Output to be added to the Transaction. """ if not isinstance(output, Output)...
Adds an output to a Transaction's list of outputs. Args: output (:class:`~bigchaindb.common.transaction. Output`): An Output to be added to the Transaction.
add_output
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def sign(self, private_keys): """Fulfills a previous Transaction's Output by signing Inputs. Note: This method works only for the following Cryptoconditions currently: - Ed25519Fulfillment - ThresholdSha256 Furt...
Fulfills a previous Transaction's Output by signing Inputs. Note: This method works only for the following Cryptoconditions currently: - Ed25519Fulfillment - ThresholdSha256 Furthermore, note that all keys required to f...
sign
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def _sign_input(cls, input_, message, key_pairs): """Signs a single Input. Note: This method works only for the following Cryptoconditions currently: - Ed25519Fulfillment - ThresholdSha256. Args: in...
Signs a single Input. Note: This method works only for the following Cryptoconditions currently: - Ed25519Fulfillment - ThresholdSha256. Args: input_ (:class:`~bigchaindb.common.transaction. ...
_sign_input
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def _sign_simple_signature_fulfillment(cls, input_, message, key_pairs): """Signs a Ed25519Fulfillment. Args: input_ (:class:`~bigchaindb.common.transaction. Input`) The input to be signed. message (str): The message to be signed k...
Signs a Ed25519Fulfillment. Args: input_ (:class:`~bigchaindb.common.transaction. Input`) The input to be signed. message (str): The message to be signed key_pairs (dict): The keys to sign the Transaction with.
_sign_simple_signature_fulfillment
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def _sign_threshold_signature_fulfillment(cls, input_, message, key_pairs): """Signs a ThresholdSha256. Args: input_ (:class:`~bigchaindb.common.transaction. Input`) The Input to be signed. message (str): The message to be signed k...
Signs a ThresholdSha256. Args: input_ (:class:`~bigchaindb.common.transaction. Input`) The Input to be signed. message (str): The message to be signed key_pairs (dict): The keys to sign the Transaction with.
_sign_threshold_signature_fulfillment
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def _inputs_valid(self, output_condition_uris): """Validates an Input against a given set of Outputs. Note: The number of `output_condition_uris` must be equal to the number of Inputs a Transaction has. Args: output_condition_uris (:obj:`...
Validates an Input against a given set of Outputs. Note: The number of `output_condition_uris` must be equal to the number of Inputs a Transaction has. Args: output_condition_uris (:obj:`list` of :obj:`str`): A list of Outputs...
_inputs_valid
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def _input_valid(self, input_, operation, message, output_condition_uri=None): """Validates a single Input against a single Output. Note: In case of a `CREATE` Transaction, this method does not validate against `output_condition_uri`. Args: ...
Validates a single Input against a single Output. Note: In case of a `CREATE` Transaction, this method does not validate against `output_condition_uri`. Args: input_ (:class:`~bigchaindb.common.transaction. Input`) The Input t...
_input_valid
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def to_dict(self): """Transforms the object to a Python dictionary. Returns: dict: The Transaction as an alternative serialization format. """ return { 'inputs': [input_.to_dict() for input_ in self.inputs], 'outputs': [output.to_dict() for ou...
Transforms the object to a Python dictionary. Returns: dict: The Transaction as an alternative serialization format.
to_dict
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def _remove_signatures(tx_dict): """Takes a Transaction dictionary and removes all signatures. Args: tx_dict (dict): The Transaction to remove all signatures from. Returns: dict """ # NOTE: We remove the reference since we need `tx_dict`...
Takes a Transaction dictionary and removes all signatures. Args: tx_dict (dict): The Transaction to remove all signatures from. Returns: dict
_remove_signatures
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def get_asset_id(cls, transactions): """Get the asset id from a list of :class:`~.Transactions`. This is useful when we want to check if the multiple inputs of a transaction are related to the same asset id. Args: transactions (:obj:`list` of :class:`~bigchaindb.common. ...
Get the asset id from a list of :class:`~.Transactions`. This is useful when we want to check if the multiple inputs of a transaction are related to the same asset id. Args: transactions (:obj:`list` of :class:`~bigchaindb.common. transaction.Transaction`): A list o...
get_asset_id
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def validate_id(tx_body): """Validate the transaction ID of a transaction Args: tx_body (dict): The Transaction to be transformed. """ # NOTE: Remove reference to avoid side effects # tx_body = deepcopy(tx_body) tx_body = rapidjson.loads(rapidjson.dum...
Validate the transaction ID of a transaction Args: tx_body (dict): The Transaction to be transformed.
validate_id
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def from_dict(cls, tx, skip_schema_validation=True): """Transforms a Python dictionary to a Transaction object. Args: tx_body (dict): The Transaction to be transformed. Returns: :class:`~bigchaindb.common.transaction.Transaction` """ oper...
Transforms a Python dictionary to a Transaction object. Args: tx_body (dict): The Transaction to be transformed. Returns: :class:`~bigchaindb.common.transaction.Transaction`
from_dict
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def from_db(cls, bigchain, tx_dict_list): """Helper method that reconstructs a transaction dict that was returned from the database. It checks what asset_id to retrieve, retrieves the asset from the asset table and reconstructs the transaction. Args: bigchain (:class:`~bigch...
Helper method that reconstructs a transaction dict that was returned from the database. It checks what asset_id to retrieve, retrieves the asset from the asset table and reconstructs the transaction. Args: bigchain (:class:`~bigchaindb.tendermint.BigchainDB`): An instance ...
from_db
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def resolve_class(operation): """For the given `tx` based on the `operation` key return its implementation class""" create_txn_class = Transaction.type_registry.get(Transaction.CREATE) return Transaction.type_registry.get(operation, create_txn_class)
For the given `tx` based on the `operation` key return its implementation class
resolve_class
python
bigchaindb/bigchaindb
bigchaindb/common/transaction.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/transaction.py
Apache-2.0
def validate_txn_obj(obj_name, obj, key, validation_fun): """Validate value of `key` in `obj` using `validation_fun`. Args: obj_name (str): name for `obj` being validated. obj (dict): dictionary object. key (str): key to be validated in `obj`. validation_fun ...
Validate value of `key` in `obj` using `validation_fun`. Args: obj_name (str): name for `obj` being validated. obj (dict): dictionary object. key (str): key to be validated in `obj`. validation_fun (function): function used to validate the value of `k...
validate_txn_obj
python
bigchaindb/bigchaindb
bigchaindb/common/utils.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/utils.py
Apache-2.0
def validate_all_keys_in_obj(obj_name, obj, validation_fun): """Validate all (nested) keys in `obj` by using `validation_fun`. Args: obj_name (str): name for `obj` being validated. obj (dict): dictionary object. validation_fun (function): function used to validate the va...
Validate all (nested) keys in `obj` by using `validation_fun`. Args: obj_name (str): name for `obj` being validated. obj (dict): dictionary object. validation_fun (function): function used to validate the value of `key`. Returns: None: indica...
validate_all_keys_in_obj
python
bigchaindb/bigchaindb
bigchaindb/common/utils.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/utils.py
Apache-2.0
def validate_all_values_for_key_in_obj(obj, key, validation_fun): """Validate value for all (nested) occurrence of `key` in `obj` using `validation_fun`. Args: obj (dict): dictionary object. key (str): key whose value is to be validated. validation_fun (function)...
Validate value for all (nested) occurrence of `key` in `obj` using `validation_fun`. Args: obj (dict): dictionary object. key (str): key whose value is to be validated. validation_fun (function): function used to validate the value of `key`. Rais...
validate_all_values_for_key_in_obj
python
bigchaindb/bigchaindb
bigchaindb/common/utils.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/utils.py
Apache-2.0
def validate_transaction_schema(tx): """Validate a transaction dict. TX_SCHEMA_COMMON contains properties that are common to all types of transaction. TX_SCHEMA_[TRANSFER|CREATE] add additional constraints on top. """ _validate_schema(TX_SCHEMA_COMMON, tx) if tx['operation'] == 'TRANSFER': ...
Validate a transaction dict. TX_SCHEMA_COMMON contains properties that are common to all types of transaction. TX_SCHEMA_[TRANSFER|CREATE] add additional constraints on top.
validate_transaction_schema
python
bigchaindb/bigchaindb
bigchaindb/common/schema/__init__.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/common/schema/__init__.py
Apache-2.0
def get_validator_change(cls, bigchain): """Return the validator set from the most recent approved block :return: { 'height': <block_height>, 'validators': <validator_set> } """ latest_block = bigchain.get_latest_block() if latest_block is None: ...
Return the validator set from the most recent approved block :return: { 'height': <block_height>, 'validators': <validator_set> }
get_validator_change
python
bigchaindb/bigchaindb
bigchaindb/elections/election.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/elections/election.py
Apache-2.0
def get_validators(cls, bigchain, height=None): """Return a dictionary of validators with key as `public_key` and value as the `voting_power` """ validators = {} for validator in bigchain.get_validators(height): # NOTE: we assume that Tendermint encodes public key ...
Return a dictionary of validators with key as `public_key` and value as the `voting_power`
get_validators
python
bigchaindb/bigchaindb
bigchaindb/elections/election.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/elections/election.py
Apache-2.0
def recipients(cls, bigchain): """Convert validator dictionary to a recipient list for `Transaction`""" recipients = [] for public_key, voting_power in cls.get_validators(bigchain).items(): recipients.append(([public_key], voting_power)) return recipients
Convert validator dictionary to a recipient list for `Transaction`
recipients
python
bigchaindb/bigchaindb
bigchaindb/elections/election.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/elections/election.py
Apache-2.0
def validate(self, bigchain, current_transactions=[]): """Validate election transaction NOTE: * A valid election is initiated by an existing validator. * A valid election is one where voters are validators and votes are allocated according to the voting power of each validato...
Validate election transaction NOTE: * A valid election is initiated by an existing validator. * A valid election is one where voters are validators and votes are allocated according to the voting power of each validator node. Args: :param bigchain: (BigchainDB) a...
validate
python
bigchaindb/bigchaindb
bigchaindb/elections/election.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/elections/election.py
Apache-2.0
def validate_schema(cls, tx): """Validate the election transaction. Since `ELECTION` extends `CREATE` transaction, all the validations for `CREATE` transaction should be inherited """ _validate_schema(TX_SCHEMA_COMMON, tx) _validate_schema(TX_SCHEMA_CREATE, tx) if cls.TX_...
Validate the election transaction. Since `ELECTION` extends `CREATE` transaction, all the validations for `CREATE` transaction should be inherited
validate_schema
python
bigchaindb/bigchaindb
bigchaindb/elections/election.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/elections/election.py
Apache-2.0
def has_concluded(self, bigchain, current_votes=[]): """Check if the election can be concluded or not. * Elections can only be concluded if the validator set has not changed since the election was initiated. * Elections can be concluded only if the current votes form a supermajority. ...
Check if the election can be concluded or not. * Elections can only be concluded if the validator set has not changed since the election was initiated. * Elections can be concluded only if the current votes form a supermajority. Custom elections may override this function and introdu...
has_concluded
python
bigchaindb/bigchaindb
bigchaindb/elections/election.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/elections/election.py
Apache-2.0
def process_block(cls, bigchain, new_height, txns): """Looks for election and vote transactions inside the block, records and processes elections. Every election is recorded in the database. Every vote has a chance to conclude the corresponding election. When an ele...
Looks for election and vote transactions inside the block, records and processes elections. Every election is recorded in the database. Every vote has a chance to conclude the corresponding election. When an election is concluded, the corresponding database record is ...
process_block
python
bigchaindb/bigchaindb
bigchaindb/elections/election.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/elections/election.py
Apache-2.0
def validate_schema(cls, tx): """Validate the validator election vote transaction. Since `VOTE` extends `TRANSFER` transaction, all the validations for `CREATE` transaction should be inherited """ _validate_schema(TX_SCHEMA_COMMON, tx) _validate_schema(TX_SCHEMA_TRANSFER, tx) ...
Validate the validator election vote transaction. Since `VOTE` extends `TRANSFER` transaction, all the validations for `CREATE` transaction should be inherited
validate_schema
python
bigchaindb/bigchaindb
bigchaindb/elections/vote.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/elections/vote.py
Apache-2.0
def validate(self, bigchain, current_transactions=[]): """For more details refer BEP-21: https://github.com/bigchaindb/BEPs/tree/master/21 """ current_validators = self.get_validators(bigchain) super(ValidatorElection, self).validate(bigchain, current_transactions=current_transactions)...
For more details refer BEP-21: https://github.com/bigchaindb/BEPs/tree/master/21
validate
python
bigchaindb/bigchaindb
bigchaindb/upsert_validator/validator_election.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/upsert_validator/validator_election.py
Apache-2.0
def add_routes(app): """Add the routes to an app""" for (prefix, routes) in API_SECTIONS: api = Api(app, prefix=prefix) for ((pattern, resource, *args), kwargs) in routes: kwargs.setdefault('strict_slashes', False) api.add_resource(resource, pattern, *args, **kwargs)
Add the routes to an app
add_routes
python
bigchaindb/bigchaindb
bigchaindb/web/routes.py
https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/web/routes.py
Apache-2.0