mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Problem: validation runs redundant queries (#2409)
Solution: when a transaction is stored, the system splits it in three components, data, metadata, and the other fields of the transaction. When the system retrieves a transaction, it needs to make three different queries to reconstruct the original transaction. If a transaction does not exist, the system does three queries anyway, even if just one query is enough. This patch fixes this by doing the additional queries if and only if the transaction exists.
This commit is contained in:
parent
d5dda74643
commit
d0a24ef584
@ -254,10 +254,10 @@ class BigchainDB(object):
|
||||
|
||||
def get_transaction(self, transaction_id, include_status=False):
|
||||
transaction = backend.query.get_transaction(self.connection, transaction_id)
|
||||
asset = backend.query.get_asset(self.connection, transaction_id)
|
||||
metadata = backend.query.get_metadata(self.connection, [transaction_id])
|
||||
|
||||
if transaction:
|
||||
asset = backend.query.get_asset(self.connection, transaction_id)
|
||||
metadata = backend.query.get_metadata(self.connection, [transaction_id])
|
||||
if asset:
|
||||
transaction['asset'] = asset
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user