mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Fix indentation for model docs
This commit is contained in:
parent
f69ccc93df
commit
b42eec93c7
@ -120,7 +120,24 @@ class Transaction(Transaction):
|
|||||||
class Block(object):
|
class Block(object):
|
||||||
"""A Block bundles up to 1000 Transactions. Nodes vote on its validity.
|
"""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`):
|
transaction (:obj:`list` of :class:`~.Transaction`):
|
||||||
Transactions to be included in the Block.
|
Transactions to be included in the Block.
|
||||||
node_pubkey (str): The public key of the node creating the
|
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.
|
nodes' public keys supposed to vote on the Block.
|
||||||
signature (str): A cryptographic signature ensuring the
|
signature (str): A cryptographic signature ensuring the
|
||||||
integrity and creatorship of a Block.
|
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):
|
if transactions is not None and not isinstance(transactions, list):
|
||||||
raise TypeError('`transactions` must be a list instance or None')
|
raise TypeError('`transactions` must be a list instance or None')
|
||||||
@ -214,12 +214,12 @@ class Block(object):
|
|||||||
def sign(self, signing_key):
|
def sign(self, signing_key):
|
||||||
"""Creates a signature for the Block and overwrites `self.signature`.
|
"""Creates a signature for the Block and overwrites `self.signature`.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
signing_key (str): A signing key corresponding to
|
signing_key (str): A signing key corresponding to
|
||||||
`self.node_pubkey`.
|
`self.node_pubkey`.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
:class:`~.Block`
|
:class:`~.Block`
|
||||||
"""
|
"""
|
||||||
block_body = self.to_dict()
|
block_body = self.to_dict()
|
||||||
block_serialized = serialize(block_body['block'])
|
block_serialized = serialize(block_body['block'])
|
||||||
@ -230,8 +230,8 @@ class Block(object):
|
|||||||
def is_signature_valid(self):
|
def is_signature_valid(self):
|
||||||
"""Checks the validity of a Block's signature.
|
"""Checks the validity of a Block's signature.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
bool: Stating the validity of the Block's signature.
|
bool: Stating the validity of the Block's signature.
|
||||||
"""
|
"""
|
||||||
block = self.to_dict()['block']
|
block = self.to_dict()['block']
|
||||||
# cc only accepts bytestring messages
|
# cc only accepts bytestring messages
|
||||||
@ -248,20 +248,20 @@ class Block(object):
|
|||||||
def from_dict(cls, block_body):
|
def from_dict(cls, block_body):
|
||||||
"""Transforms a Python dictionary to a Block object.
|
"""Transforms a Python dictionary to a Block object.
|
||||||
|
|
||||||
Note:
|
Note:
|
||||||
Throws errors if passed signature or id is incorrect.
|
Throws errors if passed signature or id is incorrect.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
block_body (dict): A block dictionary to be transformed.
|
block_body (dict): A block dictionary to be transformed.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
:class:`~Block`
|
:class:`~Block`
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
InvalidHash: If the block's id is not corresponding to its
|
InvalidHash: If the block's id is not corresponding to its
|
||||||
data.
|
data.
|
||||||
InvalidSignature: If the block's signature is not corresponding
|
InvalidSignature: If the block's signature is not corresponding
|
||||||
to it's data or `node_pubkey`.
|
to it's data or `node_pubkey`.
|
||||||
"""
|
"""
|
||||||
# TODO: Reuse `is_signature_valid` method here.
|
# TODO: Reuse `is_signature_valid` method here.
|
||||||
block = block_body['block']
|
block = block_body['block']
|
||||||
@ -301,11 +301,11 @@ class Block(object):
|
|||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
"""Transforms the object to a Python dictionary.
|
"""Transforms the object to a Python dictionary.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict: The Block as an alternative serialization format.
|
dict: The Block as an alternative serialization format.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
OperationError: If a Block doesn't contain any transactions.
|
OperationError: If a Block doesn't contain any transactions.
|
||||||
"""
|
"""
|
||||||
if len(self.transactions) == 0:
|
if len(self.transactions) == 0:
|
||||||
raise OperationError('Empty block creation is not allowed')
|
raise OperationError('Empty block creation is not allowed')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user