Skip to content

Commit

Permalink
Change timestamp to human-readable date & remove yield
Browse files Browse the repository at this point in the history
Payment history now shows date instead of UNIX timestamp next to the transaction ID & confirmation blockheight of all historic payments.

Additionally, the yield calculation has been completely removed now it's been replaced by the accurate productivity calculation.
  • Loading branch information
Bx64 committed Sep 6, 2022
1 parent 04b6fe6 commit 28c0f74
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 42 deletions.
40 changes: 2 additions & 38 deletions core/pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,41 +20,6 @@
app = Flask(__name__)


def get_round(height):
mod = divmod(height,network.delegates)
return (mod[0] + int(mod[1] > 0))


#def get_yield(netw_height, dblocks):
# drounds = dblocks['meta']['count'] #number of forged blocks
#
# missed = 0
# forged = 0
# netw_round = get_round(netw_height)
# last_forged_round = get_round(dblocks['data'][0]['height'])
#
# if netw_round > last_forged_round + 1:
# missed += netw_round - last_forged_round - 1
# else:
# forged += 1
#
# if drounds > 1:
# for i in range(0, drounds - 1):
# cur_round = get_round(dblocks['data'][i]['height'])
# prev_round = get_round(dblocks['data'][i + 1]['height'])
# if prev_round < cur_round - 1:
# if cur_round - prev_round - 1 > drounds - missed - forged:
# missed += drounds - missed - forged
# break
# else:
# missed += cur_round - prev_round - 1
# else:
# forged += 1
#
# yield_over_drounds = "{:.2f}".format(round((forged * 100)/(forged + missed)))
# return yield_over_drounds


@app.route('/')
def index():
stats = {}
Expand All @@ -64,7 +29,7 @@ def index():
stats['wallet'] = ddata['data']['address']
stats['rank'] = ddata['data']['rank']
stats['forged'] = ddata['data']['blocks']['produced']
stats['productivity'] = ddata['data']['blocks']['productivity'] # replacement for yield
stats['productivity'] = ddata['data']['blocks']['productivity']
stats['rewards'] = ddata['data']['forged']['total']
stats['votes'] = "{:,.2f}".format(int(ddata['data']['votesReceived']['votes'])/poolconfig.atomic)
stats['voters'] = int(ddata['data']['votesReceived']['voters'])
Expand All @@ -90,7 +55,6 @@ def index():
stats['synced'] = 'Syncing' if node_sync_data['data']['syncing'] else 'Synced'
stats['behind'] = node_sync_data['data']['blocks']
stats['height'] = node_sync_data['data']['height']
# stats['yield'] = get_yield(stats['height'], dblocks)

return render_template(poolconfig.pool_template + '_index.html', node=stats, pend=unpaid, tags=tags)

Expand All @@ -103,7 +67,7 @@ def payments():

tx_data = []
for i in xactions:
data_list = [i[3], i[4], i[7]]
data_list = [i[3], i[4], datetime.date.fromtimestamp(i[7])]
tx_data.append(data_list)

return render_template(poolconfig.pool_template + '_payments.html', tx_data=tx_data, tags=tags)
Expand Down
8 changes: 4 additions & 4 deletions core/templates/bfx_payments.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ <h1><center>Delegate <strong>{{tags['dname']}}</strong> Payment History</center>
<table class="table table-striped table-hover table-bordered" id="table">
<thead>
<tr class="header">
<th>Blockheight</th>
<th>Payment Date</th>
<th>Transaction ID</th>
<th>Processed at</th>
<th>Blockheight</th>
</thead>
<tbody>
{% for r in tx_data %}
<tr>
<td>{{ r[0] }}</td>
<td><a href="{{ tags['explorer'] }}/transactions/{{ r[1] }}" target="_blank">{{ r[1] }}</a></td>
<td>{{ r[2] }}</td>
<td><a href="{{ tags['explorer'] }}/transactions/{{ r[1] }}" target="_blank">{{ r[1] }}</a></td>
<td>{{ r[0] }}</td>
</tr>
{% endfor %}
</tbody>
Expand Down

0 comments on commit 28c0f74

Please sign in to comment.