Browse Source

ckdb table changes/additions

master
kanoi 11 years ago
parent
commit
906cf6fc09
  1. 53
      sql/ckdb.sql
  2. 11
      sql/initid.sh
  3. 1599
      src/ckdb.c
  4. 2
      src/ktree.c

53
sql/ckdb.sql

@ -32,7 +32,7 @@ CREATE UNIQUE INDEX usersusername ON users USING btree (username, expirydate);
CREATE TABLE workers ( CREATE TABLE workers (
workerid bigint NOT NULL, -- unique per record workerid bigint NOT NULL, -- unique per record
userid bigint NOT NULL, userid bigint NOT NULL,
workername character varying(64) NOT NULL, workername character varying(256) NOT NULL,
difficultydefault integer DEFAULT 128 NOT NULL, difficultydefault integer DEFAULT 128 NOT NULL,
idlenotificationenabled char DEFAULT 'n'::character varying NOT NULL, idlenotificationenabled char DEFAULT 'n'::character varying NOT NULL,
idlenotificationtime integer DEFAULT 10 NOT NULL, idlenotificationtime integer DEFAULT 10 NOT NULL,
@ -95,6 +95,20 @@ CREATE TABLE accountbalance ( -- summarised from miningpayouts and payments
); );
CREATE TABLE accountadjustment ( -- manual corrections
userid bigint NOT NULL,
authority character varying(256) NOT NULL,
reason text NOT NULL,
amount bigint DEFAULT 0 NOT NULL, -- satoshis
createdate timestamp with time zone NOT NULL,
createby character varying(64) DEFAULT ''::character varying NOT NULL,
createcode character varying(128) DEFAULT ''::character varying NOT NULL,
createinet character varying(128) DEFAULT ''::character varying NOT NULL,
expirydate timestamp with time zone DEFAULT '6666-06-06 06:06:06+00',
PRIMARY KEY (userid, createdate, expirydate)
);
CREATE TABLE idcontrol ( CREATE TABLE idcontrol (
idname character varying(64) NOT NULL, idname character varying(64) NOT NULL,
lastid bigint DEFAULT 1 NOT NULL, lastid bigint DEFAULT 1 NOT NULL,
@ -112,7 +126,7 @@ CREATE TABLE idcontrol (
CREATE TABLE optioncontrol ( CREATE TABLE optioncontrol (
optionname character varying(64) NOT NULL, optionname character varying(64) NOT NULL,
optionvalue character varying(128) DEFAULT ''::character varying NOT NULL, optionvalue text NOT NULL,
activationdate timestamp with time zone DEFAULT '6666-06-06 06:06:06+00', activationdate timestamp with time zone DEFAULT '6666-06-06 06:06:06+00',
activationheight integer DEFAULT 999999999, activationheight integer DEFAULT 999999999,
createdate timestamp with time zone NOT NULL, createdate timestamp with time zone NOT NULL,
@ -135,6 +149,7 @@ CREATE TABLE workinfo (
version character varying(64) NOT NULL, version character varying(64) NOT NULL,
bits character varying(64) NOT NULL, bits character varying(64) NOT NULL,
ntime character varying(64) NOT NULL, ntime character varying(64) NOT NULL,
reward bigint NOT NULL, -- satoshis
createdate timestamp with time zone NOT NULL, createdate timestamp with time zone NOT NULL,
createby character varying(64) DEFAULT ''::character varying NOT NULL, createby character varying(64) DEFAULT ''::character varying NOT NULL,
createcode character varying(128) DEFAULT ''::character varying NOT NULL, createcode character varying(128) DEFAULT ''::character varying NOT NULL,
@ -144,14 +159,18 @@ CREATE TABLE workinfo (
); );
CREATE TABLE shares ( CREATE TABLE shares ( -- not stored in the db - only in log files
workinfoid bigint NOT NULL, workinfoid bigint NOT NULL,
userid bigint NOT NULL, userid bigint NOT NULL,
workername character varying(64) NOT NULL, workername character varying(256) NOT NULL,
clientid integer NOT NULL, clientid integer NOT NULL,
enonce1 character varying(64) NOT NULL, enonce1 character varying(64) NOT NULL,
nonce2 character varying(256) NOT NULL, nonce2 character varying(256) NOT NULL,
nonce character varying(64) NOT NULL, nonce character varying(64) NOT NULL,
diff float NOT NULL,
sdiff float NOT NULL,
errno integer NOT NULL,
error character varying(64) DEFAULT ''::character varying NOT NULL, -- optional
secondaryuserid character varying(64) NOT NULL, secondaryuserid character varying(64) NOT NULL,
createdate timestamp with time zone NOT NULL, createdate timestamp with time zone NOT NULL,
createby character varying(64) DEFAULT ''::character varying NOT NULL, createby character varying(64) DEFAULT ''::character varying NOT NULL,
@ -162,10 +181,27 @@ CREATE TABLE shares (
); );
CREATE TABLE shareerrors ( -- not stored in the db - only in log files
workinfoid bigint NOT NULL,
userid bigint NOT NULL,
workername character varying(256) NOT NULL,
clientid integer NOT NULL,
errno integer NOT NULL,
error character varying(64) DEFAULT ''::character varying NOT NULL, -- optional
secondaryuserid character varying(64) NOT NULL,
createdate timestamp with time zone NOT NULL,
createby character varying(64) DEFAULT ''::character varying NOT NULL,
createcode character varying(128) DEFAULT ''::character varying NOT NULL,
createinet character varying(128) DEFAULT ''::character varying NOT NULL,
expirydate timestamp with time zone DEFAULT '6666-06-06 06:06:06+00',
PRIMARY KEY (workinfoid, userid, workername, clientid, createdate, expirydate)
);
-- memory only? -- memory only?
CREATE TABLE sharesummary ( -- per workinfo for each user+worker CREATE TABLE sharesummary ( -- per workinfo for each user+worker
userid bigint NOT NULL, userid bigint NOT NULL,
workername character varying(64) NOT NULL, workername character varying(256) NOT NULL,
workinfoid bigint NOT NULL, workinfoid bigint NOT NULL,
diff_acc bigint NOT NULL, diff_acc bigint NOT NULL,
diff_sta bigint NOT NULL, diff_sta bigint NOT NULL,
@ -196,7 +232,7 @@ CREATE TABLE blocksummary ( -- summation of sharesummary per block found for eac
height integer not NULL, height integer not NULL,
blockhash character varying(256) NOT NULL, blockhash character varying(256) NOT NULL,
userid bigint NOT NULL, userid bigint NOT NULL,
workername character varying(64) NOT NULL, workername character varying(256) NOT NULL,
diff_acc bigint NOT NULL, diff_acc bigint NOT NULL,
diff_sta bigint NOT NULL, diff_sta bigint NOT NULL,
diff_dup bigint NOT NULL, diff_dup bigint NOT NULL,
@ -229,11 +265,12 @@ CREATE TABLE blocks (
blockhash character varying(256) NOT NULL, blockhash character varying(256) NOT NULL,
workinfoid bigint NOT NULL, workinfoid bigint NOT NULL,
userid bigint NOT NULL, userid bigint NOT NULL,
workername character varying(64) NOT NULL, workername character varying(256) NOT NULL,
clientid integer NOT NULL, clientid integer NOT NULL,
enonce1 character varying(64) NOT NULL, enonce1 character varying(64) NOT NULL,
nonce2 character varying(256) NOT NULL, nonce2 character varying(256) NOT NULL,
nonce character varying(64) NOT NULL, nonce character varying(64) NOT NULL,
reward bigint NOT NULL, -- satoshis
confirmed char DEFAULT '' NOT NULL, -- blank, 'c'onfirmed or 'o'rphan confirmed char DEFAULT '' NOT NULL, -- blank, 'c'onfirmed or 'o'rphan
createdate timestamp with time zone NOT NULL, createdate timestamp with time zone NOT NULL,
createby character varying(64) DEFAULT ''::character varying NOT NULL, createby character varying(64) DEFAULT ''::character varying NOT NULL,
@ -279,7 +316,7 @@ CREATE TABLE eventlog (
CREATE TABLE auths ( CREATE TABLE auths (
authid bigint NOT NULL, -- unique per record authid bigint NOT NULL, -- unique per record
userid bigint NOT NULL, userid bigint NOT NULL,
workername character varying(64) NOT NULL, workername character varying(256) NOT NULL,
clientid integer NOT NULL, clientid integer NOT NULL,
enonce1 character varying(64) NOT NULL, enonce1 character varying(64) NOT NULL,
useragent character varying(256) NOT NULL, useragent character varying(256) NOT NULL,

11
sql/initid.sh

@ -23,4 +23,13 @@ addid()
process "$msg" process "$msg"
} }
# #
addid userid 7 # Default to yyyymmddXXXXXX
# thus on reinit it will always be above old values
# XXXXXX should allow enough per day to avoid overlap with other ids
# but of course overlapping with another id doesn't technically matter
now="`date +%Y%m%d`"
#
addid userid ${now}100000
addid workerid ${now}200000
addid paymentid ${now}300000
addid authid ${now}400000

1599
src/ckdb.c

File diff suppressed because it is too large Load Diff

2
src/ktree.c

@ -23,7 +23,7 @@ static const int dbg = 0;
#define Yo true #define Yo true
#define No false #define No false
static K_TREE nil[1] = { Yo, RED_BLACK, NULL, NULL, NULL, NULL, 0 }; static K_TREE nil[1] = { { Yo, RED_BLACK, NULL, NULL, NULL, NULL, 0 } };
K_TREE *new_ktree() K_TREE *new_ktree()
{ {

Loading…
Cancel
Save