mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Switch to get_tx_by_payload_uuid
This commit is contained in:
parent
09e840faff
commit
b0350c521b
@ -217,18 +217,18 @@ class Bigchain(object):
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_tx_by_payload_hash(self, payload_hash):
|
||||
def get_tx_by_payload_uuid(self, payload_uuid):
|
||||
"""Retrieves transactions related to a digital asset.
|
||||
|
||||
When creating a transaction one of the optional arguments is the `payload`. The payload is a generic
|
||||
dict that contains information about the digital asset.
|
||||
|
||||
To make it easy to query the bigchain for that digital asset we create a sha3-256 hash of the
|
||||
serialized payload and store it with the transaction. This makes it easy for developers to keep track
|
||||
of their digital assets in bigchain.
|
||||
To make it easy to query the bigchain for that digital asset we create a UUID for the payload and
|
||||
store it with the transaction. This makes it easy for developers to keep track of their digital
|
||||
assets in bigchain.
|
||||
|
||||
Args:
|
||||
payload_hash (str): sha3-256 hash of the serialized payload.
|
||||
payload_uuid (str): the UUID for this particular payload.
|
||||
|
||||
Returns:
|
||||
A list of transactions containing that payload. If no transaction exists with that payload it
|
||||
@ -236,7 +236,7 @@ class Bigchain(object):
|
||||
"""
|
||||
|
||||
cursor = r.table('bigchain') \
|
||||
.get_all(payload_hash, index='payload_hash') \
|
||||
.get_all(payload_uuid, index='payload_uuid') \
|
||||
.run(self.conn)
|
||||
|
||||
transactions = list(cursor)
|
||||
|
@ -56,10 +56,6 @@ def init():
|
||||
r.db(dbname).table('bigchain')\
|
||||
.index_create('payload_uuid', r.row['block']['transactions']['transaction']['data']['uuid'], multi=True)\
|
||||
.run(conn)
|
||||
# secondary index for payload hash
|
||||
r.db(dbname).table('bigchain')\
|
||||
.index_create('payload_hash', r.row['block']['transactions']['transaction']['data']['hash'], multi=True)\
|
||||
.run(conn)
|
||||
|
||||
# wait for rethinkdb to finish creating secondary indexes
|
||||
r.db(dbname).table('backlog').index_wait().run(conn)
|
||||
|
Loading…
x
Reference in New Issue
Block a user