Handle no coinbase in a tx (for oxen 10 batching)

This commit is contained in:
Jason Rhinelander 2021-07-14 22:43:52 -03:00
parent 28376a5a5c
commit 6484313fb4
3 changed files with 23 additions and 17 deletions

View File

@ -314,23 +314,27 @@ def main(refresh=None, page=0, per_page=None, first=None, last=None):
txids = []
for b in blocks:
b['txs'] = []
txids.append(b['miner_tx_hash'])
if 'miner_tx_hash' in b and b['miner_tx_hash']:
txids.append(b['miner_tx_hash'])
if 'tx_hashes' in b:
txids += b['tx_hashes']
txs = parse_txs(tx_req(lmq, oxend, txids, cache_key='mempool').get())
i = 0
for tx in txs:
# TXs should come back in the same order so we can just skip ahead one when the block
# height changes rather than needing to search for the block
if blocks[i]['height'] != tx['block_height']:
i += 1
while i < len(blocks) and blocks[i]['height'] != tx['block_height']:
print("Something getting wrong: missing txes?", file=sys.stderr)
if txids:
txs = parse_txs(tx_req(lmq, oxend, txids, cache_key='mempool').get())
i = 0
for tx in txs:
if 'vin' in tx['info'] and len(tx['info']['vin']) == 1 and 'gen' in tx['info']['vin'][0]:
tx['coinbase'] = True
# TXs should come back in the same order so we can just skip ahead one when the block
# height changes rather than needing to search for the block
if blocks[i]['height'] != tx['block_height']:
i += 1
if i >= len(blocks):
print("Something getting wrong: have leftover txes")
break
blocks[i]['txs'].append(tx)
while i < len(blocks) and blocks[i]['height'] != tx['block_height']:
print("Something getting wrong: missing txes?", file=sys.stderr)
i += 1
if i >= len(blocks):
print("Something getting wrong: have leftover txes")
break
blocks[i]['txs'].append(tx)
# Clean up the SN data a bit to make things easier for the templates
awaiting_sns, active_sns, inactive_sns = get_sns(sns, inforeq)

View File

@ -32,8 +32,10 @@
{%- elif 'sn_contributor' in tx.extra -%}
<span class="icon" title="Service Node contribution {{tx.extra.sn_pubkey}} / {{tx.extra.sn_contributor}}">
{%-if text%} contribution{%endif%}</span>
{%- elif tx.coinbase%}
<span class="icon" title="Block reward">🎁{%if text%} block reward{%endif%}</span>
{%- elif text -%}
{%if tx.coinbase%}block reward{%else%}transfer{%endif%}
transfer
{%- endif -%}
{%- elif standard -%}
{%if tx.coinbase%}block reward{%else%}transfer{%endif%}

View File

@ -171,7 +171,7 @@
<td title="{{b.timestamp | from_timestamp | format_datetime}}">{{b.timestamp | from_timestamp | ago}}</td>
<td>{{b.block_size | si}}</td>
<td>{{symbol.display(b.txs[0])}}</td>
<td><a href="/tx/{{b.miner_tx_hash}}">{{b.miner_tx_hash}}</a></td>
<td><a href="/tx/{{b.txs[0].tx_hash}}">{{b.txs[0].tx_hash}}</a></td>
<td>{{fee.display(b.txs[0])}}</td>
<td>{{b.reward | oxen(tag=False, fixed=True, decimals=2)}}</td>
<td>0/{{b.txs[0].info.vout | length}}</td>
@ -184,7 +184,7 @@
<td title="{{b.timestamp | from_timestamp | format_datetime}}">{{b.timestamp | from_timestamp | ago}}</td>
<td>{{b.block_size | si}}</td>
<td></td>
<td><a href="/tx/{{b.miner_tx_hash}}">{{b.miner_tx_hash}}</a></td>
<td></td>
<td></td>
<td>{{b.reward | oxen(tag=False, fixed=True, decimals=2)}}</td>
<td></td>