From d0c38d54d87e209deac4a70c14d2a174a82ddf8f Mon Sep 17 00:00:00 2001 From: diminator Date: Tue, 23 Aug 2016 14:00:28 +0200 Subject: [PATCH] separate call for get_status --- bigchaindb/core.py | 14 ++++++++++++++ bigchaindb/web/views/transactions.py | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/bigchaindb/core.py b/bigchaindb/core.py index 9fe89f3d..95287290 100644 --- a/bigchaindb/core.py +++ b/bigchaindb/core.py @@ -190,6 +190,20 @@ class Bigchain(object): else: return response + def get_status(self, txid): + """Retrieve the status of a transaction with `txid` from bigchain. + + Args: + txid (str): transaction id of the transaction to query + + Returns: + A string transaction status to payload ('valid', 'undecided', + or 'backlog'). If no transaction with that `txid` was found it + returns `None` + """ + _, status = self.get_transaction(txid, include_status=True) + return status + def search_block_election_on_index(self, value, index): """Retrieve block election information given a secondary index and value diff --git a/bigchaindb/web/views/transactions.py b/bigchaindb/web/views/transactions.py index 4ea17425..ca8d0e4d 100644 --- a/bigchaindb/web/views/transactions.py +++ b/bigchaindb/web/views/transactions.py @@ -100,9 +100,9 @@ def get_transaction_status(tx_id): pool = current_app.config['bigchain_pool'] with pool() as bigchain: - tx, status = bigchain.get_transaction(tx_id, include_status=True) + status = bigchain.get_status(tx_id, include_status=True) - if not tx: + if not status: return make_error(404) return flask.jsonify({'status': status})