Skip to content
Snippets Groups Projects
Commit 96c1b4ee authored by alexey.stratulat's avatar alexey.stratulat
Browse files

[*] The receipt of information about the transaction has been redone, now if...

[*] The receipt of information about the transaction has been redone, now if it is necessary to receive only the ticker token for the transaction, and it will be received from the ledger, then the receipt of all transaction items does not occur.
parent 4dc0d11e
No related branches found
No related tags found
1 merge request!22[*] The receipt of information about the transaction has been redone, now if...
......@@ -101,48 +101,87 @@ def list_tx(net, count, reverse, page=1, ):
def info(datum_tx, chain_net, isIn = False, isOut = False, isToken = False, isSign = False, isOutCond = False,):
logIt.debug("Start geading info about tx: " + str(datum_tx.hash), "explorer")
ledger = chain_net.getLedger()
items = datum_tx.getItems()
#ITEMS
tx_in = []
tx_out = []
tx_sig = None
tx_token = None
tx_out_cond = None
for item in items:
if str(type(item)) == "<class 'CellFrame.ChainTxIn'>":
tx_in.append({'prevHash': filter(str(item.prevHash), '\u0000'), 'prevIdx': item.prevIdx})
elif str(type(item)) == "<class 'CellFrame.ChainTxOut'>":
tx_out.append({'addr': str(item.addr), 'value': item.value.coins})
elif str(type(item)) == "<class 'CellFrame.ChainTxSig'>":
sign = item.sign
sig_size = item.sigSize
# pkey = sign.pkey
tx_sig = {
'size': sig_size,
'sign': {
'type': str(sign.type),
'size': sign.size,
'pkeyHash': filter(str(sign.pkeyHash), '\u0000')
}
}
elif str(type(item)) == "<class 'CellFrame.ChainTxToken'>":
tx_token = {
'ticker': item.ticker,
'emissionHash': filter(str(item.tokenEmissionHash), '\u0000'),
'emissionChainId': str(item.tokenEmissionChainId)
}
elif str(type(item)) == "<class 'CellFrame.ChainTxOutCond'>":
tx_out_cond = {
'expires': p_dateTimeToDict(item.tsExpires),
'value': item.value.coins,
'type': str(item.typeSubtype)
}
if tx_token == None:
ticker = ledger.txGetTokenTickerByHash(datum_tx.hash)
logIt.debug("Get Ledger ... [ok]", "explorer")
if (isToken is True and
isIn is False and
isOut is False and
isSign is False and
isOutCond is False):
ticker = ledger.txGetTokenTickerByHash(datum_tx.hash)
if ticker is not None:
tx_token = {
'ticker': ticker
}
else:
items = datum_tx.getItems()
for item in items:
if str(type(item)) == "<class 'CellFrame.ChainTxToken'>":
tx_token = {
'ticker': item.ticker
}
transaction = {
'hash': filter(str(datum_tx.hash), '\u0000'),
'dateTime': p_dateTimeToDict(datum_tx.dateCreated)
}
transaction["token"] = tx_token
return transaction
else:
items = datum_tx.getItems()
logIt.debug("Get Items ... [ok]", "explorer")
#ITEMS
tx_in = []
tx_out = []
tx_sig = None
tx_token = None
tx_out_cond = None
tx_out_cond_srvStakeLock = None
for item in items:
logIt.debug("Type str: "+str(type(item)), "explorer")
if str(type(item)) == "<class 'CellFrame.ChainTxIn'>":
tx_in.append({'prevHash': filter(str(item.prevHash), '\u0000'), 'prevIdx': item.prevIdx})
logIt.debug("Added item [tx_in]", "explorer")
elif str(type(item)) == "<class 'CellFrame.ChainTxOut'>":
tx_out.append({'addr': str(item.addr), 'value': item.value.coins})
logIt.debug("Added item [tx_out]", "explorer")
elif str(type(item)) == "<class 'CellFrame.ChainTxSig'>":
sign = item.sign
sig_size = item.sigSize
# pkey = sign.pkey
tx_sig = {
'size': sig_size,
'sign': {
'type': str(sign.type),
'size': sign.size,
'pkeyHash': filter(str(sign.pkeyHash), '\u0000')
}
}
logIt.debug("Added item [tx_sig]", "explorer")
elif str(type(item)) == "<class 'CellFrame.ChainTxToken'>":
tx_token = {
'ticker': item.ticker,
'emissionHash': filter(str(item.tokenEmissionHash), '\u0000'),
'emissionChainId': str(item.tokenEmissionChainId)
}
logIt.debug("Added item [tx_token]", "explorer")
elif str(type(item)) == "<class 'CellFrame.ChainTxOutCond'>":
tx_out_cond = {
'expires': p_dateTimeToDict(item.tsExpires),
'value': item.value.coins,
'type': str(item.typeSubtype)
}
logIt.debug("Added item [tx_out_cond]", "explorer")
elif str(type(item)) == "<class 'CellFrame.ChainTxOutCondSubTypeSrvStakeLock'>":
tx_out_cond_srvStakeLock = {
'unlock': p_dateTimeToDict(item.timeUnlock)
}
if tx_token == None:
ticker = ledger.txGetTokenTickerByHash(datum_tx.hash)
tx_token = {
'ticker': ticker
}
logIt.debug("Added token from ledger", "explorer")
transaction = {
'hash': filter(str(datum_tx.hash), '\u0000'),
'dateTime': p_dateTimeToDict(datum_tx.dateCreated)
......@@ -157,6 +196,9 @@ def info(datum_tx, chain_net, isIn = False, isOut = False, isToken = False, isSi
transaction['sig'] = tx_sig
if isToken is True:
transaction["token"] = tx_token
if tx_out_cond_srvStakeLock is not None:
transaction["out_cond_srv_stake_lock"] = tx_out_cond_srvStakeLock
logIt.debug("Info about tx with hash: "+str(datum_tx.hash)+" [OK]", "explorer")
return transaction
......@@ -194,7 +236,6 @@ def get_verifications(net, hash):
ptr = chain.atomIterGetFirst(iter)
while ptr[0] is not None or ptr[1] != 0:
bck = Block.fromAtom(ptr[0], ptr[1])
# logIt.notice(str(type(bck)))
datums = bck.datums
if datums is not None:
for datum in datums:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment