mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 06:04:21 +01:00
Improves docstrings
This commit is contained in:
@@ -84,7 +84,7 @@ class AppointmentsDBM(DBManager):
|
||||
``RESPONDER_LAST_BLOCK_KEY``).
|
||||
|
||||
Returns:
|
||||
:obj:`str` or :obj:`None`: A 16-byte hex-encoded str representing the last known block hash.
|
||||
:obj:`str` or :obj:`None`: A 32-byte hex-encoded str representing the last known block hash.
|
||||
|
||||
Returns ``None`` if the entry is not found.
|
||||
"""
|
||||
@@ -177,7 +177,7 @@ class AppointmentsDBM(DBManager):
|
||||
|
||||
Args:
|
||||
uuid (:obj:`str`): the identifier of the appointment to be stored.
|
||||
appointment (:obj:`dict`): an appointment encoded as dictionary.
|
||||
appointment (:obj:`dict`): an appointment encoded as a dictionary.
|
||||
|
||||
Returns:
|
||||
:obj:`bool`: True if the appointment was stored in the db. False otherwise.
|
||||
@@ -202,7 +202,7 @@ class AppointmentsDBM(DBManager):
|
||||
|
||||
Args:
|
||||
uuid (:obj:`str`): the identifier of the appointment to be stored.
|
||||
tracker (:obj:`dict`): a tracker encoded as dictionary.
|
||||
tracker (:obj:`dict`): a tracker encoded as a dictionary.
|
||||
|
||||
Returns:
|
||||
:obj:`bool`: True if the tracker was stored in the db. False otherwise.
|
||||
@@ -247,7 +247,7 @@ class AppointmentsDBM(DBManager):
|
||||
|
||||
def create_append_locator_map(self, locator, uuid):
|
||||
"""
|
||||
Creates (or appends to if already exists) a ``locator:uuid`` map.
|
||||
Creates a ``locator:uuid`` map.
|
||||
|
||||
If the map already exists, the new ``uuid`` is appended to the existing ones (if it is not already there).
|
||||
|
||||
@@ -334,7 +334,7 @@ class AppointmentsDBM(DBManager):
|
||||
|
||||
def batch_delete_watcher_appointments(self, uuids):
|
||||
"""
|
||||
Deletes an appointment from the database.
|
||||
Deletes multiple appointments from the database.
|
||||
|
||||
Args:
|
||||
uuids (:obj:`list`): a list of 16-byte hex-encoded strings identifying the appointments to be deleted.
|
||||
@@ -367,7 +367,7 @@ class AppointmentsDBM(DBManager):
|
||||
|
||||
def batch_delete_responder_trackers(self, uuids):
|
||||
"""
|
||||
Deletes an appointment from the database.
|
||||
Deletes multiple trackers from the database.
|
||||
|
||||
Args:
|
||||
uuids (:obj:`list`): a list of 16-byte hex-encoded strings identifying the trackers to be deleted.
|
||||
|
||||
@@ -14,7 +14,7 @@ class BlockProcessor:
|
||||
|
||||
Args:
|
||||
btc_connect_params (:obj:`dict`): a dictionary with the parameters to connect to bitcoind
|
||||
(rpc user, rpc passwd, host and port)
|
||||
(rpc user, rpc password, host and port)
|
||||
"""
|
||||
|
||||
def __init__(self, btc_connect_params):
|
||||
@@ -22,10 +22,10 @@ class BlockProcessor:
|
||||
|
||||
def get_block(self, block_hash):
|
||||
"""
|
||||
Gives a block given a block hash by querying ``bitcoind``.
|
||||
Gets a block given a block hash by querying ``bitcoind``.
|
||||
|
||||
Args:
|
||||
block_hash (:obj:`str`): The block hash to be queried.
|
||||
block_hash (:obj:`str`): the block hash to be queried.
|
||||
|
||||
Returns:
|
||||
:obj:`dict` or :obj:`None`: A dictionary containing the requested block data if the block is found.
|
||||
@@ -44,7 +44,7 @@ class BlockProcessor:
|
||||
|
||||
def get_best_block_hash(self):
|
||||
"""
|
||||
Returns the hash of the current best chain tip.
|
||||
Gets the hash of the current best chain tip.
|
||||
|
||||
Returns:
|
||||
:obj:`str` or :obj:`None`: The hash of the block if it can be found.
|
||||
@@ -63,10 +63,10 @@ class BlockProcessor:
|
||||
|
||||
def get_block_count(self):
|
||||
"""
|
||||
Returns the block height of the best chain.
|
||||
Gets the block count of the best chain.
|
||||
|
||||
Returns:
|
||||
:obj:`int` or :obj:`None`: The block height if it can be computed.
|
||||
:obj:`int` or :obj:`None`: The count of the best chain if it can be computed.
|
||||
|
||||
Returns ``None`` otherwise (not even sure this can actually happen).
|
||||
"""
|
||||
@@ -86,7 +86,7 @@ class BlockProcessor:
|
||||
associated metadata given by ``bitcoind`` (e.g. confirmation count).
|
||||
|
||||
Args:
|
||||
raw_tx (:obj:`str`): The hex representation of the transaction.
|
||||
raw_tx (:obj:`str`): the hex representation of the transaction.
|
||||
|
||||
Returns:
|
||||
:obj:`dict` or :obj:`None`: The decoding of the given ``raw_tx`` if the transaction is well formatted.
|
||||
@@ -133,7 +133,7 @@ class BlockProcessor:
|
||||
|
||||
def get_missed_blocks(self, last_know_block_hash):
|
||||
"""
|
||||
Compute the blocks between the current best chain tip and a given block hash (``last_know_block_hash``).
|
||||
Gets the blocks between the current best chain tip and a given block hash (``last_know_block_hash``).
|
||||
|
||||
This method is used to fetch all the missed information when recovering from a crash.
|
||||
|
||||
@@ -158,7 +158,7 @@ class BlockProcessor:
|
||||
|
||||
def is_block_in_best_chain(self, block_hash):
|
||||
"""
|
||||
Checks whether or not a given block is on the best chain. Blocks are identified by block_hash.
|
||||
Checks whether a given block is on the best chain or not. Blocks are identified by block_hash.
|
||||
|
||||
A block that is not in the best chain will either not exists (block = None) or have a confirmation count of
|
||||
-1 (implying that the block was forked out or the chain never grew from that one).
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
class Builder:
|
||||
"""
|
||||
The :class:`Builder` class is in charge of reconstructing data loaded from the database and build the data
|
||||
structures of the :obj:`Watcher <teos.watcher.Watcher>` and the :obj:`Responder <teos.responder.Responder>`.
|
||||
The :class:`Builder` class is in charge of reconstructing data loaded from the appointments database and build the
|
||||
data structures of the :obj:`Watcher <teos.watcher.Watcher>` and the :obj:`Responder <teos.responder.Responder>`.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def build_appointments(appointments_data):
|
||||
"""
|
||||
Builds an appointments dictionary (``uuid: ExtendedAppointment``) and a locator_uuid_map (``locator: uuid``)
|
||||
Builds an appointments dictionary (``uuid:ExtendedAppointment``) and a locator_uuid_map (``locator:uuid``)
|
||||
given a dictionary of appointments from the database.
|
||||
|
||||
Args:
|
||||
@@ -43,7 +43,7 @@ class Builder:
|
||||
@staticmethod
|
||||
def build_trackers(tracker_data):
|
||||
"""
|
||||
Builds a tracker dictionary (``uuid: TransactionTracker``) and a tx_tracker_map (``penalty_txid: uuid``) given
|
||||
Builds a tracker dictionary (``uuid:TransactionTracker``) and a tx_tracker_map (``penalty_txid:uuid``) given
|
||||
a dictionary of trackers from the database.
|
||||
|
||||
Args:
|
||||
@@ -85,8 +85,8 @@ class Builder:
|
||||
:mod:`Responder <teos.responder.Responder>` using backed up data.
|
||||
|
||||
Args:
|
||||
block_queue (:obj:`Queue`): a ``Queue``
|
||||
missed_blocks (:obj:`list`): list of block hashes missed by the Watchtower (do to a crash or shutdown).
|
||||
block_queue (:obj:`Queue`): a ``Queue``.
|
||||
missed_blocks (:obj:`list`): list of block hashes missed by the Watchtower (due to a crash or shutdown).
|
||||
|
||||
Returns:
|
||||
:obj:`Queue`: A ``Queue`` containing all the missed blocks hashes.
|
||||
|
||||
@@ -20,14 +20,14 @@ class ChainMonitor:
|
||||
Args:
|
||||
watcher_queue (:obj:`Queue`): the queue to be used to send blocks hashes to the ``Watcher``.
|
||||
responder_queue (:obj:`Queue`): the queue to be used to send blocks hashes to the ``Responder``.
|
||||
block_processor (:obj:`BlockProcessor <teos.block_processor.BlockProcessor>`): a blockProcessor instance.
|
||||
block_processor (:obj:`BlockProcessor <teos.block_processor.BlockProcessor>`): a ``BlockProcessor`` instance.
|
||||
bitcoind_feed_params (:obj:`dict`): a dict with the feed (ZMQ) connection parameters.
|
||||
|
||||
Attributes:
|
||||
best_tip (:obj:`str`): a block hash representing the current best tip.
|
||||
last_tips (:obj:`list`): a list of last chain tips. Used as a sliding window to avoid notifying about old tips.
|
||||
terminate (:obj:`bool`): a flag to signal the termination of the :class:`ChainMonitor` (shutdown the tower).
|
||||
check_tip (:obj:`Event`): an event that's triggered at fixed time intervals and controls the polling thread.
|
||||
check_tip (:obj:`Event`): an event that is triggered at fixed time intervals and controls the polling thread.
|
||||
lock (:obj:`Condition`): a lock used to protect concurrent access to the queues and ``best_tip`` by the zmq and
|
||||
polling threads.
|
||||
zmqSubSocket (:obj:`socket`): a socket to connect to ``bitcoind`` via ``zmq``.
|
||||
|
||||
@@ -189,10 +189,10 @@ class Cleaner:
|
||||
Args:
|
||||
trackers (:obj:`dict`): a dictionary containing all the :obj:`Responder <teos.responder.Responder>`
|
||||
trackers.
|
||||
height (:obj:`int`): the block height at which the trackers were completed.
|
||||
tx_tracker_map (:obj:`dict`): a ``penalty_txid:uuid`` map for the :obj:`Responder
|
||||
<teos.responder.Responder>` trackers.
|
||||
completed_trackers (:obj:`dict`): a dict of completed trackers to be deleted (uuid:confirmations).
|
||||
height (:obj:`int`): the block height at which the trackers were completed.
|
||||
completed_trackers (:obj:`dict`): a dict of completed/expired trackers to be deleted (uuid:confirmations).
|
||||
db_manager (:obj:`AppointmentsDBM <teos.appointments_dbm.AppointmentsDBM>`): a ``AppointmentsDBM`` instance
|
||||
to interact with the database.
|
||||
expired (:obj:`bool`): whether the trackers have expired or not. Defaults to False.
|
||||
|
||||
@@ -47,7 +47,6 @@ class Inspector:
|
||||
Args:
|
||||
appointment_data (:obj:`dict`): a dictionary containing the appointment data.
|
||||
|
||||
|
||||
Returns:
|
||||
:obj:`Extended <teos.extended_appointment.ExtendedAppointment>`: An appointment initialized with
|
||||
the provided data.
|
||||
@@ -141,7 +140,6 @@ class Inspector:
|
||||
),
|
||||
)
|
||||
|
||||
# ToDo: #6-define-checks-encrypted-blob
|
||||
@staticmethod
|
||||
def check_blob(encrypted_blob):
|
||||
"""
|
||||
|
||||
@@ -8,7 +8,6 @@ Tools is a module with general methods that can used by different entities in th
|
||||
"""
|
||||
|
||||
|
||||
# NOTCOVERED
|
||||
def bitcoin_cli(btc_connect_params):
|
||||
"""
|
||||
An ``http`` connection with ``bitcoind`` using the ``json-rpc`` interface.
|
||||
|
||||
Reference in New Issue
Block a user