From 45623e5fdc0094e56fde3f6d8a83e632e0bf3bf7 Mon Sep 17 00:00:00 2001 From: cryptcoin-junkey Date: Sun, 27 Jun 2021 07:45:48 +0000 Subject: [PATCH] Fix data schema of assets. Signed-off-by: Cryptcoin Junkey --- counterblock/lib/config.py | 4 ++-- counterblock/lib/modules/assets.py | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/counterblock/lib/config.py b/counterblock/lib/config.py index deec15f..de087c2 100644 --- a/counterblock/lib/config.py +++ b/counterblock/lib/config.py @@ -3,9 +3,9 @@ ## # CONSTANTS ## -VERSION = "1.4.0+mona011" # should keep up with counterblockd repo's release tag +VERSION = "1.4.1+mona001" # should keep up with counterblockd repo's release tag -DB_VERSION = 25 # a db version increment will cause counterblockd to rebuild its database off of counterpartyd +DB_VERSION = 27 # a db version increment will cause counterblockd to rebuild its database off of counterpartyd UNIT = 100000000 diff --git a/counterblock/lib/modules/assets.py b/counterblock/lib/modules/assets.py index 2932737..a588812 100644 --- a/counterblock/lib/modules/assets.py +++ b/counterblock/lib/modules/assets.py @@ -271,11 +271,13 @@ def get_assets_info(assetsList): assets_info.append({ 'asset': asset, 'asset_longname': None, + 'assetgroup': None, 'owner': None, 'divisible': True, 'listed': (asset == config.XCP), 'reassignable': True, 'vendable': (asset == config.XCP), + 'fungible': True, 'locked': False, 'supply': supply, 'description': '', @@ -290,11 +292,13 @@ def get_assets_info(assetsList): assets_info.append({ 'asset': tracked_asset['asset'], 'asset_longname': tracked_asset['asset_longname'], + 'assetgroup': tracked_asset['assetgroup'], 'owner': tracked_asset['owner'], 'divisible': tracked_asset['divisible'], 'listed': tracked_asset['listed'], 'reassignable': tracked_asset['reassignable'], 'vendable': tracked_asset['vendable'], + 'fungible': tracked_asset['fungible'], 'locked': tracked_asset['locked'], 'supply': tracked_asset['total_issued'], 'description': tracked_asset['description'], @@ -403,6 +407,7 @@ def get_asset_history(asset, reverse=False): 'listed': raw[i]['listed'], 'reassignable': raw[i]['reassignable'], 'vendable': raw[i]['vendable'], + 'fungible': raw[i]['fungible'], 'locked': raw[i]['locked'], 'total_issued': raw[i]['total_issued'], 'total_issued_normalized': raw[i]['total_issued_normalized'], @@ -581,13 +586,15 @@ def modify_extended_asset_info(asset, description): # asset, the last one with _at_block == that block id in the history array is the # final version for that asset at that block 'asset': msg_data['asset'], - 'asset_longname': msg_data.get('asset_longname', None), # for subassets, this is the full subasset name of the asset, e.g. PIZZA.DOMINOSBLA + 'asset_longname': msg_data.get('asset_longname', None) if msg_data['fungible'] else None, # for subassets, this is the full subasset name of the asset, e.g. PIZZA.DOMINOSBLA + 'assetgroup': msg_data.get('asset_longname', None) if not msg_data['fungible'] else None, 'owner': msg_data['issuer'], 'description': msg_data['description'], 'divisible': msg_data['divisible'], 'listed': msg_data['listed'], 'reassignable': msg_data['reassignable'], 'vendable': msg_data['vendable'], + 'fungible': msg_data['fungible'], 'locked': not msg_data['fungible'], 'total_issued': int(msg_data['quantity']), 'total_issued_normalized': blockchain.normalize_quantity(msg_data['quantity'], msg_data['divisible']), @@ -655,6 +662,7 @@ def parse_balance_change(msg, msg_data): 'address': address, 'asset': asset_info['asset'], 'asset_longname': asset_info['asset_longname'], + 'assetgroup': asset_info['assetgroup'], 'block_index': config.state['cur_block']['block_index'], 'block_time': config.state['cur_block']['block_time_obj'], 'quantity': quantity, @@ -722,11 +730,13 @@ def process_rollback(max_block_index): base_asset = { 'asset': asset, 'asset_longname': None, + 'assetgroup': None, 'owner': None, 'divisible': True, 'listed': (asset == config.XCP), 'reassignable': True, 'vendable': (asset == config.XCP), + 'fungible': True, 'locked': False, 'total_issued': None, '_at_block': config.BLOCK_FIRST, # the block ID this asset is current for