forked from Ocean/datum_gateway
Address review comments
This commit is contained in:
parent
16c869857d
commit
15392e68e0
@ -141,13 +141,13 @@ void datum_api_var_STRATUM_HASHRATE_ESTIMATE(char *buffer, size_t buffer_size, c
|
||||
}
|
||||
void datum_api_var_DATUM_PROCESS_UPTIME(char *buffer, size_t buffer_size, const T_DATUM_API_DASH_VARS *vardata) {
|
||||
uint64_t uptime_seconds = get_process_uptime_seconds();
|
||||
uint16_t days = uptime_seconds / (24 * 3600);
|
||||
uint8_t hours = (uptime_seconds % (24 * 3600)) / 3600;
|
||||
uint8_t minutes = (uptime_seconds % 3600) / 60;
|
||||
uint8_t seconds = uptime_seconds % 60;
|
||||
uint64_t days = uptime_seconds / (24 * 3600);
|
||||
unsigned int hours = (uptime_seconds % (24 * 3600)) / 3600;
|
||||
unsigned int minutes = (uptime_seconds % 3600) / 60;
|
||||
unsigned int seconds = uptime_seconds % 60;
|
||||
|
||||
if (days > 0) {
|
||||
snprintf(buffer, buffer_size, "%u days, %u hours, %u minutes, %u seconds",
|
||||
snprintf(buffer, buffer_size, "%lu days, %u hours, %u minutes, %u seconds",
|
||||
days, hours, minutes, seconds);
|
||||
} else if (hours > 0) {
|
||||
snprintf(buffer, buffer_size, "%u hours, %u minutes, %u seconds",
|
||||
|
@ -85,7 +85,7 @@ uint64_t get_process_uptime_seconds() {
|
||||
|
||||
void datum_utils_init(void) {
|
||||
build_hex_lookup();
|
||||
process_start_time = current_time_seconds();
|
||||
process_start_time = monotonic_time_seconds();
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
@ -127,9 +127,9 @@ unsigned char floorPoT(uint64_t x) {
|
||||
}
|
||||
#endif
|
||||
|
||||
uint64_t current_time_seconds(void) {
|
||||
uint64_t monotonic_time_seconds(void) {
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts); // SAFE from timezone changes
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts); // SAFE from system time changes (e.g., NTP adjustments, manual clock changes)
|
||||
return (uint64_t)ts.tv_sec;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include "datum_logger.h"
|
||||
|
||||
void datum_utils_init(void);
|
||||
uint64_t current_time_seconds(void);
|
||||
uint64_t monotonic_time_seconds(void);
|
||||
uint64_t current_time_millis(void);
|
||||
uint64_t current_time_micros(void);
|
||||
uint64_t get_process_uptime_seconds(void);
|
||||
|
@ -78,6 +78,10 @@
|
||||
<td class="label">Pool Pubkey:</td>
|
||||
<td class="fixed-width">${DATUM_POOL_PUBKEY}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Process uptime:</td>
|
||||
<td>${DATUM_PROCESS_UPTIME}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@ -100,10 +104,6 @@
|
||||
<td class="label">Estimated Hashrate:</td>
|
||||
<td>${STRATUM_HASHRATE_ESTIMATE}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Process uptime:</td>
|
||||
<td>${DATUM_PROCESS_UPTIME}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user