Skip to content

Commit

Permalink
Fix data schema of assets.
Browse files Browse the repository at this point in the history
Signed-off-by: Cryptcoin Junkey <[email protected]>
  • Loading branch information
cryptcoin-junkey committed Jul 4, 2021
1 parent 3ac7860 commit 45623e5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions counterblock/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 11 additions & 1 deletion counterblock/lib/modules/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': '',
Expand All @@ -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'],
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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']),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 45623e5

Please sign in to comment.