mirror of
https://github.com/planetmint/planetmint.git
synced 2025-11-26 15:35:45 +00:00
hash error
This commit is contained in:
parent
e01a9b96cd
commit
5ce84c5a2f
@ -131,9 +131,9 @@ def store_assets(connection, assets: list):
|
|||||||
space = connection.space("assets")
|
space = connection.space("assets")
|
||||||
for asset in assets:
|
for asset in assets:
|
||||||
try:
|
try:
|
||||||
space.insert((asset["id"], asset["data"]))
|
space.insert((asset["id"], asset))
|
||||||
except: # TODO Raise ERROR for Duplicate
|
except: # TODO Raise ERROR for Duplicate
|
||||||
print("DUPLICATE ERROR (" + asset["id"] + ") " + str(asset["data"]))
|
pass
|
||||||
|
|
||||||
|
|
||||||
@register_query(TarantoolDB)
|
@register_query(TarantoolDB)
|
||||||
@ -151,7 +151,7 @@ def get_assets(connection, assets_ids: list) -> list:
|
|||||||
for _id in list(set(assets_ids)):
|
for _id in list(set(assets_ids)):
|
||||||
asset = space.select(str(_id), index="assetid_search")
|
asset = space.select(str(_id), index="assetid_search")
|
||||||
asset = asset.data[0]
|
asset = asset.data[0]
|
||||||
_returned_data.append({"id": str(asset[0]), "data": asset[1]})
|
_returned_data.append(asset[1])
|
||||||
return sorted(_returned_data, key=lambda k: k["id"], reverse=False)
|
return sorted(_returned_data, key=lambda k: k["id"], reverse=False)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -49,7 +49,7 @@ class TransactionDecompose:
|
|||||||
metadata = self._transaction.get("metadata")
|
metadata = self._transaction.get("metadata")
|
||||||
self._tuple_transaction["metadata"] = (self._transaction["id"], metadata) if metadata is not None else ()
|
self._tuple_transaction["metadata"] = (self._transaction["id"], metadata) if metadata is not None else ()
|
||||||
|
|
||||||
def __asset_check(self):
|
def __asset_check(self): # ASSET CAN BE VERIFIED BY OPERATION TYPE CREATE OR TRANSFER
|
||||||
_asset = self._transaction.get("asset")
|
_asset = self._transaction.get("asset")
|
||||||
if _asset is None:
|
if _asset is None:
|
||||||
self._tuple_transaction["asset"] = ""
|
self._tuple_transaction["asset"] = ""
|
||||||
@ -174,7 +174,7 @@ class TransactionCompose:
|
|||||||
_outputs = []
|
_outputs = []
|
||||||
for _output in self.db_results["outputs"]:
|
for _output in self.db_results["outputs"]:
|
||||||
_out = self._map["outputs"].copy()
|
_out = self._map["outputs"].copy()
|
||||||
_out["amount"] = _out[1]
|
_out["amount"] = _output[1]
|
||||||
_out["public_keys"] = [_key[3] for _key in self.db_results["keys"] if _key[2] == _output[5]]
|
_out["public_keys"] = [_key[3] for _key in self.db_results["keys"] if _key[2] == _output[5]]
|
||||||
_out["condition"]["uri"] = _output[2]
|
_out["condition"]["uri"] = _output[2]
|
||||||
if self.db_results["outputs"][0][7] is None:
|
if self.db_results["outputs"][0][7] is None:
|
||||||
@ -184,6 +184,7 @@ class TransactionCompose:
|
|||||||
_out["condition"]["details"]["subconditions"] = _output[7]
|
_out["condition"]["details"]["subconditions"] = _output[7]
|
||||||
_out["condition"]["type"] = _output[3]
|
_out["condition"]["type"] = _output[3]
|
||||||
_out["condition"]["treshold"] = _output[6]
|
_out["condition"]["treshold"] = _output[6]
|
||||||
|
_outputs.append(_out)
|
||||||
return _outputs
|
return _outputs
|
||||||
|
|
||||||
def convert_to_dict(self):
|
def convert_to_dict(self):
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import argparse
|
|||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
from planetmint.backend.tarantool.database import TarantoolDB, drop_tarantool, init_tarantool
|
from planetmint.backend.tarantool.connection import TarantoolDB
|
||||||
|
|
||||||
from planetmint.core import rollback
|
from planetmint.core import rollback
|
||||||
from planetmint.migrations.chain_migration_election import ChainMigrationElection
|
from planetmint.migrations.chain_migration_election import ChainMigrationElection
|
||||||
@ -245,11 +245,12 @@ def run_election_show(args, planet):
|
|||||||
|
|
||||||
|
|
||||||
def _run_init():
|
def _run_init():
|
||||||
|
pass
|
||||||
# bdb = planetmint.Planetmint()
|
# bdb = planetmint.Planetmint()
|
||||||
|
|
||||||
# schema.init_database(connection=bdb.connection)
|
# schema.init_database(connection=bdb.connection)
|
||||||
|
|
||||||
init_tarantool()
|
# init_tarantool()
|
||||||
|
|
||||||
|
|
||||||
@configure_planetmint
|
@configure_planetmint
|
||||||
@ -267,7 +268,7 @@ def run_drop(args):
|
|||||||
if response != 'y':
|
if response != 'y':
|
||||||
return
|
return
|
||||||
|
|
||||||
drop_tarantool()
|
# drop_tarantool()
|
||||||
|
|
||||||
|
|
||||||
def run_recover(b):
|
def run_recover(b):
|
||||||
|
|||||||
@ -1170,6 +1170,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("VERIF " + str(tx_body))
|
||||||
tx_body = rapidjson.loads(rapidjson.dumps(tx_body))
|
tx_body = rapidjson.loads(rapidjson.dumps(tx_body))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -1181,7 +1182,6 @@ class Transaction(object):
|
|||||||
|
|
||||||
tx_body_serialized = Transaction._to_str(tx_body)
|
tx_body_serialized = Transaction._to_str(tx_body)
|
||||||
valid_tx_id = Transaction._to_hash(tx_body_serialized)
|
valid_tx_id = Transaction._to_hash(tx_body_serialized)
|
||||||
print("VALIDTX " + 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 "
|
||||||
"the hash of its body, i.e. it's not valid.")
|
"the hash of its body, i.e. it's not valid.")
|
||||||
|
|||||||
@ -244,17 +244,17 @@ class Planetmint(object):
|
|||||||
transaction = backend.query.get_transaction(self.connection, transaction_id)
|
transaction = backend.query.get_transaction(self.connection, transaction_id)
|
||||||
|
|
||||||
if transaction:
|
if transaction:
|
||||||
asset = backend.query.get_asset(self.connection, transaction_id)
|
# asset = backend.query.get_asset(self.connection, transaction_id)
|
||||||
metadata = backend.query.get_metadata(self.connection, [transaction_id])
|
# metadata = backend.query.get_metadata(self.connection, [transaction_id])
|
||||||
if asset:
|
# if asset:
|
||||||
transaction['asset'] = asset
|
# transaction['asset'] = asset
|
||||||
|
#
|
||||||
if 'metadata' not in transaction:
|
# if 'metadata' not in transaction:
|
||||||
metadata = metadata[0] if metadata else None
|
# metadata = metadata[0] if metadata else None
|
||||||
if metadata:
|
# if metadata:
|
||||||
metadata = metadata.get('metadata')
|
# metadata = metadata.get('metadata')
|
||||||
|
#
|
||||||
transaction.update({'metadata': metadata})
|
# transaction.update({'metadata': metadata})
|
||||||
|
|
||||||
transaction = Transaction.from_dict(transaction)
|
transaction = Transaction.from_dict(transaction)
|
||||||
|
|
||||||
|
|||||||
@ -503,7 +503,7 @@ def test_cant_spend_same_input_twice_in_tx(b, alice):
|
|||||||
tx_create = Transaction.create([alice.public_key], [([alice.public_key], 100)])
|
tx_create = Transaction.create([alice.public_key], [([alice.public_key], 100)])
|
||||||
tx_create_signed = tx_create.sign([alice.private_key])
|
tx_create_signed = tx_create.sign([alice.private_key])
|
||||||
assert b.validate_transaction(tx_create_signed) == tx_create_signed
|
assert b.validate_transaction(tx_create_signed) == tx_create_signed
|
||||||
|
print("DCT " + str(tx_create_signed.to_dict()))
|
||||||
b.store_bulk_transactions([tx_create_signed])
|
b.store_bulk_transactions([tx_create_signed])
|
||||||
|
|
||||||
# Create a transfer transaction with duplicated fulfillments
|
# Create a transfer transaction with duplicated fulfillments
|
||||||
|
|||||||
@ -380,7 +380,7 @@ def test_get_spent_transaction_critical_double_spend(b, alice, bob, carol):
|
|||||||
[([bob.public_key], 1)],
|
[([bob.public_key], 1)],
|
||||||
asset_id=tx.id)\
|
asset_id=tx.id)\
|
||||||
.sign([alice.private_key])
|
.sign([alice.private_key])
|
||||||
print("PROPOSEDTX " + str(same_input_double_spend.to_dict()))
|
print("SPEND " + str(tx.to_dict()))
|
||||||
|
|
||||||
b.store_bulk_transactions([tx])
|
b.store_bulk_transactions([tx])
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user