diff --git a/src/ckdb.h b/src/ckdb.h index 2e2f1601..f6b9396c 100644 --- a/src/ckdb.h +++ b/src/ckdb.h @@ -55,7 +55,7 @@ #define DB_VLOCK "1" #define DB_VERSION "1.0.4" -#define CKDB_VERSION DB_VERSION"-1.610" +#define CKDB_VERSION DB_VERSION"-1.611" #define WHERE_FFL " - from %s %s() line %d" #define WHERE_FFL_HERE __FILE__, __func__, __LINE__ diff --git a/src/ckdb_cmd.c b/src/ckdb_cmd.c index bab3f32a..a23ad1d1 100644 --- a/src/ckdb_cmd.c +++ b/src/ckdb_cmd.c @@ -5796,7 +5796,7 @@ static char *cmd_marks(PGconn *conn, char *cmd, char *id, char description[TXT_BIG+1] = { '\0' }; char extra[TXT_BIG+1] = { '\0' }; char status[TXT_FLAG+1] = { MARK_READY, '\0' }; - bool ok; + bool ok = false, pps; LOGDEBUG("%s(): cmd '%s'", __func__, cmd); @@ -6237,6 +6237,39 @@ static char *cmd_marks(PGconn *conn, char *cmd, char *id, old ? "On" : "Off", markersummary_auto ? "On" : "Off"); ok = true; + } else if (strcasecmp(action, "pps") == 0) { + /* Recalculate a shift's rewards/rewarded + * Require markerid */ + i_markerid = require_name(trf_root, "markerid", 1, + (char *)intpatt, reply, siz); + if (!i_markerid) + return strdup(reply); + TXT_TO_BIGINT("markerid", transfer_data(i_markerid), markerid); + + K_RLOCK(workmarkers_free); + wm_item = find_workmarkerid(markerid, false, MARKER_PROCESSED); + K_RUNLOCK(workmarkers_free); + if (!wm_item) { + snprintf(reply, siz, "no markerid %"PRId64, markerid); + return strdup(reply); + } + DATA_WORKMARKERS(workmarkers, wm_item); + pps = shift_rewards(wm_item); + if (pps) { + snprintf(msg, sizeof(msg), + "shift '%s' markerid %"PRId64" rewards %d " + "rewarded %.3e pps %.3e", + workmarkers->description, + workmarkers->markerid, workmarkers->rewards, + workmarkers->rewarded, workmarkers->pps_value); + } else { + snprintf(msg, sizeof(msg), + "shift '%s' markerid %"PRId64" no rewards yet" + " pps %.3e", + workmarkers->description, + workmarkers->markerid, workmarkers->pps_value); + } + ok = true; } else { snprintf(reply, siz, "unknown action '%s'", action); LOGERR("%s.%s", id, reply);