show time of last fetched template in the web ui

This commit is contained in:
Jethro Grassie 2019-05-12 12:50:40 -04:00
parent 0de8aaffcd
commit 2d0e62929a
No known key found for this signature in database
GPG key ID: DE8ED755616565BB
4 changed files with 26 additions and 9 deletions

View file

@ -1342,7 +1342,7 @@ rpc_on_block_template(const char* data, rpc_callback_t *callback)
json_object_put(root);
return;
}
pool_stats.last_template_fetched = time(NULL);
block_template_t *front = (block_template_t*) bstack_push(bst, NULL);
response_to_block_template(result, front);
pool_clients_send_job();

View file

@ -35,6 +35,7 @@
<tr><td>Network height: </td><td id="network_height"></td></tr>
<tr><td>Blocks found: </td><td id="pool_blocks_found"></td></tr>
<tr><td>Last block found: </td><td id="last_block_found"></td></tr>
<tr><td>Last template: </td><td id="last_template_fetched"></td></tr>
<tr><td>Payment threshold: </td><td id="payment_threshold"></td></tr>
<tr><td>Pool fee: </td><td id="pool_fee"></td></tr>
<tr><td>Pool port: </td><td id="pool_port"></td></tr>
@ -53,20 +54,33 @@
</table>
<small><a href="https://github.com/jtgrassie/monero-pool">https://github.com/jtgrassie/monero-pool</a></small>
<script>
function format_last_block(last)
function format_last_time(last)
{
var now = new Date().getTime() / 1000;
var diff = now - last;
var v;
if (last == 0)
return "None yet";
else if (diff < 60)
return parseInt(diff) + " seconds ago";
{
v = parseInt(diff);
return v + " second" + (v != 1 ? "s" : "") + " ago";
}
else if (diff < 3600)
return parseInt(diff/60) + " minutes ago";
{
v = parseInt(diff/60);
return v + " minute" + (v != 1 ? "s" : "") + " ago";
}
else if (diff < 86400)
return parseInt(diff/3600) + " hours ago";
{
v = parseInt(diff/3600);
return v + " hour" + (v != 1 ? "s" : "") + " ago";
}
else
return parseInt(diff/86400) + " days ago";
{
v = parseInt(diff/86400);
return v + " day" + (v != 1 ? "s" : "") + " ago";
}
}
function format_hashrate(hr)
@ -93,8 +107,8 @@
var el = document.querySelector("#"+e);
if (!el)
continue;
if (e == "last_block_found")
el.innerHTML = format_last_block(stats[e]);
if (e == "last_block_found" || e == "last_template_fetched")
el.innerHTML = format_last_time(stats[e]);
else if (/hashrate/.test(e))
el.innerHTML = format_hashrate(stats[e]);
else

View file

@ -73,6 +73,7 @@ send_json_stats (void *cls, struct MHD_Connection *connection)
uint64_t ph = context->pool_stats->pool_hashrate;
uint64_t nh = context->pool_stats->network_hashrate;
uint64_t height = context->pool_stats->network_height;
uint64_t ltf = context->pool_stats->last_template_fetched;
uint64_t lbf = context->pool_stats->last_block_found;
uint32_t pbf = context->pool_stats->pool_blocks_found;
uint64_t mh = 0;
@ -89,6 +90,7 @@ send_json_stats (void *cls, struct MHD_Connection *connection)
"\"pool_hashrate\":%"PRIu64","
"\"network_hashrate\":%"PRIu64","
"\"network_height\":%"PRIu64","
"\"last_template_fetched\":%"PRIu64","
"\"last_block_found\":%"PRIu64","
"\"pool_blocks_found\":%d,"
"\"payment_threshold\":%.2f,"
@ -97,7 +99,7 @@ send_json_stats (void *cls, struct MHD_Connection *connection)
"\"connected_miners\":%d,"
"\"miner_hashrate\":%"PRIu64","
"\"miner_balance\":%.8f"
"}", ph, nh, height, lbf, pbf,
"}", ph, nh, height, ltf, lbf, pbf,
context->payment_threshold, context->pool_fee,
context->pool_port, context->pool_stats->connected_miners,
mh, mb);

View file

@ -44,6 +44,7 @@ typedef struct pool_stats_t
uint64_t pool_hashrate;
uint32_t pool_blocks_found;
time_t last_block_found;
time_t last_template_fetched;
} pool_stats_t;
typedef struct wui_context_t