From f287bdf073d6a8ee6a418135d628cdfe26cad69a Mon Sep 17 00:00:00 2001 From: Sergi Delgado Segura Date: Tue, 10 Dec 2019 12:00:40 +0100 Subject: [PATCH] Fixes returns --- pisa/api.py | 8 ++++---- pisa/appointment.py | 6 +++--- pisa/block_processor.py | 16 ++++++++-------- pisa/builder.py | 10 +++++----- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/pisa/api.py b/pisa/api.py index 89cdef9..5adb73c 100644 --- a/pisa/api.py +++ b/pisa/api.py @@ -26,7 +26,7 @@ def add_appointment(): encoded and contain an ``appointment`` field and optionally a ``signature`` and ``public_key`` fields. Returns: - tuple: A tuple containing the response (``json``) and response code (``int``). For accepted appointments, the + ``tuple``: A tuple containing the response (``json``) and response code (``int``). For accepted appointments, the ``rcode`` is always 0 and the response contains the signed receipt. For rejected appointments, the ``rcode`` is a negative value and the response contains the error message. Error messages can be found at :mod:`Errors `. @@ -90,7 +90,7 @@ def get_appointment(): The information is requested by ``locator``. Returns: - dict: A json formatted dictionary containing information about the requested appointment. + ``dict``: A json formatted dictionary containing information about the requested appointment. A ``status`` flag is added to the data provided by either the :mod:`Watcher ` or the :mod:`Responder ` that signals the status of the appointment. @@ -143,7 +143,7 @@ def get_all_appointments(): This endpoint should only be accessible by the administrator. Requests are only allowed from localhost. Returns: - dict: A json formatted dictionary containing all the appointments hold by the :mod:`Watcher ` + ``dict``: A json formatted dictionary containing all the appointments hold by the :mod:`Watcher ` (``watcher_appointments``) and by the :mod:`Responder ` (``responder_jobs``). """ @@ -172,7 +172,7 @@ def get_block_count(): testers about the current block so they can define a dummy appointment without having to run a bitcoin node. Returns: - dict: A json encoded dictionary containing the block height. + ``dict``: A json encoded dictionary containing the block height. """ diff --git a/pisa/appointment.py b/pisa/appointment.py index bf3510e..825eab3 100644 --- a/pisa/appointment.py +++ b/pisa/appointment.py @@ -39,7 +39,7 @@ class Appointment: ``{locator, start_time, end_time, dispute_delta, encrypted_blob}`` Returns: - Appointment: An appointment initialized using the provided data. + ``Appointment``: An appointment initialized using the provided data. Raises: ValueError: If one of the mandatory keys is missing in ``appointment_data``. @@ -64,7 +64,7 @@ class Appointment: Exports an appointment as a dictionary. Returns: - appointment (dict): A dictionary containing the appointment attributes. + ``dict``: A dictionary containing the appointment attributes. """ @@ -93,7 +93,7 @@ class Appointment: reorgs in the future. Returns: - appointment (str): A json-encoded str representing the appointment. + ``str``: A json-encoded str representing the appointment. """ appointment = self.to_dict() diff --git a/pisa/block_processor.py b/pisa/block_processor.py index 042bf32..2406442 100644 --- a/pisa/block_processor.py +++ b/pisa/block_processor.py @@ -20,7 +20,7 @@ class BlockProcessor: block_hash (str): The block hash to be queried. Returns: - block (dict): A dictionary containing the requested block data if the block is found. + ``dict`` or ``None``: A dictionary containing the requested block data if the block is found. Returns ``None`` otherwise. """ @@ -40,7 +40,7 @@ class BlockProcessor: Returns the hash of the current best chain tip. Returns: - block_hash (str): The hash of the block if it can be found. + ``str`` or ``None``: The hash of the block if it can be found. Returns ``None`` otherwise (not even sure this can actually happen). """ @@ -60,7 +60,7 @@ class BlockProcessor: Returns the block height of the best chain. Returns: - block_count (int): The block height if it can be computed. + ``int`` or ``None``: The block height if it can be computed. Returns ``None`` otherwise (not even sure this can actually happen). """ @@ -84,7 +84,7 @@ class BlockProcessor: raw_tx (str): The hex representation of the transaction. Returns: - tx (dict): The decoding of the given ``raw_tx`` if the transaction is well formaed. + ``dict`` or ``None``: The decoding of the given ``raw_tx`` if the transaction is well formatted. Returns ``None`` otherwise. """ @@ -111,8 +111,8 @@ class BlockProcessor: last_know_block_hash (hex): the hash of the last known block. Returns: - missed_blocks (list): A list of blocks between the last given block and the current best chain tip, starting - from the child of ``last_know_block_hash``. + ``list``: A list of blocks between the last given block and the current best chain tip, starting from the + child of ``last_know_block_hash``. """ current_block_hash = self.get_best_block_hash() @@ -134,8 +134,8 @@ class BlockProcessor: target_block_hash (str): the hash of the target block (the one to compute the distance form the tip). Returns: - distance (int): The distance between the target and the best chain tip is the target block can be found on - the blockchain. + ``int`` or ``None``: The distance between the target and the best chain tip is the target block can be found + on the blockchain. Returns ``None`` otherwise. """ diff --git a/pisa/builder.py b/pisa/builder.py index 5d39034..fb4b4cb 100644 --- a/pisa/builder.py +++ b/pisa/builder.py @@ -23,9 +23,9 @@ class Builder: ``{uuid: {locator: str, start_time: int, ...}, uuid: {locator:...}}`` Returns: - appointments, locator_uuid_map (tuple): A tuple with two dictionaries. ``appointments`` containing the - appointment information in :mod:`Appointment ` objects and ``locator_uuid_map`` - containing a map of appointment (``uuid:locator``). + ``tuple``: A tuple with two dictionaries. ``appointments`` containing the appointment information in + :mod:`Appointment ` objects and ``locator_uuid_map`` containing a map of appointment + (``uuid:locator``). """ appointments = {} @@ -56,7 +56,7 @@ class Builder: ``{uuid: {locator: str, dispute_txid: str, ...}, uuid: {locator:...}}`` Returns: - jobs, tx_job_map (tuple): A tuple with two dictionaries. ``jobs`` containing the jobs information in + ``tuple``: A tuple with two dictionaries. ``jobs`` containing the jobs information in :class:`Job ` objects and a ``tx_job_map`` containing the map of jobs (``penalty_txid: uuid``). @@ -87,7 +87,7 @@ class Builder: missed_blocks (list): list of block hashes missed by the Watchtower (do to a crash or shutdown). Returns: - block_queue (Queue): A `Queue` containing all the missed blocks hashes. + ``Queue``: A `Queue` containing all the missed blocks hashes. """ block_queue = Queue()