Browse Source

ckdb/php - set default diff to 0 meaning unset

master
kanoi 10 years ago
parent
commit
0d13eb4501
  1. 4
      pool/page_workmgt.php
  2. 10
      src/ckdb.h
  3. 2
      src/ckdb_cmd.c
  4. 19
      src/ckdb_dbio.c

4
pool/page_workmgt.php

@ -45,6 +45,10 @@ function workmgtuser($data, $user, $err)
$offset++;
}
}
$pg .= '<tr><td colspan=2 class=dc><font size=-1><span class=st1>*</span>';
$pg .= ' A value of 0, less than the pool default,<br>';
$pg .= 'or less than the pool calculated value for you,<br>';
$pg .= 'will use the pool calculated value</font></td></tr>';
$pg .= "</table><input type=hidden name=rows value=$count></form>\n";
return $pg;

10
src/ckdb.h

@ -52,7 +52,7 @@
#define DB_VLOCK "1"
#define DB_VERSION "0.9.2"
#define CKDB_VERSION DB_VERSION"-0.405"
#define CKDB_VERSION DB_VERSION"-0.406"
#define WHERE_FFL " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__
@ -597,15 +597,17 @@ extern K_LIST *workers_free;
extern K_STORE *workers_store;
#define DIFFICULTYDEFAULT_MIN 10
#define DIFFICULTYDEFAULT_MAX 1000000
#define DIFFICULTYDEFAULT_DEF DIFFICULTYDEFAULT_MIN
#define DIFFICULTYDEFAULT_MAX 0x7fffffff
// 0 means it's not set
#define DIFFICULTYDEFAULT_DEF 0
#define DIFFICULTYDEFAULT_DEF_STR STRINT(DIFFICULTYDEFAULT_DEF)
#define IDLENOTIFICATIONENABLED "y"
#define IDLENOTIFICATIONDISABLED " "
#define IDLENOTIFICATIONENABLED_DEF IDLENOTIFICATIONDISABLED
#define IDLENOTIFICATIONTIME_MIN 10
#define IDLENOTIFICATIONTIME_MAX 60
#define IDLENOTIFICATIONTIME_DEF IDLENOTIFICATIONTIME_MIN
// 0 means it's not set and will be flagged disabled
#define IDLENOTIFICATIONTIME_DEF 0
#define IDLENOTIFICATIONTIME_DEF_STR STRINT(IDLENOTIFICATIONTIME_DEF)
// PAYMENTADDRESSES

2
src/ckdb_cmd.c

@ -355,10 +355,12 @@ static char *cmd_workerset(PGconn *conn, char *cmd, char *id, tv_t *now,
continue;
difficultydefault = atoi(transfer_data(i_diffdef));
if (difficultydefault != 0) {
if (difficultydefault < DIFFICULTYDEFAULT_MIN)
difficultydefault = DIFFICULTYDEFAULT_MIN;
if (difficultydefault > DIFFICULTYDEFAULT_MAX)
difficultydefault = DIFFICULTYDEFAULT_MAX;
}
if (workers->difficultydefault != difficultydefault) {
/* This uses a seperate txn per update

19
src/ckdb_dbio.c

@ -1068,6 +1068,7 @@ K_ITEM *workers_add(PGconn *conn, int64_t userid, char *workername,
conned = true;
}
bzero(row, sizeof(*row));
row->workerid = nextid(conn, "workerid", (int64_t)1, cd, by, code, inet);
if (row->workerid == 0)
goto unitem;
@ -1076,10 +1077,13 @@ K_ITEM *workers_add(PGconn *conn, int64_t userid, char *workername,
STRNCPY(row->workername, workername);
if (difficultydefault && *difficultydefault) {
diffdef = atoi(difficultydefault);
// If out of the range, set it in the range
if (diffdef != DIFFICULTYDEFAULT_DEF) {
if (diffdef < DIFFICULTYDEFAULT_MIN)
diffdef = DIFFICULTYDEFAULT_MIN;
if (diffdef > DIFFICULTYDEFAULT_MAX)
diffdef = DIFFICULTYDEFAULT_MAX;
}
row->difficultydefault = diffdef;
} else
row->difficultydefault = DIFFICULTYDEFAULT_DEF;
@ -1095,15 +1099,20 @@ K_ITEM *workers_add(PGconn *conn, int64_t userid, char *workername,
if (idlenotificationtime && *idlenotificationtime) {
nottime = atoi(idlenotificationtime);
if (nottime < DIFFICULTYDEFAULT_MIN) {
row->idlenotificationenabled[0] = IDLENOTIFICATIONDISABLED[0];
nottime = DIFFICULTYDEFAULT_MIN;
} else if (nottime > IDLENOTIFICATIONTIME_MAX)
nottime = row->idlenotificationtime;
if (nottime != IDLENOTIFICATIONTIME_DEF) {
// If out of the range, set to default
if (nottime < IDLENOTIFICATIONTIME_MIN ||
nottime > IDLENOTIFICATIONTIME_MAX)
nottime = IDLENOTIFICATIONTIME_DEF;
}
row->idlenotificationtime = nottime;
} else
row->idlenotificationtime = IDLENOTIFICATIONTIME_DEF;
// Default is disabled
if (row->idlenotificationtime == IDLENOTIFICATIONTIME_DEF)
row->idlenotificationenabled[0] = IDLENOTIFICATIONDISABLED[0];
HISTORYDATEINIT(row, cd, by, code, inet);
HISTORYDATETRANSFER(trf_root, row);

Loading…
Cancel
Save