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. 10
      src/ckdb_cmd.c
  4. 27
      src/ckdb_dbio.c

4
pool/page_workmgt.php

@ -45,6 +45,10 @@ function workmgtuser($data, $user, $err)
$offset++; $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"; $pg .= "</table><input type=hidden name=rows value=$count></form>\n";
return $pg; return $pg;

10
src/ckdb.h

@ -52,7 +52,7 @@
#define DB_VLOCK "1" #define DB_VLOCK "1"
#define DB_VERSION "0.9.2" #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 " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__ #define WHERE_FFL_HERE __FILE__, __func__, __LINE__
@ -597,15 +597,17 @@ extern K_LIST *workers_free;
extern K_STORE *workers_store; extern K_STORE *workers_store;
#define DIFFICULTYDEFAULT_MIN 10 #define DIFFICULTYDEFAULT_MIN 10
#define DIFFICULTYDEFAULT_MAX 1000000 #define DIFFICULTYDEFAULT_MAX 0x7fffffff
#define DIFFICULTYDEFAULT_DEF DIFFICULTYDEFAULT_MIN // 0 means it's not set
#define DIFFICULTYDEFAULT_DEF 0
#define DIFFICULTYDEFAULT_DEF_STR STRINT(DIFFICULTYDEFAULT_DEF) #define DIFFICULTYDEFAULT_DEF_STR STRINT(DIFFICULTYDEFAULT_DEF)
#define IDLENOTIFICATIONENABLED "y" #define IDLENOTIFICATIONENABLED "y"
#define IDLENOTIFICATIONDISABLED " " #define IDLENOTIFICATIONDISABLED " "
#define IDLENOTIFICATIONENABLED_DEF IDLENOTIFICATIONDISABLED #define IDLENOTIFICATIONENABLED_DEF IDLENOTIFICATIONDISABLED
#define IDLENOTIFICATIONTIME_MIN 10 #define IDLENOTIFICATIONTIME_MIN 10
#define IDLENOTIFICATIONTIME_MAX 60 #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) #define IDLENOTIFICATIONTIME_DEF_STR STRINT(IDLENOTIFICATIONTIME_DEF)
// PAYMENTADDRESSES // PAYMENTADDRESSES

10
src/ckdb_cmd.c

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

27
src/ckdb_dbio.c

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

Loading…
Cancel
Save