|
|
@ -1080,6 +1080,7 @@ typedef struct poolstats { |
|
|
|
double hashrate5m; |
|
|
|
double hashrate5m; |
|
|
|
double hashrate1hr; |
|
|
|
double hashrate1hr; |
|
|
|
double hashrate24hr; |
|
|
|
double hashrate24hr; |
|
|
|
|
|
|
|
bool stored; // Non-db field
|
|
|
|
SIMPLEDATECONTROLFIELDS; |
|
|
|
SIMPLEDATECONTROLFIELDS; |
|
|
|
} POOLSTATS; |
|
|
|
} POOLSTATS; |
|
|
|
|
|
|
|
|
|
|
@ -4577,6 +4578,8 @@ static bool poolstats_add(PGconn *conn, bool store, char *poolinstance, |
|
|
|
|
|
|
|
|
|
|
|
row = DATA_POOLSTATS(p_item); |
|
|
|
row = DATA_POOLSTATS(p_item); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
row->stored = false; |
|
|
|
|
|
|
|
|
|
|
|
STRNCPY(row->poolinstance, poolinstance); |
|
|
|
STRNCPY(row->poolinstance, poolinstance); |
|
|
|
TXT_TO_BIGINT("elapsed", elapsed, row->elapsed); |
|
|
|
TXT_TO_BIGINT("elapsed", elapsed, row->elapsed); |
|
|
|
TXT_TO_INT("users", users, row->users); |
|
|
|
TXT_TO_INT("users", users, row->users); |
|
|
@ -4620,6 +4623,8 @@ static bool poolstats_add(PGconn *conn, bool store, char *poolinstance, |
|
|
|
PGLOGERR("Insert", rescode, conn); |
|
|
|
PGLOGERR("Insert", rescode, conn); |
|
|
|
goto unparam; |
|
|
|
goto unparam; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
row->stored = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ok = true; |
|
|
|
ok = true; |
|
|
@ -4686,6 +4691,8 @@ static bool poolstats_fill(PGconn *conn) |
|
|
|
item = k_unlink_head(poolstats_free); |
|
|
|
item = k_unlink_head(poolstats_free); |
|
|
|
row = DATA_POOLSTATS(item); |
|
|
|
row = DATA_POOLSTATS(item); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
row->stored = true; |
|
|
|
|
|
|
|
|
|
|
|
PQ_GET_FLD(res, i, "poolinstance", field, ok); |
|
|
|
PQ_GET_FLD(res, i, "poolinstance", field, ok); |
|
|
|
if (!ok) |
|
|
|
if (!ok) |
|
|
|
break; |
|
|
|
break; |
|
|
@ -5746,7 +5753,16 @@ static char *cmd_poolstats_do(char *cmd, char *id, char *by, char *code, |
|
|
|
if (!ps) |
|
|
|
if (!ps) |
|
|
|
store = true; |
|
|
|
store = true; |
|
|
|
else { |
|
|
|
else { |
|
|
|
if (tvdiff(cd, &(DATA_POOLSTATS(ps)->createdate)) > STATS_PER) |
|
|
|
// Find last stored matching the poolinstance and less than STATS_PER old
|
|
|
|
|
|
|
|
while (ps && !DATA_POOLSTATS(ps)->stored && |
|
|
|
|
|
|
|
strcmp(row.poolinstance, DATA_POOLSTATS(ps)->poolinstance) == 0 && |
|
|
|
|
|
|
|
tvdiff(cd, &(DATA_POOLSTATS(ps)->createdate)) < STATS_PER) { |
|
|
|
|
|
|
|
ps = next_in_ktree(ctx); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!ps || !DATA_POOLSTATS(ps)->stored || |
|
|
|
|
|
|
|
strcmp(row.poolinstance, DATA_POOLSTATS(ps)->poolinstance) != 0 || |
|
|
|
|
|
|
|
tvdiff(cd, &(DATA_POOLSTATS(ps)->createdate)) >= STATS_PER) |
|
|
|
store = true; |
|
|
|
store = true; |
|
|
|
else |
|
|
|
else |
|
|
|
store = false; |
|
|
|
store = false; |
|
|
|