mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-25 06:55:45 +00:00
fixed usage of from_db part 1
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
parent
6189100d52
commit
8ea911ba64
@ -1171,6 +1171,7 @@ class Transaction(object):
|
|||||||
"""
|
"""
|
||||||
# NOTE: Remove reference to avoid side effects
|
# NOTE: Remove reference to avoid side effects
|
||||||
# tx_body = deepcopy(tx_body)
|
# tx_body = deepcopy(tx_body)
|
||||||
|
print( f"\n tx body 1: {tx_body}")
|
||||||
tx_body = rapidjson.loads(rapidjson.dumps(tx_body))
|
tx_body = rapidjson.loads(rapidjson.dumps(tx_body))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -1185,7 +1186,7 @@ class Transaction(object):
|
|||||||
valid_tx_id = Transaction._to_hash(tx_body_serialized)
|
valid_tx_id = Transaction._to_hash(tx_body_serialized)
|
||||||
print( f"\n valid TX : {valid_tx_id}")
|
print( f"\n valid TX : {valid_tx_id}")
|
||||||
print( f"\n proposed TX id : {proposed_tx_id}")
|
print( f"\n proposed TX id : {proposed_tx_id}")
|
||||||
print( f"\n tx body : {tx_body}")
|
print( f"\n tx body 2: {tx_body}")
|
||||||
print( f"\n tx serialized : {tx_body_serialized}")
|
print( f"\n tx serialized : {tx_body_serialized}")
|
||||||
if proposed_tx_id != valid_tx_id:
|
if proposed_tx_id != valid_tx_id:
|
||||||
err_msg= ("The transaction's id '{}' isn't equal to "
|
err_msg= ("The transaction's id '{}' isn't equal to "
|
||||||
@ -1211,13 +1212,13 @@ class Transaction(object):
|
|||||||
id = tx['id']
|
id = tx['id']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
id = None
|
id = None
|
||||||
|
#tx['asset'] = tx['asset'][0] if isinstance( tx['asset'], list) or isinstance( tx['asset'], tuple) else tx['asset'],
|
||||||
local_dict= {
|
local_dict= {
|
||||||
'inputs': tx['inputs'],
|
'inputs': tx['inputs'],
|
||||||
'outputs': tx['outputs'],
|
'outputs': tx['outputs'],
|
||||||
'operation': operation,
|
'operation': operation,
|
||||||
'metadata': tx['metadata'],
|
'metadata': tx['metadata'],
|
||||||
'asset': tx['asset'],
|
'asset': tx['asset'],#[0] if isinstance( tx['asset'], list) or isinstance( tx['asset'], tuple) else tx['asset'],
|
||||||
'version': tx['version'],
|
'version': tx['version'],
|
||||||
'id': id
|
'id': id
|
||||||
}
|
}
|
||||||
@ -1270,8 +1271,10 @@ class Transaction(object):
|
|||||||
tx_ids = list(tx_map.keys())
|
tx_ids = list(tx_map.keys())
|
||||||
metadata_list = list(planet.get_metadata(tx_ids))
|
metadata_list = list(planet.get_metadata(tx_ids))
|
||||||
for metadata in metadata_list:
|
for metadata in metadata_list:
|
||||||
tx = tx_map[metadata['id']]
|
print (f"\n\nmetadata: { metadata}")
|
||||||
tx.update({'metadata': metadata.get('metadata')})
|
if 'id' in metadata:
|
||||||
|
tx = tx_map[metadata['id']]
|
||||||
|
tx.update({'metadata': metadata.get('metadata')})
|
||||||
|
|
||||||
if return_list:
|
if return_list:
|
||||||
tx_list = []
|
tx_list = []
|
||||||
|
|||||||
@ -300,6 +300,7 @@ class Planetmint(object):
|
|||||||
def get_spent(self, txid, output, current_transactions=[]):
|
def get_spent(self, txid, output, current_transactions=[]):
|
||||||
transactions = backend.query.get_spent(self.connection, txid,
|
transactions = backend.query.get_spent(self.connection, txid,
|
||||||
output)
|
output)
|
||||||
|
print(f"spent TX: {transactions}")
|
||||||
transactions = list(transactions) if transactions else []
|
transactions = list(transactions) if transactions else []
|
||||||
if len(transactions) > 1:
|
if len(transactions) > 1:
|
||||||
raise core_exceptions.CriticalDoubleSpend(
|
raise core_exceptions.CriticalDoubleSpend(
|
||||||
@ -318,7 +319,10 @@ class Planetmint(object):
|
|||||||
if len(transactions) + len(current_spent_transactions) > 1:
|
if len(transactions) + len(current_spent_transactions) > 1:
|
||||||
raise DoubleSpend('tx "{}" spends inputs twice'.format(txid))
|
raise DoubleSpend('tx "{}" spends inputs twice'.format(txid))
|
||||||
elif transactions:
|
elif transactions:
|
||||||
transaction = Transaction.from_db(self, transactions[0])
|
print( f"\n\nget tx from DB : {transactions[0]['id']} {transactions[0]}")
|
||||||
|
transaction=backend.query.get_transactions(self.connection, [transactions[0]['id']])
|
||||||
|
print( f"\n\nget tx from DB result: {transaction}")
|
||||||
|
#transaction = Transaction.from_db(self, transactions[0])
|
||||||
elif current_spent_transactions:
|
elif current_spent_transactions:
|
||||||
transaction = current_spent_transactions[0]
|
transaction = current_spent_transactions[0]
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user