mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Added missing docstrings. Fixed typos.
This commit is contained in:
parent
eb94181e1b
commit
ce414e46f3
@ -293,8 +293,8 @@ def get_last_voted_block_id(connection, node_pubkey):
|
|||||||
node_pubkey (str): base58 encoded public key.
|
node_pubkey (str): base58 encoded public key.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
The last block the node has voted on. If the node didn't cast
|
The last block id the node has voted on. If the node didn't cast
|
||||||
any vote then the genesis block is returned.
|
any vote then the genesis block id is returned.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
@ -641,8 +641,24 @@ class Bigchain(object):
|
|||||||
return self.block_election(block)['status']
|
return self.block_election(block)['status']
|
||||||
|
|
||||||
def get_assets(self, asset_ids):
|
def get_assets(self, asset_ids):
|
||||||
# TODO: write docstrings
|
"""
|
||||||
|
Return a list of assets that match the asset_ids
|
||||||
|
|
||||||
|
Args:
|
||||||
|
asset_ids (:obj:`list` of :obj:`str`): A list of asset_ids to
|
||||||
|
retrieve from the database.
|
||||||
|
|
||||||
|
Returs:
|
||||||
|
list: The list of assets returned from the database.
|
||||||
|
"""
|
||||||
return backend.query.get_assets(self.connection, asset_ids)
|
return backend.query.get_assets(self.connection, asset_ids)
|
||||||
|
|
||||||
def write_assets(self, assets):
|
def write_assets(self, assets):
|
||||||
|
"""
|
||||||
|
Writes a list of assets into the database.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
assets (:obj:`list` of :obj:`dict`): A list of assets to write to
|
||||||
|
the database.
|
||||||
|
"""
|
||||||
return backend.query.write_assets(self.connection, assets)
|
return backend.query.write_assets(self.connection, assets)
|
||||||
|
@ -88,8 +88,22 @@ class Transaction(Transaction):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_db(cls, bigchain, tx_dict):
|
def from_db(cls, bigchain, tx_dict):
|
||||||
# TODO: write docstring
|
"""
|
||||||
if tx_dict['operation'] in [Transaction.CREATE, Transaction.CREATE]:
|
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.Bigchain`): An instance of Bigchain
|
||||||
|
used to perform database queries.
|
||||||
|
tx_dict (:obj:`dict`): The transaction dict as returned from the
|
||||||
|
database.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
:class:`~Transaction`
|
||||||
|
|
||||||
|
"""
|
||||||
|
if tx_dict['operation'] in [Transaction.CREATE, Transaction.GENESIS]:
|
||||||
# TODO: Maybe replace this call to a call to get_asset_by_id
|
# TODO: Maybe replace this call to a call to get_asset_by_id
|
||||||
asset = list(bigchain.get_assets([tx_dict['id']]))[0]
|
asset = list(bigchain.get_assets([tx_dict['id']]))[0]
|
||||||
asset.pop('id')
|
asset.pop('id')
|
||||||
@ -317,12 +331,14 @@ class Block(object):
|
|||||||
def from_db(cls, bigchain, block_dict):
|
def from_db(cls, bigchain, block_dict):
|
||||||
"""
|
"""
|
||||||
Helper method that reconstructs a block_dict that was returned from
|
Helper method that reconstructs a block_dict that was returned from
|
||||||
the database. If checks what asset_ids to retrieve, retrieves the
|
the database. It checks what asset_ids to retrieve, retrieves the
|
||||||
assets from the assets table and reconstructs the block.
|
assets from the assets table and reconstructs the block.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
bigchain (:class:`~bigchaindb.Bigchain`): An instance of Bigchain
|
bigchain (:class:`~bigchaindb.Bigchain`): An instance of Bigchain
|
||||||
used to perform database queries.
|
used to perform database queries.
|
||||||
|
block_dict(:obj:`dict`): The block dict as returned from the
|
||||||
|
database.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
:class:`~Block`
|
:class:`~Block`
|
||||||
|
@ -281,7 +281,7 @@ class TestBlockModel(object):
|
|||||||
# decouple assets
|
# decouple assets
|
||||||
assets_from_block, block_dict = block.decouple_assets()
|
assets_from_block, block_dict = block.decouple_assets()
|
||||||
|
|
||||||
# write the assets and block separatedly
|
# write the assets and block separately
|
||||||
b.write_assets(assets_from_block)
|
b.write_assets(assets_from_block)
|
||||||
b.write_block(block)
|
b.write_block(block)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user