From 2fef20148904e600ba74926b627235f2ecc85f7d Mon Sep 17 00:00:00 2001 From: Troy McConaghy Date: Thu, 10 Nov 2016 10:22:29 +0100 Subject: [PATCH 01/10] Fixed broken link in CONTRIBUTING.md file Fixed the link to the setuptools documentation about "extras", i.e. the `extras_require` bit of `setup.py`. --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 92137572..cf3a552c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -82,7 +82,7 @@ How? Let's split the command down into its components: - `install` tells pip to use the *install* action - `-e` installs a project in [editable mode](https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs) - `.` installs what's in the current directory - - `[dev]` adds some [extra requirements](https://pythonhosted.org/setuptools/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies) to the installation. (If you are curious, open `setup.py` and look for `dev` in the `extras_require` section.) + - `[dev]` adds some [extra requirements](https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies) to the installation. (If you are curious, open `setup.py` and look for `dev` in the `extras_require` section.) Aside: An alternative to `pip install -e .[dev]` is `python setup.py develop`. From d31a268a51671ff45736df08ff76bdbf055d025c Mon Sep 17 00:00:00 2001 From: Ryan Henderson Date: Fri, 11 Nov 2016 15:08:37 +0100 Subject: [PATCH 02/10] add id query (#799) --- bigchaindb/core.py | 22 ++++++++++++++++++++++ bigchaindb/db/backends/rethinkdb.py | 11 +++++++++++ tests/db/test_bigchain_api.py | 9 +++++++++ 3 files changed, 42 insertions(+) diff --git a/bigchaindb/core.py b/bigchaindb/core.py index 5a007eab..7711514a 100644 --- a/bigchaindb/core.py +++ b/bigchaindb/core.py @@ -188,6 +188,28 @@ class Bigchain(object): exceptions.FulfillmentNotInValidBlock): return False + def get_block(self, block_id, include_status=False): + """Get the block with the specified `block_id` (and optionally its status) + + Returns the block corresponding to `block_id` or None if no match is + found. + + Args: + block_id (str): transaction id of the transaction to get + include_status (bool): also return the status of the block + the return value is then a tuple: (block, status) + """ + block = self.backend.get_block(block_id) + status = None + + if include_status: + if block: + status = self.block_election_status(block_id, + block['block']['voters']) + return block, status + else: + return block + def get_transaction(self, txid, include_status=False): """Get the transaction with the specified `txid` (and optionally its status) diff --git a/bigchaindb/db/backends/rethinkdb.py b/bigchaindb/db/backends/rethinkdb.py index 22937dd2..5b73cce6 100644 --- a/bigchaindb/db/backends/rethinkdb.py +++ b/bigchaindb/db/backends/rethinkdb.py @@ -258,6 +258,17 @@ class RethinkDBBackend: r.table('bigchain') .insert(r.json(block), durability=durability)) + def get_block(self, block_id): + """Get a block from the bigchain table + + Args: + block_id (str): block id of the block to get + + Returns: + block (dict): the block or `None` + """ + return self.connection.run(r.table('bigchain').get(block_id)) + def has_transaction(self, transaction_id): """Check if a transaction exists in the bigchain table. diff --git a/tests/db/test_bigchain_api.py b/tests/db/test_bigchain_api.py index a6b76eb4..314286c6 100644 --- a/tests/db/test_bigchain_api.py +++ b/tests/db/test_bigchain_api.py @@ -369,6 +369,15 @@ class TestBigchainApi(object): assert excinfo.value.args[0] == 'Empty block creation is not allowed' + @pytest.mark.usefixtures('inputs') + def test_get_block_by_id(self, b): + new_block = dummy_block() + b.write_block(new_block, durability='hard') + + assert b.get_block(new_block.id) == new_block.to_dict() + block, status = b.get_block(new_block.id, include_status=True) + assert status == b.BLOCK_UNDECIDED + def test_get_last_voted_block_returns_genesis_if_no_votes_has_been_casted(self, b): import rethinkdb as r from bigchaindb import util From 1c8fec730c15be3c3527d9ae8609c19e8fae5a8a Mon Sep 17 00:00:00 2001 From: tim Date: Thu, 10 Nov 2016 11:02:23 +0100 Subject: [PATCH 03/10] Format http api docs to 79 chars --- .../http-client-server-api.rst | 44 ++++++++++++++----- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/docs/server/source/drivers-clients/http-client-server-api.rst b/docs/server/source/drivers-clients/http-client-server-api.rst index 74bcf1d2..d274efad 100644 --- a/docs/server/source/drivers-clients/http-client-server-api.rst +++ b/docs/server/source/drivers-clients/http-client-server-api.rst @@ -3,21 +3,35 @@ The HTTP Client-Server API .. note:: - The HTTP client-server API is currently quite rudimentary. For example, there is no ability to do complex queries using the HTTP API. We plan to add querying capabilities in the future. + The HTTP client-server API is currently quite rudimentary. For example, + there is no ability to do complex queries using the HTTP API. We plan to add + querying capabilities in the future. -When you start Bigchaindb using `bigchaindb start`, an HTTP API is exposed at the address stored in the BigchainDB node configuration settings. The default is: +When you start Bigchaindb using `bigchaindb start`, an HTTP API is exposed at +the address stored in the BigchainDB node configuration settings. The default +is: `http://localhost:9984/api/v1/ `_ -but that address can be changed by changing the "API endpoint" configuration setting (e.g. in a local config file). There's more information about setting the API endpoint in :doc:`the section about BigchainDB Configuration Settings <../server-reference/configuration>`. +but that address can be changed by changing the "API endpoint" configuration +setting (e.g. in a local config file). There's more information about setting +the API endpoint in :doc:`the section about BigchainDB Configuration Settings +<../server-reference/configuration>`. -There are other configuration settings related to the web server (serving the HTTP API). In particular, the default is for the web server socket to bind to ``localhost:9984`` but that can be changed (e.g. to ``0.0.0.0:9984``). For more details, see the "server" settings ("bind", "workers" and "threads") in :doc:`the section about BigchainDB Configuration Settings <../server-reference/configuration>`. +There are other configuration settings related to the web server (serving the +HTTP API). In particular, the default is for the web server socket to bind to +``localhost:9984`` but that can be changed (e.g. to ``0.0.0.0:9984``). For more +details, see the "server" settings ("bind", "workers" and "threads") in +:doc:`the section about BigchainDB Configuration Settings +<../server-reference/configuration>`. API Root -------- -If you send an HTTP GET request to e.g. ``http://localhost:9984`` (with no ``/api/v1/`` on the end), then you should get an HTTP response with something like the following in the body: +If you send an HTTP GET request to e.g. ``http://localhost:9984`` (with no +``/api/v1/`` on the end), then you should get an HTTP response with something +like the following in the body: .. code-block:: json @@ -39,8 +53,13 @@ POST /transactions/ .. http:post:: /transactions/ Push a new transaction. - - Note: The posted transaction should be valid `transaction `_. The steps to build a valid transaction are beyond the scope of this page. One would normally use a driver such as the `BigchainDB Python Driver `_ to build a valid transaction. + + Note: The posted transaction should be valid `transaction + `_. + The steps to build a valid transaction are beyond the scope of this page. + One would normally use a driver such as the `BigchainDB Python Driver + `_ to + build a valid transaction. **Example request**: @@ -158,9 +177,11 @@ GET /transactions/{tx_id}/status .. http:get:: /transactions/{tx_id}/status - Get the status of the transaction with the ID ``tx_id``, if a transaction with that ``tx_id`` exists. + Get the status of the transaction with the ID ``tx_id``, if a transaction + with that ``tx_id`` exists. - The possible status values are ``backlog``, ``undecided``, ``valid`` or ``invalid``. + The possible status values are ``backlog``, ``undecided``, ``valid`` or + ``invalid``. :param tx_id: transaction ID :type tx_id: hex string @@ -194,7 +215,8 @@ GET /transactions/{tx_id} Get the transaction with the ID ``tx_id``. - This endpoint returns only a transaction from a ``VALID`` or ``UNDECIDED`` block on ``bigchain``, if exists. + This endpoint returns only a transaction from a ``VALID`` or ``UNDECIDED`` + block on ``bigchain``, if exists. :param tx_id: transaction ID :type tx_id: hex string @@ -260,4 +282,4 @@ GET /transactions/{tx_id} } :statuscode 200: A transaction with that ID was found. - :statuscode 404: A transaction with that ID was not found. \ No newline at end of file + :statuscode 404: A transaction with that ID was not found. From c8553abb4146e2b290109753608d71bd5074f0ee Mon Sep 17 00:00:00 2001 From: Ryan Henderson Date: Mon, 14 Nov 2016 10:03:59 +0100 Subject: [PATCH 04/10] add backlog count (#806) --- bigchaindb/db/backends/rethinkdb.py | 11 +++++++++++ tests/db/test_bigchain_api.py | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/bigchaindb/db/backends/rethinkdb.py b/bigchaindb/db/backends/rethinkdb.py index 5b73cce6..aeb68572 100644 --- a/bigchaindb/db/backends/rethinkdb.py +++ b/bigchaindb/db/backends/rethinkdb.py @@ -293,6 +293,17 @@ class RethinkDBBackend: r.table('bigchain', read_mode=self.read_mode) .count()) + def count_backlog(self): + """Count the number of transactions in the backlog table. + + Returns: + The number of transactions in the backlog. + """ + + return self.connection.run( + r.table('backlog', read_mode=self.read_mode) + .count()) + def write_vote(self, vote): """Write a vote to the votes table. diff --git a/tests/db/test_bigchain_api.py b/tests/db/test_bigchain_api.py index 314286c6..6a7880e9 100644 --- a/tests/db/test_bigchain_api.py +++ b/tests/db/test_bigchain_api.py @@ -592,6 +592,15 @@ class TestBigchainApi(object): with pytest.raises(TransactionDoesNotExist) as excinfo: tx.validate(Bigchain()) + def test_count_backlog(self, b, user_vk): + from bigchaindb.models import Transaction + + for _ in range(4): + tx = Transaction.create([b.me], [user_vk]).sign([b.me_private]) + b.write_transaction(tx) + + assert b.backend.count_backlog() == 4 + class TestTransactionValidation(object): def test_create_operation_with_inputs(self, b, user_vk, create_tx): From 29832f9a9bd72cbff855b2150c4a3568b00eda21 Mon Sep 17 00:00:00 2001 From: Ryan Henderson Date: Mon, 14 Nov 2016 10:04:28 +0100 Subject: [PATCH 05/10] add get_genesis_block (#809) --- bigchaindb/db/backends/rethinkdb.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/bigchaindb/db/backends/rethinkdb.py b/bigchaindb/db/backends/rethinkdb.py index aeb68572..c9a171e9 100644 --- a/bigchaindb/db/backends/rethinkdb.py +++ b/bigchaindb/db/backends/rethinkdb.py @@ -317,6 +317,17 @@ class RethinkDBBackend: r.table('votes') .insert(vote)) + def get_genesis_block(self): + """Get the genesis block + + Returns: + The genesis block + """ + return self.connection.run( + r.table('bigchain', read_mode=self.read_mode) + .filter(util.is_genesis_block) + .nth(0)) + def get_last_voted_block(self, node_pubkey): """Get the last voted block for a specific node. @@ -341,10 +352,7 @@ class RethinkDBBackend: except r.ReqlNonExistenceError: # return last vote if last vote exists else return Genesis block - return self.connection.run( - r.table('bigchain', read_mode=self.read_mode) - .filter(util.is_genesis_block) - .nth(0)) + return self.get_genesis_block() # Now the fun starts. Since the resolution of timestamp is a second, # we might have more than one vote per timestamp. If this is the case From f69ccc93df916d273bea61ca30128c21d68ce1a7 Mon Sep 17 00:00:00 2001 From: tim Date: Mon, 17 Oct 2016 15:00:38 +0200 Subject: [PATCH 06/10] Add doc strings for Block cls --- bigchaindb/models.py | 86 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 78 insertions(+), 8 deletions(-) diff --git a/bigchaindb/models.py b/bigchaindb/models.py index 6471b075..6d2ff053 100644 --- a/bigchaindb/models.py +++ b/bigchaindb/models.py @@ -118,8 +118,36 @@ class Transaction(Transaction): class Block(object): + """A Block bundles up to 1000 Transactions. Nodes vote on its validity. + + Attributes: + transaction (:obj:`list` of :class:`~.Transaction`): + Transactions to be included in the Block. + node_pubkey (str): The public key of the node creating the + Block. + timestamp (str): The Unix time a Block was created. + voters (:obj:`list` of :obj:`str`): A list of a federation + nodes' public keys supposed to vote on the Block. + signature (str): A cryptographic signature ensuring the + integrity and creatorship of a Block. + """ + def __init__(self, transactions=None, node_pubkey=None, timestamp=None, voters=None, signature=None): + """The Block model is mainly used for (de)serialization and integrity + checking. + + Args: + transaction (:obj:`list` of :class:`~.Transaction`): + Transactions to be included in the Block. + node_pubkey (str): The public key of the node creating the + Block. + timestamp (str): The Unix time a Block was created. + voters (:obj:`list` of :obj:`str`): A list of a federation + nodes' public keys supposed to vote on the Block. + signature (str): A cryptographic signature ensuring the + integrity and creatorship of a Block. + """ if transactions is not None and not isinstance(transactions, list): raise TypeError('`transactions` must be a list instance or None') else: @@ -146,18 +174,20 @@ class Block(object): return self.to_dict() == other def validate(self, bigchain): - """Validate a block. + """Validates the Block. Args: - bigchain (Bigchain): an instantiated bigchaindb.Bigchain object. + bigchain (:class:`~bigchaindb.Bigchain`): An instantiated Bigchain + object. Returns: - block (Block): The block as a `Block` object if it is valid. - Else it raises an appropriate exception describing - the reason of invalidity. + :class:`~.Block`: If valid, returns a `Block` object. Else an + appropriate exception describing the reason of invalidity is + raised. Raises: - OperationError: if a non-federation node signed the block. + OperationError: If a non-federation node signed the Block. + InvalidSignature: If a Block's signature is invalid. """ # First, make sure this node hasn't already voted on this block @@ -182,6 +212,15 @@ class Block(object): return self def sign(self, signing_key): + """Creates a signature for the Block and overwrites `self.signature`. + + Args: + signing_key (str): A signing key corresponding to + `self.node_pubkey`. + + Returns: + :class:`~.Block` + """ block_body = self.to_dict() block_serialized = serialize(block_body['block']) signing_key = SigningKey(signing_key) @@ -189,8 +228,13 @@ class Block(object): return self def is_signature_valid(self): + """Checks the validity of a Block's signature. + + Returns: + bool: Stating the validity of the Block's signature. + """ block = self.to_dict()['block'] - # cc only accepts bytesting messages + # cc only accepts bytestring messages block_serialized = serialize(block).encode() verifying_key = VerifyingKey(block['node_pubkey']) try: @@ -202,6 +246,24 @@ class Block(object): @classmethod def from_dict(cls, block_body): + """Transforms a Python dictionary to a Block object. + + Note: + Throws errors if passed signature or id is incorrect. + + Args: + block_body (dict): A block dictionary to be transformed. + + Returns: + :class:`~Block` + + Raises: + InvalidHash: If the block's id is not corresponding to its + data. + InvalidSignature: If the block's signature is not corresponding + to it's data or `node_pubkey`. + """ + # TODO: Reuse `is_signature_valid` method here. block = block_body['block'] block_serialized = serialize(block) block_id = hash_data(block_serialized) @@ -220,7 +282,7 @@ class Block(object): # https://github.com/bigchaindb/cryptoconditions/issues/27 try: signature_valid = verifying_key\ - .verify(block_serialized.encode(), signature) + .verify(block_serialized.encode(), signature) except ValueError: signature_valid = False if signature_valid is False: @@ -237,6 +299,14 @@ class Block(object): return self.to_dict()['id'] def to_dict(self): + """Transforms the object to a Python dictionary. + + Returns: + dict: The Block as an alternative serialization format. + + Raises: + OperationError: If a Block doesn't contain any transactions. + """ if len(self.transactions) == 0: raise OperationError('Empty block creation is not allowed') From b42eec93c7b05df09191e0afac9676c65f7f6fcc Mon Sep 17 00:00:00 2001 From: tim Date: Mon, 14 Nov 2016 13:53:49 +0100 Subject: [PATCH 07/10] Fix indentation for model docs --- bigchaindb/models.py | 80 ++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/bigchaindb/models.py b/bigchaindb/models.py index 6d2ff053..afda5ca9 100644 --- a/bigchaindb/models.py +++ b/bigchaindb/models.py @@ -120,7 +120,24 @@ class Transaction(Transaction): class Block(object): """A Block bundles up to 1000 Transactions. Nodes vote on its validity. - Attributes: + Attributes: + transaction (:obj:`list` of :class:`~.Transaction`): + Transactions to be included in the Block. + node_pubkey (str): The public key of the node creating the + Block. + timestamp (str): The Unix time a Block was created. + voters (:obj:`list` of :obj:`str`): A list of a federation + nodes' public keys supposed to vote on the Block. + signature (str): A cryptographic signature ensuring the + integrity and creatorship of a Block. + """ + + def __init__(self, transactions=None, node_pubkey=None, timestamp=None, + voters=None, signature=None): + """The Block model is mainly used for (de)serialization and integrity + checking. + + Args: transaction (:obj:`list` of :class:`~.Transaction`): Transactions to be included in the Block. node_pubkey (str): The public key of the node creating the @@ -130,23 +147,6 @@ class Block(object): nodes' public keys supposed to vote on the Block. signature (str): A cryptographic signature ensuring the integrity and creatorship of a Block. - """ - - def __init__(self, transactions=None, node_pubkey=None, timestamp=None, - voters=None, signature=None): - """The Block model is mainly used for (de)serialization and integrity - checking. - - Args: - transaction (:obj:`list` of :class:`~.Transaction`): - Transactions to be included in the Block. - node_pubkey (str): The public key of the node creating the - Block. - timestamp (str): The Unix time a Block was created. - voters (:obj:`list` of :obj:`str`): A list of a federation - nodes' public keys supposed to vote on the Block. - signature (str): A cryptographic signature ensuring the - integrity and creatorship of a Block. """ if transactions is not None and not isinstance(transactions, list): raise TypeError('`transactions` must be a list instance or None') @@ -214,12 +214,12 @@ class Block(object): def sign(self, signing_key): """Creates a signature for the Block and overwrites `self.signature`. - Args: - signing_key (str): A signing key corresponding to - `self.node_pubkey`. + Args: + signing_key (str): A signing key corresponding to + `self.node_pubkey`. - Returns: - :class:`~.Block` + Returns: + :class:`~.Block` """ block_body = self.to_dict() block_serialized = serialize(block_body['block']) @@ -230,8 +230,8 @@ class Block(object): def is_signature_valid(self): """Checks the validity of a Block's signature. - Returns: - bool: Stating the validity of the Block's signature. + Returns: + bool: Stating the validity of the Block's signature. """ block = self.to_dict()['block'] # cc only accepts bytestring messages @@ -248,20 +248,20 @@ class Block(object): def from_dict(cls, block_body): """Transforms a Python dictionary to a Block object. - Note: - Throws errors if passed signature or id is incorrect. + Note: + Throws errors if passed signature or id is incorrect. - Args: - block_body (dict): A block dictionary to be transformed. + Args: + block_body (dict): A block dictionary to be transformed. - Returns: - :class:`~Block` + Returns: + :class:`~Block` - Raises: - InvalidHash: If the block's id is not corresponding to its - data. - InvalidSignature: If the block's signature is not corresponding - to it's data or `node_pubkey`. + Raises: + InvalidHash: If the block's id is not corresponding to its + data. + InvalidSignature: If the block's signature is not corresponding + to it's data or `node_pubkey`. """ # TODO: Reuse `is_signature_valid` method here. block = block_body['block'] @@ -301,11 +301,11 @@ class Block(object): def to_dict(self): """Transforms the object to a Python dictionary. - Returns: - dict: The Block as an alternative serialization format. + Returns: + dict: The Block as an alternative serialization format. - Raises: - OperationError: If a Block doesn't contain any transactions. + Raises: + OperationError: If a Block doesn't contain any transactions. """ if len(self.transactions) == 0: raise OperationError('Empty block creation is not allowed') From 37cf057b99e14ae49bdb9410372d106801fa6a66 Mon Sep 17 00:00:00 2001 From: tim Date: Mon, 14 Nov 2016 13:56:05 +0100 Subject: [PATCH 08/10] PR Feedback for docs --- bigchaindb/models.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/bigchaindb/models.py b/bigchaindb/models.py index afda5ca9..a6a2ecdb 100644 --- a/bigchaindb/models.py +++ b/bigchaindb/models.py @@ -248,9 +248,6 @@ class Block(object): def from_dict(cls, block_body): """Transforms a Python dictionary to a Block object. - Note: - Throws errors if passed signature or id is incorrect. - Args: block_body (dict): A block dictionary to be transformed. @@ -299,13 +296,13 @@ class Block(object): return self.to_dict()['id'] def to_dict(self): - """Transforms the object to a Python dictionary. + """Transforms the Block to a Python dictionary. Returns: - dict: The Block as an alternative serialization format. + dict: The Block as a dict. Raises: - OperationError: If a Block doesn't contain any transactions. + OperationError: If the Block doesn't contain any transactions. """ if len(self.transactions) == 0: raise OperationError('Empty block creation is not allowed') From 6ef18fbbaecfc3d4e92b2f77baaab885bd3ff2ed Mon Sep 17 00:00:00 2001 From: Sylvain Bellemare Date: Fri, 11 Nov 2016 19:21:24 +0100 Subject: [PATCH 09/10] Simplify Transaction.to_inputs method --- bigchaindb/common/transaction.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/bigchaindb/common/transaction.py b/bigchaindb/common/transaction.py index c1857d23..9bcb5e1f 100644 --- a/bigchaindb/common/transaction.py +++ b/bigchaindb/common/transaction.py @@ -786,20 +786,14 @@ class Transaction(object): :obj:`list` of :class:`~bigchaindb.common.transaction. Fulfillment` """ - inputs = [] - if condition_indices is None or len(condition_indices) == 0: - # NOTE: If no condition indices are passed, we just assume to - # take all conditions as inputs. - condition_indices = [index for index, _ - in enumerate(self.conditions)] - - for cid in condition_indices: - input_cond = self.conditions[cid] - ffill = Fulfillment(input_cond.fulfillment, - input_cond.owners_after, - TransactionLink(self.id, cid)) - inputs.append(ffill) - return inputs + # NOTE: If no condition indices are passed, we just assume to + # take all conditions as inputs. + return [ + Fulfillment(self.conditions[cid].fulfillment, + self.conditions[cid].owners_after, + TransactionLink(self.id, cid)) + for cid in condition_indices or range(len(self.conditions)) + ] def add_fulfillment(self, fulfillment): """Adds a Fulfillment to a Transaction's list of Fulfillments. From 74e1f9c30330058ab5fd7fe25d5742fe4d66626e Mon Sep 17 00:00:00 2001 From: tim Date: Mon, 14 Nov 2016 14:59:09 +0100 Subject: [PATCH 10/10] Fix tense in docs --- bigchaindb/models.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/bigchaindb/models.py b/bigchaindb/models.py index a6a2ecdb..57d64272 100644 --- a/bigchaindb/models.py +++ b/bigchaindb/models.py @@ -118,7 +118,7 @@ class Transaction(Transaction): class Block(object): - """A Block bundles up to 1000 Transactions. Nodes vote on its validity. + """Bundle a list of Transactions in a Block. Nodes vote on its validity. Attributes: transaction (:obj:`list` of :class:`~.Transaction`): @@ -129,7 +129,7 @@ class Block(object): voters (:obj:`list` of :obj:`str`): A list of a federation nodes' public keys supposed to vote on the Block. signature (str): A cryptographic signature ensuring the - integrity and creatorship of a Block. + integrity and validity of the creator of a Block. """ def __init__(self, transactions=None, node_pubkey=None, timestamp=None, @@ -146,7 +146,7 @@ class Block(object): voters (:obj:`list` of :obj:`str`): A list of a federation nodes' public keys supposed to vote on the Block. signature (str): A cryptographic signature ensuring the - integrity and creatorship of a Block. + integrity and validity of the creator of a Block. """ if transactions is not None and not isinstance(transactions, list): raise TypeError('`transactions` must be a list instance or None') @@ -174,14 +174,14 @@ class Block(object): return self.to_dict() == other def validate(self, bigchain): - """Validates the Block. + """Validate the Block. Args: bigchain (:class:`~bigchaindb.Bigchain`): An instantiated Bigchain object. Returns: - :class:`~.Block`: If valid, returns a `Block` object. Else an + :class:`~.Block`: If valid, return a `Block` object. Else an appropriate exception describing the reason of invalidity is raised. @@ -212,7 +212,7 @@ class Block(object): return self def sign(self, signing_key): - """Creates a signature for the Block and overwrites `self.signature`. + """Create a signature for the Block and overwrite `self.signature`. Args: signing_key (str): A signing key corresponding to @@ -228,7 +228,7 @@ class Block(object): return self def is_signature_valid(self): - """Checks the validity of a Block's signature. + """Check the validity of a Block's signature. Returns: bool: Stating the validity of the Block's signature. @@ -246,7 +246,7 @@ class Block(object): @classmethod def from_dict(cls, block_body): - """Transforms a Python dictionary to a Block object. + """Transform a Python dictionary to a Block object. Args: block_body (dict): A block dictionary to be transformed. @@ -296,7 +296,7 @@ class Block(object): return self.to_dict()['id'] def to_dict(self): - """Transforms the Block to a Python dictionary. + """Transform the Block to a Python dictionary. Returns: dict: The Block as a dict.