ckdb - add -g flag to enable payout generation - off by default - and payouts commands genon/genoff to enable/disable it
This commit is contained in:
parent
10a69a6db1
commit
ad52dc6771
24
src/ckdb.c
24
src/ckdb.c
@ -125,6 +125,7 @@ static char *status_chars = "|/-\\";
|
||||
|
||||
static char *restorefrom;
|
||||
|
||||
bool genpayout_auto;
|
||||
bool markersummary_auto;
|
||||
|
||||
int switch_state = SWITCH_STATE_ALL;
|
||||
@ -1432,6 +1433,13 @@ static bool setup_data()
|
||||
mutex_init(&wq_waitlock);
|
||||
cond_init(&wq_waitcond);
|
||||
|
||||
LOGWARNING("%sStartup payout generation state is %s",
|
||||
genpayout_auto ? "" : "WARNING: ",
|
||||
genpayout_auto ? "On" : "Off");
|
||||
LOGWARNING("%sStartup mark generation state is %s",
|
||||
markersummary_auto ? "" : "WARNING: ",
|
||||
markersummary_auto ? "On" : "Off");
|
||||
|
||||
alloc_storage();
|
||||
|
||||
setnow(&db_stt);
|
||||
@ -3054,7 +3062,12 @@ static void summarise_blocks()
|
||||
diffacc, diffinv, shareacc, shareinv, elapsed);
|
||||
|
||||
// Now the summarisation is confirmed, generate the payout data
|
||||
pplns_block(blocks);
|
||||
if (genpayout_auto)
|
||||
pplns_block(blocks);
|
||||
else {
|
||||
LOGWARNING("%s() Auto payout generation disabled",
|
||||
__func__);
|
||||
}
|
||||
} else {
|
||||
LOGERR("%s() block %d, failed to confirm stats",
|
||||
__func__, blocks->height);
|
||||
@ -5402,11 +5415,13 @@ static void check_restore_dir(char *name)
|
||||
static struct option long_options[] = {
|
||||
{ "config", required_argument, 0, 'c' },
|
||||
{ "dbname", required_argument, 0, 'd' },
|
||||
// generate = enable payout pplns auto generation
|
||||
{ "generate", no_argument, 0, 'g' },
|
||||
{ "help", no_argument, 0, 'h' },
|
||||
{ "killold", no_argument, 0, 'k' },
|
||||
{ "loglevel", required_argument, 0, 'l' },
|
||||
// markersummary = enable markersummary auto generation
|
||||
{ "markersummary", no_argument, 0, 'm' },
|
||||
// marker = enable mark/workmarker/markersummary auto generation
|
||||
{ "marker", no_argument, 0, 'm' },
|
||||
{ "name", required_argument, 0, 'n' },
|
||||
{ "dbpass", required_argument, 0, 'p' },
|
||||
{ "btc-pass", required_argument, 0, 'P' },
|
||||
@ -5462,6 +5477,9 @@ int main(int argc, char **argv)
|
||||
while (*kill)
|
||||
*(kill++) = ' ';
|
||||
break;
|
||||
case 'g':
|
||||
genpayout_auto = true;
|
||||
break;
|
||||
case 'h':
|
||||
for (j = 0; long_options[j].val; j++) {
|
||||
struct option *jopt = &long_options[j];
|
||||
|
||||
@ -55,7 +55,7 @@
|
||||
|
||||
#define DB_VLOCK "1"
|
||||
#define DB_VERSION "1.0.3"
|
||||
#define CKDB_VERSION DB_VERSION"-1.332"
|
||||
#define CKDB_VERSION DB_VERSION"-1.333"
|
||||
|
||||
#define WHERE_FFL " - from %s %s() line %d"
|
||||
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__
|
||||
@ -95,6 +95,7 @@ extern int switch_state;
|
||||
#define SWITCH_STATE_AUTHWORKERS 1
|
||||
#define SWITCH_STATE_ALL 666666
|
||||
|
||||
extern bool genpayout_auto;
|
||||
extern bool markersummary_auto;
|
||||
|
||||
#define BLANK " "
|
||||
|
||||
@ -4947,6 +4947,28 @@ static char *cmd_payouts(PGconn *conn, char *cmd, char *id, tv_t *now,
|
||||
else
|
||||
ok = process_pplns(height, blockhash, &addrdate);
|
||||
|
||||
} else if (strcasecmp(action, "genon") == 0) {
|
||||
/* Turn on auto payout generation
|
||||
* and report the before/after status
|
||||
* No parameters */
|
||||
bool old = genpayout_auto;
|
||||
genpayout_auto = true;
|
||||
snprintf(msg, sizeof(msg), "payout generation state was %s,"
|
||||
" now %s",
|
||||
old ? "On" : "Off",
|
||||
genpayout_auto ? "On" : "Off");
|
||||
ok = true;
|
||||
} else if (strcasecmp(action, "genoff") == 0) {
|
||||
/* Turn off auto payout generation
|
||||
* and report the before/after status
|
||||
* No parameters */
|
||||
bool old = genpayout_auto;
|
||||
genpayout_auto = false;
|
||||
snprintf(msg, sizeof(msg), "payout generation state was %s,"
|
||||
" now %s",
|
||||
old ? "On" : "Off",
|
||||
genpayout_auto ? "On" : "Off");
|
||||
ok = true;
|
||||
} else {
|
||||
snprintf(reply, siz, "unknown action '%s'", action);
|
||||
LOGERR("%s.%s", id, reply);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user