├── .gitignore ├── AUTHORS ├── COPYING ├── ChangeLog ├── Makefile.am ├── NEWS ├── README ├── autogen.sh ├── cknode.conf ├── ckpassthrough.conf ├── ckpool.conf ├── ckproxy.conf ├── ckredirector.conf ├── configure.ac ├── html ├── BTC.png ├── BTC20.png ├── BTCSym.png ├── address.php ├── favicon.ico ├── green.png ├── index.php ├── maintenance.txt.dis ├── orange.png ├── red.png └── worker.php ├── m4 └── .gitignore ├── pool ├── address.php ├── base.php ├── db.php ├── email.php ├── inc.php ├── index.html ├── page.php ├── page_2fa.php ├── page_addrmgt.php ├── page_allwork.php ├── page_api.php ├── page_blocks.php ├── page_ckp.php ├── page_events.php ├── page_help.php ├── page_index.php ├── page_ips.php ├── page_luck.php ├── page_mpayouts.php ├── page_payments.php ├── page_payout.php ├── page_pblocks.php ├── page_percent.php ├── page_pplns.php ├── page_pplns2.php ├── page_psperf.php ├── page_reg.php ├── page_reset.php ├── page_settings.php ├── page_shifts.php ├── page_stats.php ├── page_userinfo.php ├── page_userset.php ├── page_usperf.php ├── page_workers.php ├── page_workmgt.php ├── param.php ├── prime.php ├── socket.php └── worker.php ├── sql ├── bs.sql ├── ckdb.sql ├── initid.sh ├── luck.sh ├── reloadstatus.sql ├── rollback.sh ├── tabdump.sh ├── tables.sql ├── v0.6-v0.7.sql ├── v0.7-v0.8.sql ├── v0.8-v0.9.sql ├── v0.9-v0.9.1.sql ├── v0.9.1-v0.9.2.sql ├── v0.9.2-v0.9.3.sql ├── v0.9.3-v0.9.4.sql ├── v0.9.4-v0.9.5.sql ├── v0.9.5-v0.9.6.sql ├── v0.9.6-v1.0.0.sql ├── v1.0.0-v1.0.1.sql ├── v1.0.1-v1.0.2.sql ├── v1.0.2-v1.0.3.sql ├── v1.0.3-v1.0.4.sql ├── v1.0.4-v1.0.5.sql ├── v1.0.5-v1.0.6.sql ├── v1.0.6-v1.0.7.sql └── v1.0.7-v1.0.8.sql └── src ├── Makefile.am ├── bitcoin.c ├── bitcoin.h ├── ckdb.c ├── ckdb.h ├── ckdb.php ├── ckdb_btc.c ├── ckdb_cmd.c ├── ckdb_crypt.c ├── ckdb_data.c ├── ckdb_dbio.c ├── ckpmsg.c ├── ckpool.c ├── ckpool.h ├── cmd.sh ├── connector.c ├── connector.h ├── generator.c ├── generator.h ├── jansson-2.10 ├── CHANGES ├── CMakeLists.txt ├── LICENSE ├── Makefile.am ├── README.rst ├── android │ └── jansson_config.h ├── configure.ac ├── jansson.pc.in ├── jansson_private_config.h.in ├── src │ ├── Makefile.am │ ├── dump.c │ ├── error.c │ ├── hashtable.c │ ├── hashtable.h │ ├── hashtable_seed.c │ ├── jansson.def │ ├── jansson.h │ ├── jansson_config.h.in │ ├── jansson_private.h │ ├── load.c │ ├── lookup3.h │ ├── memory.c │ ├── pack_unpack.c │ ├── strbuffer.c │ ├── strbuffer.h │ ├── strconv.c │ ├── utf.c │ ├── utf.h │ └── value.c └── test-driver ├── klist.c ├── klist.h ├── ktree.c ├── ktree.h ├── libckpool.c ├── libckpool.h ├── notifier.c ├── relog.sh ├── sha2.c ├── sha2.h ├── sha256_code_release ├── open_software_license.txt ├── sha256_avx1.asm ├── sha256_avx2_rorx2.asm └── sha256_sse4.asm ├── stratifier.c ├── stratifier.h ├── uthash.h └── utlist.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.bin 3 | *.la 4 | *.lo 5 | 6 | autom4te.cache 7 | .deps 8 | 9 | Makefile 10 | Makefile.in 11 | INSTALL 12 | aclocal.m4 13 | configure 14 | depcomp 15 | missing 16 | install-sh 17 | stamp-h1 18 | compile 19 | config.log 20 | config.status 21 | config.guess 22 | config.sub 23 | 24 | *~ 25 | 26 | ext_deps 27 | config.h.in 28 | config.h 29 | 30 | mkinstalldirs 31 | 32 | *.swp 33 | src/ckpool 34 | src/ckpmsg 35 | src/ckdb 36 | ltmain.sh 37 | 38 | *.m4 39 | 40 | .libs/ 41 | 42 | libtool 43 | 44 | 45 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Con Kolivas 2 | Core project lead, maintainer, author of ckpool and libckpool. 3 | 14BMjogz69qe8hk9thyzbmR5pg34mVKB1e 4 | 5 | Andrew Smith 6 | Maintainer and author of ckdb. 7 | 1Jjk2LmktEQKnv8r2cZ9MvLiZwZ9gxabKm 8 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- 1 | See git repository ('git log') for full changelog. 2 | 3 | Git repository can be found at: 4 | https://bitbucket.org/ckolivas/ckpool 5 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ACLOCAL_AMFLAGS = -I m4 2 | SUBDIRS = src 3 | EXTRA_DIST = ckpool.conf ckproxy.conf 4 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ctubio/ckpool/4718cea30af47963aa55dcc4c452b9b2f9768ff8/NEWS -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | autoreconf --force --install -I m4 3 | -------------------------------------------------------------------------------- /cknode.conf: -------------------------------------------------------------------------------- 1 | { 2 | "btcd" : [ 3 | { 4 | "url" : "localhost:8332", 5 | "auth" : "user", 6 | "pass" : "pass", 7 | "notify" : true 8 | }, 9 | { 10 | "url" : "backup:8332", 11 | "auth" : "user", 12 | "pass" : "pass", 13 | "notify" : false 14 | } 15 | ], 16 | "proxy" : [ 17 | { 18 | "url" : "ckpool.org:3333", 19 | "auth" : "user", 20 | "pass" : "pass" 21 | }, 22 | { 23 | "url" : "backup.ckpool.org:3333", 24 | "auth" : "user", 25 | "pass" : "pass" 26 | } 27 | ], 28 | "serverurl" : [ 29 | "192.168.1.100:3334", 30 | "127.0.0.1:3334" 31 | ], 32 | "logdir" : "logs" 33 | } 34 | Comments from here on are ignored. 35 | -------------------------------------------------------------------------------- /ckpassthrough.conf: -------------------------------------------------------------------------------- 1 | { 2 | "proxy" : [ 3 | { 4 | "url" : "ckpool.org:3333", 5 | "auth" : "user", 6 | "pass" : "pass" 7 | } 8 | ], 9 | "serverurl" : [ 10 | "192.168.1.100:3334", 11 | "127.0.0.1:3334" 12 | ], 13 | "logdir" : "logs" 14 | } 15 | Comments from here on are ignored. 16 | -------------------------------------------------------------------------------- /ckpool.conf: -------------------------------------------------------------------------------- 1 | { 2 | "btcd" : [ 3 | { 4 | "url" : "localhost:8332", 5 | "auth" : "user", 6 | "pass" : "pass", 7 | "notify" : true 8 | }, 9 | { 10 | "url" : "backup:8332", 11 | "auth" : "user", 12 | "pass" : "pass", 13 | "notify" : false 14 | } 15 | ], 16 | "upstream" : "main.ckpool.org:3336", 17 | "btcaddress" : "14BMjogz69qe8hk9thyzbmR5pg34mVKB1e", 18 | "btcsig" : "/mined by ck/", 19 | "blockpoll" : 100, 20 | "nonce1length" : 4, 21 | "nonce2length" : 8, 22 | "update_interval" : 30, 23 | "serverurl" : [ 24 | "ckpool.org:3333", 25 | "node.ckpool.org:3333", 26 | "node.ckpool.org:80" 27 | ], 28 | "nodeserver" : [ 29 | "ckpool.org:3335" 30 | ], 31 | "trusted" : [ 32 | "ckpool.org:3336" 33 | ], 34 | "mindiff" : 1, 35 | "startdiff" : 42, 36 | "maxdiff" : 0, 37 | "logdir" : "logs" 38 | } 39 | Comments from here on are ignored. 40 | -------------------------------------------------------------------------------- /ckproxy.conf: -------------------------------------------------------------------------------- 1 | { 2 | "proxy" : [ 3 | { 4 | "url" : "ckpool.org:3333", 5 | "auth" : "user", 6 | "pass" : "pass" 7 | }, 8 | { 9 | "url" : "backup.ckpool.org:3333", 10 | "auth" : "user", 11 | "pass" : "pass" 12 | } 13 | ], 14 | "update_interval" : 30, 15 | "serverurl" : [ 16 | "192.168.1.100:3334", 17 | "127.0.0.1:3334" 18 | ], 19 | "mindiff" : 1, 20 | "startdiff" : 42, 21 | "maxdiff" : 0, 22 | "logdir" : "logs" 23 | } 24 | Comments from here on are ignored. 25 | -------------------------------------------------------------------------------- /ckredirector.conf: -------------------------------------------------------------------------------- 1 | { 2 | "proxy" : [ 3 | { 4 | "url" : "ckpool.org:3333", 5 | "auth" : "user", 6 | "pass" : "pass" 7 | } 8 | ], 9 | "update_interval" : 30, 10 | "serverurl" : [ 11 | "192.168.1.100:3334", 12 | "127.0.0.1:3334" 13 | ], 14 | "redirecturl" : [ 15 | "node1.ckpool.org:3333", 16 | "node2.ckpool.org:3333" 17 | ], 18 | "mindiff" : 1, 19 | "startdiff" : 42, 20 | "maxdiff" : 0, 21 | "logdir" : "logs" 22 | } 23 | Comments from here on are ignored. 24 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | AC_INIT(ckpool, 0.9.4, kernel@kolivas.org) 2 | 3 | AC_CANONICAL_SYSTEM 4 | AC_CONFIG_MACRO_DIR([m4]) 5 | AC_CONFIG_SRCDIR([src/ckpool.c]) 6 | AC_CONFIG_HEADERS([config.h]) 7 | 8 | AM_INIT_AUTOMAKE([foreign subdir-objects]) 9 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) 10 | AC_USE_SYSTEM_EXTENSIONS 11 | 12 | AC_CANONICAL_BUILD 13 | AC_CANONICAL_HOST 14 | 15 | dnl Make sure anyone changing configure.ac/Makefile.am has a clue 16 | AM_MAINTAINER_MODE 17 | 18 | dnl Checks for programs 19 | AC_PROG_CC 20 | # gl_EARLY - maybe later 21 | AC_PROG_GCC_TRADITIONAL 22 | AM_PROG_CC_C_O 23 | LT_INIT([disable-shared]) 24 | 25 | # gl_INIT - maybe later 26 | 27 | dnl Checks for header files. 28 | AC_HEADER_STDC 29 | 30 | AC_FUNC_ALLOCA 31 | 32 | PKG_PROG_PKG_CONFIG() 33 | 34 | AC_CHECK_HEADERS(stdio.h stdlib.h fcntl.h sys/time.h unistd.h dirent.h) 35 | AC_CHECK_HEADERS(ctype.h errno.h byteswap.h string.h time.h fenv.h) 36 | AC_CHECK_HEADERS(endian.h sys/endian.h arpa/inet.h sys/poll.h syslog.h) 37 | AC_CHECK_HEADERS(alloca.h pthread.h stdio.h math.h signal.h sys/prctl.h) 38 | AC_CHECK_HEADERS(sys/types.h sys/socket.h sys/stat.h linux/un.h netdb.h) 39 | AC_CHECK_HEADERS(stdint.h netinet/in.h netinet/tcp.h sys/ioctl.h getopt.h) 40 | AC_CHECK_HEADERS(sys/epoll.h libpq-fe.h postgresql/libpq-fe.h grp.h) 41 | AC_CHECK_HEADERS(gsl/gsl_math.h gsl/gsl_cdf.h) 42 | AC_CHECK_HEADERS(openssl/x509.h openssl/hmac.h) 43 | 44 | AC_CHECK_PROG(YASM, yasm, yes) 45 | AM_CONDITIONAL([HAVE_YASM], [test x$YASM = xyes]) 46 | 47 | rorx= 48 | avx1= 49 | sse4= 50 | if test x$YASM = xyes; then 51 | rorx=`cat /proc/cpuinfo | grep -o -m 1 avx2` 52 | if [test x$rorx != xavx2]; then 53 | avx1=`cat /proc/cpuinfo | grep -o -m 1 avx` 54 | if [test x$avx1 != xavx]; then 55 | sse4=`cat /proc/cpuinfo | grep -o -m 1 sse4_1` 56 | fi 57 | fi 58 | fi 59 | AM_CONDITIONAL([HAVE_AVX2], [test x$rorx = xavx2]) 60 | AM_CONDITIONAL([HAVE_AVX1], [test x$avx1 = xavx]) 61 | AM_CONDITIONAL([HAVE_SSE4], [test x$sse4 = xsse4_1]) 62 | if test x$rorx = xavx2; then 63 | AC_DEFINE([USE_AVX2], [1], [Use avx2 assembly instructions for sha256]) 64 | fi 65 | if test x$avx1 = xavx; then 66 | AC_DEFINE([USE_AVX1], [1], [Use avx1 assembly instructions for sha256]) 67 | fi 68 | if test x$sse4 = xsse4_1; then 69 | AC_DEFINE([USE_SSE4], [1], [Use sse4 assembly instructions for sha256]) 70 | fi 71 | 72 | AC_CONFIG_SUBDIRS([src/jansson-2.10]) 73 | JANSSON_LIBS="jansson-2.10/src/.libs/libjansson.a" 74 | 75 | AC_SUBST(JANSSON_LIBS) 76 | 77 | AC_ARG_WITH([ckdb], 78 | [AC_HELP_STRING([--with-ckdb],[Compile ckpool with ckdb database support (default disabled)])], 79 | [ckdb=$withval],[ckdb=no] 80 | ) 81 | 82 | AC_SEARCH_LIBS(clock_nanosleep, rt, , "Error: Required library rt not found." && exit 1) 83 | AC_SEARCH_LIBS(exp, m, , echo "Error: Required library math not found." && exit 1) 84 | AC_SEARCH_LIBS(pthread_mutex_trylock, pthread, , "Error: Required library pthreads not found." && exit 1) 85 | 86 | if test "x$ckdb" != "xno"; then 87 | AC_SEARCH_LIBS(PQdb, pq, , echo "Error: Required library pq 88 | not found. Install it or disable support by removing --with-ckdb" && exit 1) 89 | AC_SEARCH_LIBS(BN_init, crypto, , echo "Error: Required library crypto 90 | not found. Install them or disable support by removing --with-ckdb" && exit 1) 91 | AC_SEARCH_LIBS(SSL_accept, ssl, , echo "Error: Required libraries ssl 92 | not found. Install them or disable support by removing --with-ckdb" && exit 1) 93 | AC_SEARCH_LIBS(cblas_dgemm, gslcblas, ,echo "Error: Required library gslcblas 94 | not found. Install them or disable support by removing --with-ckdb" && exit 1) 95 | AC_SEARCH_LIBS(gsl_blas_dgemm, gsl, , echo "Error: Required library gsl 96 | not found. Install them or disable support by removing --with-ckdb" && exit 1) 97 | AC_DEFINE([USE_CKDB], [1], [Defined to 1 if ckdb support required]) 98 | fi 99 | AM_CONDITIONAL([WANT_CKDB], [test "x$ckdb" != "xno"]) 100 | AC_SUBST(DB_LIBS) 101 | 102 | AC_OUTPUT([Makefile] [src/Makefile]) 103 | 104 | LDFLAGS="${LDFLAGS} -Wl,--as-needed" 105 | 106 | echo 107 | echo "Compilation............: make (or gmake)" 108 | echo " YASM (Intel ASM).....: $YASM" 109 | echo " CPPFLAGS.............: $CPPFLAGS" 110 | echo " CFLAGS...............: $CFLAGS" 111 | echo " LDFLAGS..............: $LDFLAGS" 112 | echo " LDADD................: $LIBS $JANSSON_LIBS" 113 | echo 114 | echo "Installation...........: make install (as root if needed, with 'su' or 'sudo')" 115 | echo " prefix...............: $prefix" 116 | echo 117 | -------------------------------------------------------------------------------- /html/BTC.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ctubio/ckpool/4718cea30af47963aa55dcc4c452b9b2f9768ff8/html/BTC.png -------------------------------------------------------------------------------- /html/BTC20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ctubio/ckpool/4718cea30af47963aa55dcc4c452b9b2f9768ff8/html/BTC20.png -------------------------------------------------------------------------------- /html/BTCSym.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ctubio/ckpool/4718cea30af47963aa55dcc4c452b9b2f9768ff8/html/BTCSym.png -------------------------------------------------------------------------------- /html/address.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /html/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ctubio/ckpool/4718cea30af47963aa55dcc4c452b9b2f9768ff8/html/favicon.ico -------------------------------------------------------------------------------- /html/green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ctubio/ckpool/4718cea30af47963aa55dcc4c452b9b2f9768ff8/html/green.png -------------------------------------------------------------------------------- /html/index.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /html/maintenance.txt.dis: -------------------------------------------------------------------------------- 1 |

Web site is down for maintenance

2 | -------------------------------------------------------------------------------- /html/orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ctubio/ckpool/4718cea30af47963aa55dcc4c452b9b2f9768ff8/html/orange.png -------------------------------------------------------------------------------- /html/red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ctubio/ckpool/4718cea30af47963aa55dcc4c452b9b2f9768ff8/html/red.png -------------------------------------------------------------------------------- /html/worker.php: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /m4/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.bin 3 | 4 | autom4te.cache 5 | .deps 6 | 7 | Makefile 8 | Makefile.in 9 | INSTALL 10 | aclocal.m4 11 | configure 12 | depcomp 13 | missing 14 | install-sh 15 | stamp-h1 16 | compile 17 | config.log 18 | config.status 19 | config.guess 20 | config.sub 21 | 22 | *~ 23 | 24 | ext_deps 25 | config.h.in 26 | config.h 27 | 28 | mkinstalldirs 29 | 30 | *.swp 31 | -------------------------------------------------------------------------------- /pool/address.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | CKPool 7 | 24 | 25 | -------------------------------------------------------------------------------- /pool/email.php: -------------------------------------------------------------------------------- 1 | $eol$eol"; 142 | if ($old != null && $old != '') 143 | { 144 | $message .= "You will no longer receive notifications at the address:$eol <$old>$eol$eol"; 145 | $send = "$to,$old"; 146 | } 147 | else 148 | $send = $to; 149 | $message .= $ret; 150 | 151 | return sendnoheader($send, "EMail Address Change", $message, $emailinfo); 152 | } 153 | # 154 | function passChanged($to, $whoip, $emailinfo) 155 | { 156 | global $eol; 157 | 158 | if (!isset($emailinfo['KWebURL'])) 159 | return false; 160 | 161 | $web = $emailinfo['KWebURL']; 162 | 163 | $ret = emailEnd('password change', $whoip, $emailinfo); 164 | if ($ret === false) 165 | return false; 166 | 167 | $message = "Your password was changed.$eol$eol"; 168 | $message .= "If you didn't change it, then you need to urgently use$eol"; 169 | $message .= "the password reset at the pool to change it again.$eol$eol"; 170 | $message .= $ret; 171 | 172 | return sendnoheader($to, "Password Change", $message, $emailinfo); 173 | } 174 | # 175 | function twofaSetup($to, $whoip, $emailinfo) 176 | { 177 | global $eol; 178 | 179 | if (!isset($emailinfo['KWebURL'])) 180 | return false; 181 | 182 | $web = $emailinfo['KWebURL']; 183 | 184 | $ret = emailEnd('2fa change', $whoip, $emailinfo); 185 | if ($ret === false) 186 | return false; 187 | 188 | $message = "2FA is ready to be tested.$eol"; 189 | $message .= "It will be enabled once you test it.$eol$eol"; 190 | $message .= $ret; 191 | 192 | return sendnoheader($to, "2FA is Ready to be Enabled", $message, $emailinfo); 193 | } 194 | # 195 | function twofaEnabled($to, $whoip, $emailinfo) 196 | { 197 | global $eol; 198 | 199 | if (!isset($emailinfo['KWebURL'])) 200 | return false; 201 | 202 | $web = $emailinfo['KWebURL']; 203 | 204 | $ret = emailEnd('2fa change', $whoip, $emailinfo); 205 | if ($ret === false) 206 | return false; 207 | 208 | $message = "2FA is enabled on your account.$eol$eol"; 209 | $message .= $ret; 210 | 211 | return sendnoheader($to, "2FA is Enabled", $message, $emailinfo); 212 | } 213 | # 214 | function twofaCancel($to, $whoip, $emailinfo) 215 | { 216 | global $eol; 217 | 218 | if (!isset($emailinfo['KWebURL'])) 219 | return false; 220 | 221 | $web = $emailinfo['KWebURL']; 222 | 223 | $ret = emailEnd('2fa change', $whoip, $emailinfo); 224 | if ($ret === false) 225 | return false; 226 | 227 | $message = "2FA setup was cancelled on your account.$eol"; 228 | $message .= "You can set it up later if you want.$eol$eol"; 229 | $message .= $ret; 230 | 231 | return sendnoheader($to, "2FA was Cancelled", $message, $emailinfo); 232 | } 233 | # 234 | function twofaRemove($to, $whoip, $emailinfo) 235 | { 236 | global $eol; 237 | 238 | if (!isset($emailinfo['KWebURL'])) 239 | return false; 240 | 241 | $web = $emailinfo['KWebURL']; 242 | 243 | $ret = emailEnd('2fa change', $whoip, $emailinfo); 244 | if ($ret === false) 245 | return false; 246 | 247 | $message = "2FA was removed from your account.$eol"; 248 | $message .= "You can set it up again later if you want.$eol$eol"; 249 | $message .= $ret; 250 | 251 | return sendnoheader($to, "2FA was Removed", $message, $emailinfo); 252 | } 253 | # 254 | # getOpts required for email 255 | # If they aren't all setup in the DB then email functions will return false 256 | function emailOptList() 257 | { 258 | return 'KWebURL,KNoReply'; 259 | } 260 | # 261 | ?> 262 | -------------------------------------------------------------------------------- /pool/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |

Web configuration needs adjustment

4 | 5 | -------------------------------------------------------------------------------- /pool/page_addrmgt.php: -------------------------------------------------------------------------------- 1 | Address Management'; 8 | 9 | if ($err != '') 10 | $pg .= "$err

"; 11 | 12 | $pg .= makeForm('addrmgt'); 13 | $pg .= "\n"; 14 | $pg .= ''; 15 | $pg .= ''; 16 | $pg .= ''; 17 | $pg .= ''; 18 | $pg .= ''; 19 | $pg .= ''; 20 | $pg .= ''; 21 | 22 | # new row template for '+' 23 | $pg .= ''; 24 | $pg .= ''; 25 | $pg .= ''; 28 | $pg .= ''; 31 | $pg .= ''; 34 | $pg .= ''; 37 | $pg .= "\n"; 38 | 39 | $ans = userSettings($user); 40 | 41 | $offset = 0; 42 | $count = 0; 43 | if ($ans['STATUS'] == 'ok') 44 | { 45 | $pg .= ''; 46 | if (isset($ans['limit'])) 47 | $limit = $ans['limit']; 48 | else 49 | $limit = 1; 50 | $count = $ans['rows']; 51 | # this will output any DB rows > limit but DB update will ignore extras 52 | for ($i = 0; $i < $count; $i++) 53 | { 54 | if ((($offset) % 2) == 0) 55 | $row = 'even'; 56 | else 57 | $row = 'odd'; 58 | 59 | $pg .= ""; 60 | $addr = $ans['addr:'.$i]; 61 | $pg .= ''; 62 | $pg .= ''; 65 | $nam = htmlspecialchars($ans['payname:'.$i]); 66 | $pg .= ''; 69 | $ratio = intval($ans['ratio:'.$i]); 70 | $pg .= ''; 73 | $pg .= ''; 76 | $pg .= "\n"; 77 | 78 | $offset++; 79 | } 80 | if ($offset < $limit) { 81 | if ((($offset++) % 2) == 0) 82 | $row = 'even'; 83 | else 84 | $row = 'odd'; 85 | $pg .= ""; 88 | } 89 | 90 | $pg .= ''; 91 | if ((($offset++) % 2) == 0) 92 | $row = 'even'; 93 | else 94 | $row = 'odd'; 95 | $pg .= ""; 96 | $pg .= ''; 97 | $pg .= ''; 98 | $pg .= ''; 99 | $pg .= ''; 100 | 101 | if ((($offset++) % 2) == 0) 102 | $row = 'even'; 103 | else 104 | $row = 'odd'; 105 | $pg .= ""; 106 | $pg .= ''; 107 | $pg .= ''; 108 | $pg .= ''; 110 | $pg .= ''; 111 | 112 | $pg .= ''; 116 | } 117 | $pg .= "
#AddressIDRatio%
'; 26 | $pg .= ""; 27 | $pg .= ''; 29 | $pg .= ""; 30 | $pg .= ''; 32 | $pg .= ""; 33 | $pg .= ''; 35 | $pg .= "0.00%"; 36 | $pg .= '
'.($i+1).''; 63 | $pg .= ""; 64 | $pg .= ''; 67 | $pg .= ""; 68 | $pg .= ''; 71 | $pg .= ""; 72 | $pg .= ''; 74 | $pg .= "%"; 75 | $pg .= '
"; 86 | $pg .= ""; 87 | $pg .= "limit $limit
 Password: 
 *2nd Authentication:'; 109 | $pg .= '  
'; 113 | $pg .= "*Leave blank if you haven't enabled it
"; 114 | $pg .= 'You must enter your password to save changes
'; 115 | $pg .= 'A ratio of 0, will remove the address from the payouts
\n"; 118 | 119 | # TODO - adrw() update the odd/even class for the new row and rows below it 120 | # TODO - move the js functions into inc.php 121 | $pg .= ""; 139 | 140 | return $pg; 141 | } 142 | # 143 | function doaddrmgt($data, $user) 144 | { 145 | $err = ''; 146 | $OK = getparam('OK', false); 147 | $count = getparam('rows', false); 148 | $pass = getparam('pass', false); 149 | $twofa = getparam('2fa', false); 150 | $mfail = false; 151 | if ($OK == 'Save' && !nuem($count) && !nuem($pass)) 152 | { 153 | if ($count > 0 && $count < 1000) 154 | { 155 | $mfail = true; 156 | $addrarr = array(); 157 | for ($i = 0; $i < $count; $i++) 158 | { 159 | $addr = getparam('addr:'.$i, false); 160 | $nam = getparam('payname:'.$i, false); 161 | if (nuem($nam)) 162 | $nam = ''; 163 | $ratio = getparam('ratio:'.$i, false); 164 | if (!nuem($addr) && !nuem($ratio)) 165 | $addrarr[] = array('addr' => trim($addr), 'payname' => trim($nam), 'ratio' => $ratio); 166 | } 167 | $ans = userSettings($user, null, $addrarr, $pass, $twofa); 168 | if ($ans['STATUS'] != 'ok') 169 | $err = $ans['ERROR']; 170 | else 171 | { 172 | $ans = userSettings($user); 173 | if ($ans['STATUS'] != 'ok') 174 | goto meh; 175 | if (isset($ans['email'])) 176 | $email = $ans['email']; 177 | else 178 | goto meh; 179 | 180 | $emailinfo = getOpts($user, emailOptList()); 181 | if ($emailinfo['STATUS'] != 'ok') 182 | goto meh; 183 | else 184 | payoutAddressChanged($email, zeip(), $emailinfo); 185 | } 186 | $mfail = false; 187 | } 188 | } 189 | meh: 190 | if ($mfail == true) 191 | { 192 | if ($err != '') 193 | $err .= '
'; 194 | $err .= 'An error occurred, check your details below'; 195 | } 196 | 197 | $pg = addrmgtuser($data, $user, $err); 198 | 199 | return $pg; 200 | } 201 | # 202 | function show_addrmgt($info, $page, $menu, $name, $user) 203 | { 204 | gopage($info, NULL, 'doaddrmgt', $page, $menu, $name, $user); 205 | } 206 | # 207 | ?> 208 | -------------------------------------------------------------------------------- /pool/page_allwork.php: -------------------------------------------------------------------------------- 1 | All Workers'; 8 | 9 | $pg .= worktable(); 10 | 11 | $totshare = 0; 12 | $totdiff = 0; 13 | $totshrate = 0; 14 | $totinvalid = 0; 15 | $totrate = 0; 16 | $offset = 0; 17 | $blockacc = 0; 18 | $blockreward = 0; 19 | $instances = 0; 20 | 21 | $pg .= worktitle($data, $user); 22 | $pg .= ''; 23 | $ans = getAllUsers($user); 24 | if ($ans['STATUS'] == 'ok') 25 | { 26 | $count = $ans['rows']; 27 | $title = NULL; 28 | for ($i = 0; $i < $count; $i++) 29 | { 30 | $pg .= workuser($data, $ans['username:'.$i], 31 | $offset, $totshare, $totdiff, 32 | $totshrate, $totinvalid, $totrate, 33 | $blockacc, $blockreward, 34 | 3600, false, false, 35 | $title, $instances); 36 | } 37 | } 38 | $pg .= ''; 39 | $pg .= worktotal($offset, $totshare, $totdiff, $totshrate, $totinvalid, 40 | $totrate, $blockacc, $blockreward, $instances); 41 | 42 | $pg .= "\n"; 43 | 44 | return $pg; 45 | } 46 | # 47 | function show_allwork($info, $page, $menu, $name, $user) 48 | { 49 | gopage($info, NULL, 'doallwork', $page, $menu, $name, $user); 50 | } 51 | # 52 | ?> 53 | -------------------------------------------------------------------------------- /pool/page_api.php: -------------------------------------------------------------------------------- 1 | 103 | -------------------------------------------------------------------------------- /pool/page_ckp.php: -------------------------------------------------------------------------------- 1 | 99999999) 9 | $b4 = ''; 10 | else if ($num > 9999999) 11 | $b4 = ''; 12 | if ($b4 != '') 13 | $af = ''; 14 | return $b4.$fmt.$af; 15 | } 16 | # 17 | function dockp($data, $user) 18 | { 19 | $pg = '

CKDB

'; 20 | 21 | $msg = msgEncode('stats', 'stats', array(), $user); 22 | $rep = sendsockreply('stats', $msg); 23 | if ($rep == false) 24 | $ans = array(); 25 | else 26 | $ans = repDecode($rep); 27 | 28 | addSort(); 29 | $r = "input type=radio name=srt onclick=\"sott('ckpsrt',this);\""; 30 | $pg .= 'TotalRAM: '.stnum($ans['totalram']).'
'; 31 | $pg .= "\n"; 32 | $pg .= ''; 33 | $pg .= ""; 34 | $pg .= ''; 35 | $pg .= ""; 36 | $pg .= ""; 37 | $pg .= ""; 38 | $pg .= ""; 39 | $pg .= ""; 40 | $pg .= ""; 41 | $pg .= "\n"; 42 | if ($ans['STATUS'] == 'ok') 43 | { 44 | $pg .= ''; 45 | $count = $ans['rows']; 46 | for ($i = 0; $i < $count; $i++) 47 | { 48 | if (($i % 2) == 0) 49 | $row = 'even'; 50 | else 51 | $row = 'odd'; 52 | 53 | $pg .= ""; 54 | $pg .= "'; 55 | $pg .= ''; 56 | $pg .= "'; 57 | $pg .= "'; 58 | $pg .= "'; 59 | $pg .= "'; 60 | $pg .= "'; 61 | $pg .= "'; 62 | $pg .= "\n"; 63 | } 64 | $pg .= ''; 65 | } 66 | $pg .= "
Name:<$r id=srtname data-sf=s0>Initial<$r id=srtalloc data-sf=r2>:Alloc<$r id=srtstore data-sf=r3>:In Store<$r id=srtram data-sf=r4>:RAM<$r id=srtram2 data-sf=r5>:RAM2<$r id=srtcull data-sf=r6>:Cull<$r id=srtlim data-sf=r7>:Limit
".$ans['name:'.$i].''.stnum($ans['initial:'.$i]).'".stnum($ans['allocated:'.$i]).'".stnum($ans['instore:'.$i]).'".stnum($ans['ram:'.$i]).'".stnum($ans['ram2:'.$i]).'".stnum($ans['cull:'.$i]).'".stnum($ans['cull_limit:'.$i]).'
\n"; 67 | $pg .= "\n"; 69 | 70 | return $pg; 71 | } 72 | # 73 | function show_ckp($info, $page, $menu, $name, $user) 74 | { 75 | gopage($info, NULL, 'dockp', $page, $menu, $name, $user); 76 | } 77 | # 78 | ?> 79 | -------------------------------------------------------------------------------- /pool/page_events.php: -------------------------------------------------------------------------------- 1 | Event Information'; 6 | 7 | $wh = getparam('what', false); 8 | if (nuem($wh)) 9 | $wh = ''; 10 | 11 | $pg = '
'.makeForm('events')." 12 | What: 13 |   14 | "; 15 | 16 | if ($wh == 'settings') 17 | { 18 | $ans = eventCmd($user, array('action' => 'settings')); 19 | 20 | $other = array('event_limits_hash_lifetime', 21 | 'ovent_limits_ipc_factor'); 22 | 23 | $pg .= "

\n"; 24 | $pg .= ''; 25 | $pg .= ''; 26 | $pg .= ''; 27 | $pg .= ''; 28 | $pg .= "\n"; 29 | 30 | if ($ans['STATUS'] == 'ok') 31 | { 32 | $pg .= ''; 33 | $i = 0; 34 | foreach ($other as $name) 35 | { 36 | if (($i % 2) == 0) 37 | $row = 'even'; 38 | else 39 | $row = 'odd'; 40 | 41 | $i++; 42 | $pg .= ""; 43 | $pg .= ""; 44 | $pg .= ""; 45 | $pg .= ''; 46 | $pg .= "\n"; 47 | } 48 | $pg .= ''; 49 | } 50 | $pg .= "
#NameValue
$i$name'.$ans[$name].'
\n"; 51 | 52 | $flds = array('enabled' => 'Ena', 53 | 'user_low_time' => 'UserLo', 54 | 'user_low_time_limit' => 'UserLoLim', 55 | 'user_hi_time' => 'UserHi', 56 | 'user_hi_time_limit' => 'UserHiLim', 57 | 'ip_low_time' => 'IPLo', 58 | 'ip_low_time_limit' => 'IPLoLim', 59 | 'ip_hi_time' => 'IPHi', 60 | 'ip_hi_time_limit' => 'IPHiLim', 61 | 'lifetime' => 'Life'); 62 | 63 | $pg .= "

\n"; 64 | $pg .= ''; 65 | $pg .= ''; 66 | $pg .= ''; 67 | foreach ($flds as $row => $nam) 68 | $pg .= ""; 69 | $pg .= "\n"; 70 | 71 | if ($ans['STATUS'] == 'ok') 72 | { 73 | $pg .= ''; 74 | $names = array(); 75 | foreach ($ans as $name => $value) 76 | { 77 | $ex = explode('_', $name, 2); 78 | if (count($ex) == 2 && isset($flds[$ex[1]])) 79 | $names[$ex[0]] = 1; 80 | } 81 | $i = 0; 82 | foreach ($names as $name => $one) 83 | { 84 | if (($i % 2) == 0) 85 | $row = 'even'; 86 | else 87 | $row = 'odd'; 88 | 89 | $i++; 90 | $pg .= ""; 91 | $pg .= ""; 92 | $pg .= ""; 93 | foreach ($flds as $fld => $nam) 94 | $pg .= ''; 95 | $pg .= "\n"; 96 | } 97 | $pg .= ''; 98 | } 99 | $pg .= "
#Name$nam
$i$name'.$ans[$name.'_'.$fld].'
\n"; 100 | } 101 | 102 | if ($wh == 'all' || $wh == 'user' || $wh == 'ip' || $wh == 'ipc' || $wh == 'hash') 103 | { 104 | $ans = eventCmd($user, array('action' => 'events', 'list' => $wh)); 105 | 106 | $pg .= "

\n"; 107 | $pg .= ''; 108 | $pg .= ''; 109 | $pg .= ''; 110 | $pg .= ''; 111 | $pg .= ''; 112 | $pg .= ''; 113 | $pg .= ''; 114 | $pg .= ''; 115 | $pg .= ''; 116 | $pg .= ''; 117 | $pg .= "\n"; 118 | 119 | if ($ans['STATUS'] == 'ok') 120 | { 121 | $pg .= ''; 122 | $count = $ans['rows']; 123 | for ($i = 0; $i < $count; $i++) 124 | { 125 | if (($i % 2) == 0) 126 | $row = 'even'; 127 | else 128 | $row = 'odd'; 129 | 130 | $j = $i+1; 131 | $pg .= ""; 132 | $pg .= ""; 133 | $pg .= ''; 134 | $pg .= ''; 135 | $pg .= ''; 136 | $pg .= ''; 137 | $pg .= ''; 138 | $pg .= ''; 139 | $pg .= ''; 140 | $pg .= ''; 141 | $pg .= "\n"; 142 | } 143 | $pg .= ''; 144 | } 145 | $pg .= "
#ListIDIDNameUserIPIPcHashUTC
$j'.$ans['list:'.$i].''.$ans['id:'.$i].''.$ans['idname:'.$i].''.$ans['user:'.$i].''.isans($ans, 'ip:'.$i).''.isans($ans, 'ipc:'.$i).''.isans($ans, 'hash:'.$i).''.gmdate('j/M H:i:s',$ans['createdate:'.$i]).'
\n"; 146 | } 147 | 148 | if ($wh == 'ovents') 149 | { 150 | $ans = eventCmd($user, array('action' => 'ovents')); 151 | 152 | $pg .= "

\n"; 153 | $pg .= ''; 154 | $pg .= ''; 155 | $pg .= ''; 156 | $pg .= ''; 157 | $pg .= ''; 158 | $pg .= ''; 159 | $pg .= ''; 160 | $pg .= "\n"; 161 | 162 | if ($ans['STATUS'] == 'ok') 163 | { 164 | $pg .= ''; 165 | $count = $ans['rows']; 166 | for ($i = 0; $i < $count; $i++) 167 | { 168 | if (($i % 2) == 0) 169 | $row = 'even'; 170 | else 171 | $row = 'odd'; 172 | 173 | $j = $i+1; 174 | $pg .= ""; 175 | $pg .= ""; 176 | $pg .= ''; 177 | $pg .= ''; 178 | $pg .= ''; 179 | $pg .= ''; 180 | $co = ''; 181 | for ($k = 0; $k < 60; $k++) 182 | { 183 | if ($k < 10) 184 | $min = '0' . $k; 185 | else 186 | $min = $k; 187 | if (isset($ans["min$min:$i"])) 188 | { 189 | if ($co != '') 190 | $co .= ' '; 191 | $co .= "$min=".$ans["min$min:$i"]; 192 | } 193 | } 194 | $pg .= ""; 195 | $pg .= "\n"; 196 | } 197 | $pg .= ''; 198 | } 199 | $pg .= "
#KeyIDIDNameHour UTCCount
$j'.$ans['key:'.$i].''.$ans['id:'.$i].''.$ans['idname:'.$i].''.gmdate('j/M H:i:s',$ans['hour:'.$i]*3600).'$co
\n"; 200 | } 201 | 202 | return $pg; 203 | } 204 | # 205 | function show_events($info, $page, $menu, $name, $user) 206 | { 207 | gopage($info, NULL, 'doevents', $page, $menu, $name, $user); 208 | } 209 | # 210 | ?> 211 | -------------------------------------------------------------------------------- /pool/page_help.php: -------------------------------------------------------------------------------- 1 | HelplessHelpless'; 6 | } 7 | # 8 | function show_help($info, $page, $menu, $name, $user) 9 | { 10 | gopage($info, NULL, 'dohelp', $page, $menu, $name, $user); 11 | } 12 | # 13 | ?> 14 | -------------------------------------------------------------------------------- /pool/page_index.php: -------------------------------------------------------------------------------- 1 | 11 | -------------------------------------------------------------------------------- /pool/page_ips.php: -------------------------------------------------------------------------------- 1 | Event IP Information'; 6 | 7 | $ans = eventCmd($user, array('action' => 'ips')); 8 | 9 | $pg .= "\n"; 10 | $pg .= ''; 11 | $pg .= ''; 12 | $pg .= ''; 13 | $pg .= ''; 14 | $pg .= ''; 15 | $pg .= ''; 16 | $pg .= ''; 17 | $pg .= ''; 18 | $pg .= ''; 19 | $pg .= ''; 20 | $pg .= ''; 21 | $pg .= "\n"; 22 | if ($ans['STATUS'] == 'ok') 23 | { 24 | $now = $ans['STAMP']; 25 | $pg .= ''; 26 | $count = $ans['rows']; 27 | for ($i = 0; $i < $count; $i++) 28 | { 29 | if (($i % 2) == 0) 30 | $row = 'even'; 31 | else 32 | $row = 'odd'; 33 | 34 | $j = $i+1; 35 | $pg .= ""; 36 | $pg .= ""; 37 | $pg .= ''; 38 | $pg .= ''; 39 | $pg .= ''; 40 | $pg .= ''; 41 | $pg .= ''; 42 | $exp = $ans['lifetime:'.$i]; 43 | if ($exp == 0) 44 | $dxp = '∞'; 45 | else 46 | { 47 | $exp += $ans['createdate:'.$i]; 48 | if ($exp <= $now) 49 | $dxp = 'Exp'; 50 | else 51 | { 52 | $exp -= $now; 53 | $dxp = $exp . 's'; 54 | } 55 | } 56 | $pg .= ''; 57 | $pg .= ''; 58 | $pg .= ''; 59 | $pg .= ''; 60 | $pg .= "\n"; 61 | } 62 | $pg .= ''; 63 | } 64 | $pg .= "
#GroupIPNameIs?LifetimeLeftLogDescUTC
$j'.$ans['group:'.$i].''.$ans['ip:'.$i].''.$ans['eventname:'.$i].''.$ans['is_event:'.$i].''.$ans['lifetime:'.$i].''.$dxp.''.$ans['log:'.$i].''.$ans['description:'.$i].''.gmdate('j/M H:i:s',$ans['createdate:'.$i]).'
\n"; 65 | 66 | return $pg; 67 | } 68 | # 69 | function show_ips($info, $page, $menu, $name, $user) 70 | { 71 | gopage($info, NULL, 'doips', $page, $menu, $name, $user); 72 | } 73 | # 74 | ?> 75 | -------------------------------------------------------------------------------- /pool/page_luck.php: -------------------------------------------------------------------------------- 1 | s){xmin=s}if(xmaxymax)ymax=lk} 13 | } 14 | if(ymax>500){ymax=500} 15 | ghg(c,xmax-xmin); 16 | ggr(c,0.90,0.90,'Luck%',rows,xmin,xmax,ymin,ymax,d,'seq:','vx:','luck:',tlk,w,cols,null)} 17 | c={}; 18 | function dodrw(data,cbx){if(hasCan()){gdrw(c,sep(data),cbx)}} 19 | function gact(t){if(t.checked){scnv(t.id,1)}else{scnv(t.id,0)}godrw(0)}"; 20 | return $g; 21 | } 22 | # 23 | function doluck($data, $user) 24 | { 25 | global $fld_sep, $val_sep; 26 | 27 | if ($user === null) 28 | $ans = getBlocks('Anon'); 29 | else 30 | $ans = getBlocks($user); 31 | 32 | $pg = '

Pool Avg Block Luck History


'; 33 | 34 | if ($ans['STATUS'] == 'ok' and isset($ans['rows']) and $ans['rows'] > 0) 35 | { 36 | $count = $ans['s_rows'] - 1; 37 | $av = number_format(100 * $ans['s_luck:'.$count], 3); 38 | 39 | for ($i = 0; $i < $count; $i++) 40 | // This also defines how many lines there are 41 | $cols = array('#0000c0', '#00dd00', '#e06020', '#b020e0'); 42 | $nams = array(1, 5, 15, 25); 43 | $nc = count($cols); 44 | 45 | addGBase(); 46 | $cbx = array('skey' => 'block key', 'slines' => 'block lines', 47 | 'tkey' => 'time key', 'tlines' => 'time lines', 48 | 'over' => 'key overlap', 'smooth' => 'smooth', 49 | 'utc' => 'utc'); 50 | $xon = array('skey' => 1, 'tkey' => 1, 'tlines' => 1, 'utc' => 1); 51 | 52 | $pg .= '
'; 53 | foreach ($cbx as $nam => $txt) 54 | { 55 | $pg .= ' '; 56 | $pg .= ""; 57 | $pg .= "$txt "; 58 | } 59 | $pg .= '
'; 60 | 61 | $i = 1; 62 | $datacols = ''; 63 | foreach ($cols as $col) 64 | { 65 | if ($i != 1) 66 | $pg .= '  '; 67 | if ($i == 2 || $i == 4) 68 | $chk = ' checked'; 69 | else 70 | $chk = ''; 71 | $pg .= ""; 72 | $pg .= ": "; 73 | if ($nams[$i-1] == 1) 74 | $avs = ''; 75 | else 76 | $avs = ' Avg'; 77 | $pg .= $nams[$i-1]." Block Luck$avs"; 78 | 79 | if ($i > 1) 80 | $datacols .= ','; 81 | $datacols .= $col; 82 | $i++; 83 | } 84 | 85 | $pg .= '
'; 86 | $pg .= '
'; 87 | $pg .= 'A graph will show here if your browser supports html5/canvas'; 88 | $pg .= "
\n"; 89 | 90 | $count = $ans['rows']; 91 | # add the orphan/reject ratios to the subsequent blocks 92 | $dr = 0; 93 | for ($i = $count-1; $i >= 0; $i--) 94 | { 95 | $conf = $ans["confirmed:$i"]; 96 | if ($conf == '1' or $conf == 'F') 97 | { 98 | $ans["diffratio:$i"] += $dr; 99 | $dr = 0; 100 | } 101 | else 102 | $dr += $ans["diffratio:$i"]; 103 | } 104 | 105 | # $ans blocks are 0->rows-1 highest->lowest 106 | # build an array of valid block offsets (reversed lowest->highest) 107 | $off = array(); 108 | for ($i = $count-1; $i >= 0; $i--) 109 | { 110 | $conf = $ans["confirmed:$i"]; 111 | if ($conf == '1' or $conf == 'F') 112 | $off[] = $i; 113 | } 114 | 115 | $data = ''; 116 | $count = count($off); 117 | $avg = 0; 118 | # each valid block offset number (lowest->highest) 119 | for ($j = 0; $j < $count; $j++) 120 | { 121 | $i = $off[$j]; 122 | 123 | $data .= $fld_sep . "height:$j$val_sep"; 124 | $data .= $ans["height:$i"]; 125 | $data .= $fld_sep . "seq:$j$val_sep"; 126 | $data .= $ans["seq:$i"]; 127 | $data .= $fld_sep . "firstcreatedate:$j$val_sep"; 128 | $data .= $ans["firstcreatedate:$i"]; 129 | $data .= $fld_sep . "0_luck:$j$val_sep"; 130 | $data .= number_format(100 * $ans['luck:'.$i], 3); 131 | 132 | $avg += $ans["diffratio:$i"]; 133 | 134 | $l5c = $l15c = $l25c = 1; 135 | $l5 = $l15 = $l25 = $ans['diffratio:'.$i]; 136 | 137 | # +/- offset from j (12 is the max for 25) 138 | for ($k = 1; $k <= 12; $k++) 139 | { 140 | # we want the (n-1)/2 on each side of the offset number 141 | foreach (array(-1, 1) as $s) 142 | { 143 | $o = $j + ($s * $k); 144 | if (0 <= $o && $o < $count) 145 | { 146 | $dr = $ans['diffratio:'.$off[$o]]; 147 | if ($k <= 2) # (5-1)/2 148 | { 149 | $l5 += $dr; 150 | $l5c++; 151 | } 152 | if ($k < 7) # (15-1)/2 153 | { 154 | $l15 += $dr; 155 | $l15c++; 156 | } 157 | $l25 += $dr; 158 | $l25c++; 159 | } 160 | } 161 | } 162 | # luck is 1/(mean diffratio) 163 | $data .= $fld_sep . "1_luck:$j$val_sep"; 164 | $data .= number_format(100 * $l5c / $l5, 3); 165 | $data .= $fld_sep . "2_luck:$j$val_sep"; 166 | $data .= number_format(100 * $l15c / $l15, 3); 167 | $data .= $fld_sep . "3_luck:$j$val_sep"; 168 | $data .= number_format(100 * $l25c / $l25, 3); 169 | } 170 | $data .= $fld_sep . 'rows' . $val_sep . $count; 171 | $data .= $fld_sep . 'arp' . $val_sep . ',0_,1_,2_,3_'; 172 | $data .= $fld_sep . 'cols' . $val_sep . $datacols; 173 | 174 | $pg .= "\n"; 187 | } 188 | 189 | return $pg; 190 | } 191 | # 192 | function show_luck($info, $page, $menu, $name, $user) 193 | { 194 | gopage($info, NULL, 'doluck', $page, $menu, $name, $user); 195 | } 196 | # 197 | ?> 198 | -------------------------------------------------------------------------------- /pool/page_mpayouts.php: -------------------------------------------------------------------------------- 1 | Mining Rewards'; 6 | 7 | $ans = getMPayouts($user); 8 | 9 | $pg .= "The rewards you've earned for each block the pool has found.
"; 10 | $pg .= 'See the '; 11 | $pg .= makeLink('payments'); 12 | $pg .= "Payments page for the payments you've been sent.

"; 13 | 14 | $pg .= "\n"; 15 | $pg .= ''; 16 | $pg .= ''; 17 | $pg .= ''; 18 | $pg .= ''; 19 | $pg .= ''; 20 | $pg .= ''; 21 | $pg .= ''; 22 | $pg .= ''; 23 | $pg .= ''; 24 | $pg .= ''; 25 | $pg .= ''; 26 | $pg .= "\n"; 27 | if ($ans['STATUS'] == 'ok') 28 | { 29 | $pg .= ''; 30 | $totamt = 0; 31 | $count = $ans['rows']; 32 | for ($i = 0; $i < $count; $i++) 33 | { 34 | if (($i % 2) == 0) 35 | $row = 'even'; 36 | else 37 | $row = 'odd'; 38 | 39 | $pg .= ""; 40 | $pg .= ''; 41 | $pg .= ''; 42 | $pg .= ''; 43 | $diffused = $ans['diffused:'.$i]; 44 | $pg .= ''; 45 | $elapsed = $ans['elapsed:'.$i]; 46 | $pg .= ''; 47 | $phr = $diffused * pow(2,32) / $elapsed; 48 | $pg .= ''; 49 | $diffacc = $ans['diffacc:'.$i]; 50 | $ypct = $diffacc * 100 / $diffused; 51 | $pg .= ''; 52 | $pg .= ''; 53 | $hr = $diffacc * pow(2,32) / $elapsed; 54 | $pg .= ''; 55 | $amount = $ans['amount:'.$i]; 56 | $totamt += $amount; 57 | $pg .= ''; 58 | $pg .= "\n"; 59 | } 60 | $pg .= ''; 61 | if ($count > 1) 62 | { 63 | if (($i % 2) == 0) 64 | $row = 'even'; 65 | else 66 | $row = 'odd'; 67 | 68 | $pg .= ""; 69 | $pg .= ''; 70 | $pg .= ''; 71 | $pg .= ''; 72 | $pg .= "\n"; 73 | } 74 | } 75 | $pg .= "
BlockBlock UTCMiner RewardN DiffN RangePool N AvgYour %Your N DiffYour N AvgYour BTC
'.$ans['height:'.$i].''.gmdate('j/M H:i',$ans['blockcreatedate:'.$i]).''.btcfmt($ans['minerreward:'.$i]).''.difffmt($diffused).''.howmanyhrs($elapsed).''.siprefmt($phr).'Hs'.number_format($ypct, 2).'%'.difffmt($diffacc).''.dsprate($hr).''.btcfmt($amount).'
Total:'.btcfmt($totamt).'
\n"; 76 | 77 | return $pg; 78 | } 79 | # 80 | function show_mpayouts($info, $page, $menu, $name, $user) 81 | { 82 | gopage($info, NULL, 'dompayouts', $page, $menu, $name, $user); 83 | } 84 | # 85 | ?> 86 | -------------------------------------------------------------------------------- /pool/page_payments.php: -------------------------------------------------------------------------------- 1 | Payments'; 19 | $pg .= "The payment transactions on $btcn are here:"; 20 | $pg .= " BTCa,"; 21 | $pg .= " BTCb,"; 22 | $pg .= " BTCc,"; 23 | $pg .= " BTCd and"; 24 | $pg .= " BTCe
"; 25 | $pg .= "The payments below don't yet show when they have been sent.
"; 26 | $pg .= "Dust payments below 0.00010000 BTC are not sent out yet.

"; 27 | 28 | $ans = getPayments($user); 29 | 30 | $pg .= "\n"; 31 | $pg .= ''; 32 | $pg .= ''; 33 | $pg .= ''; 34 | $pg .= ''; 35 | $pg .= ''; 36 | $pg .= ''; 37 | $pg .= "\n"; 38 | if ($ans['STATUS'] == 'ok') 39 | { 40 | $pg .= ''; 41 | $all = array(); 42 | $count = $ans['rows']; 43 | for ($i = 0; $i < $count; $i++) 44 | { 45 | $all[] = array('payoutid' => $ans['payoutid:'.$i], 46 | 'height' => $ans['height:'.$i], 47 | 'payaddress' => $ans['payaddress:'.$i], 48 | 'amount' => $ans['amount:'.$i], 49 | 'paydate' => $ans['paydate:'.$i]); 50 | } 51 | usort($all, 'sortheight'); 52 | $hasdust = false; 53 | for ($i = 0; $i < $count; $i++) 54 | { 55 | if (($i % 2) == 0) 56 | $row = 'even'; 57 | else 58 | $row = 'odd'; 59 | 60 | $pg .= ""; 61 | $pg .= ''; 62 | $pg .= ''; 63 | $pg .= ''; 64 | $amount = $all[$i]['amount']; 65 | if ($amount < '10000') 66 | { 67 | $dust = '*'; 68 | $hasdust = true; 69 | } 70 | else 71 | $dust = ' '; 72 | $pg .= ''; 73 | $pg .= ""; 74 | $pg .= "\n"; 75 | } 76 | $pg .= ''; 77 | if ($hasdust === true) 78 | { 79 | $pg .= ''; 83 | } 84 | } 85 | $pg .= "
BlockAddressStatusBTC
'.$all[$i]['height'].''.$all[$i]['payaddress'].' '.btcfmt($amount).'$dust
'; 80 | $pg .= '* '; 81 | $pg .= 'Dust payments are not automatically sent out'; 82 | $pg .= '
\n"; 86 | 87 | return $pg; 88 | } 89 | # 90 | function show_payments($info, $page, $menu, $name, $user) 91 | { 92 | gopage($info, NULL, 'dopayments', $page, $menu, $name, $user); 93 | } 94 | # 95 | ?> 96 | -------------------------------------------------------------------------------- /pool/page_payout.php: -------------------------------------------------------------------------------- 1 | $N
"; 7 | $ot = "1/$N"; 8 | $n = "${N}Nd"; 9 | $n1 = 'N'; 10 | $n1d = 'Nd'; 11 | $bc = '+101 Confirms'; 12 | $bm = 'Matured'; 13 | $nd = 0; 14 | if (isset($data['info']['currndiff'])) 15 | $nd = $data['info']['currndiff']; 16 | $nv = number_format($nd, 1); 17 | $nvx = ''.number_format($N*$nd, 1).''; 18 | $pd = $data['info']['p_hashrate24hr']; 19 | $hr = 'is ?'; 20 | $hrt = '?'; 21 | if ($pd != '?' && $pd != '' && $pd > 0) 22 | { 23 | $hr = 'for the last day is roughly '.siprefmt($pd,2).'Hs'; 24 | if ($nd > 0) 25 | $hrt = ''.howmanyhrs($nd * $N / ($pd / pow(2,32)), true, true).''; 26 | } 27 | 28 | $pg = "

Payouts

29 |
30 | 31 | What payout method does the pool use?

32 | We use PPL${n1}S (Pay Per Last $n1 Shares)

33 | PPL${n1}S means that when a block is found, the block reward is shared among the last $n1 shares that miners sent to the pool, up to when the block was found.
34 | The $n1 value the pool uses is $t times the network difficulty when the block is found - '$n'.

35 | 36 | How much of each block does the pool reward?

37 | Transaction fees are included in the miner reward.
38 | Pool fee is 0.9% of the total.

39 | 40 | PPL${n1}S acts like the reward 'ramps up' when you first start mining.
What actually happens?


41 | The $n means it takes that long to reward your shares.
42 | The ramp isn't missing rewards, it's delaying them to reduce variance.
43 | Each share is rewarded in all the blocks found in the $n after the share.
44 | That's simply how it reduces variance. Each share's reward is averaged out over the $n after it.
45 | The pool hash rate $hr which means the $n 'ramp' is roughly $hrt.

46 | 47 | Continue reading below for more detail about how it works:

48 | 49 | How do the PPL${n1}S payments work?

50 | The $n means the pool rewards $t times the expected number of shares, each time a block is found.
51 | So each share will be paid approximately $ot of it's expected value, in each block it gets a reward,
52 | but each share is also expected, on average, to be rewarded $t times in blocks found after the share is submitted to the pool.
53 | i.e. if pool luck was always 100% then each share is expected to be rewarded $t times.

54 | If pool luck is better than 100%, then the average share reward will be better than $t times.
55 | If pool luck is lower than 100%, then the average share reward will be less than $t times.

56 | 57 | What's a shift?

58 | When your miner sends shares to the pool, the shares are not stored individually, but rather summarised into shifts.
59 | Shifts are ~50min or less in length.
60 | Aproximately every 30s, the pool generates new work and sends that to all the miners.
61 | The pool also sends new work every time a block is found on the Bitcoin network.
62 | A shift summarises all the shares submitted to the pool for 100 work changes.
63 | However, when we find pool blocks, the current shift ends at the work in which the block was found
64 | and a new shift starts.
65 | A ckpool restart will also end the current shift and start a new shift.
66 | A network difficulty change will also end the current shift and start a new shift.

67 | 68 | So, what's the $n value?

69 | The current Bitcoin network value for $n1d is $nv and thus $n is $nvx
70 | Bitcoin adjusts the $n1d value every 2016 blocks, which is about every 2 weeks.

71 | When a block is found, the reward process counts back shifts until the total share difficulty included is $n.
72 | Since shares are summarised into shifts, it will include the full shift at the end of the range counting backwards,
73 | so it usually will be a bit more than $n.

74 | 75 | When are payments sent out?

76 | The block 'Status' must first reach '$bc' on the Blocks page, and then is flagged as '$bm', before the reward is distributed.
77 | The block reward is sent out manually soon after that.

78 | 79 |
"; 80 | return $pg; 81 | } 82 | # 83 | function show_payout($info, $page, $menu, $name, $user) 84 | { 85 | gopage($info, NULL, 'dopayout', $page, $menu, $name, $user); 86 | } 87 | # 88 | ?> 89 | -------------------------------------------------------------------------------- /pool/page_pblocks.php: -------------------------------------------------------------------------------- 1 | 16 | -------------------------------------------------------------------------------- /pool/page_percent.php: -------------------------------------------------------------------------------- 1 | '; 6 | $pg .= 'Address'; 7 | $pg .= 'ID'; 8 | $pg .= 'Shares'; 9 | $pg .= 'Diff'; 10 | $pg .= 'Invalid'; 11 | $pg .= 'Block %'; 12 | $pg .= 'Hash Rate'; 13 | $pg .= 'Ratio'; 14 | $pg .= 'Addr %'; 15 | $pg .= "\n"; 16 | return $pg; 17 | } 18 | # 19 | function perhashorder($a, $b) 20 | { 21 | return $b['payratio'] - $a['payratio']; 22 | } 23 | # 24 | function peruser($data, $user, &$offset, &$totshare, &$totdiff, 25 | &$totinvalid, &$totrate, &$blockacc, 26 | &$blockreward, $srt = false) 27 | { 28 | $ans = getPercents($user); 29 | 30 | $pg = ''; 31 | if ($ans['STATUS'] == 'ok') 32 | { 33 | $pg .= ''; 34 | if (isset($ans['blockacc'])) 35 | $blockacc = $ans['blockacc']; 36 | if (isset($ans['blockreward'])) 37 | $blockreward = $ans['blockreward']; 38 | $all = array(); 39 | $count = $ans['rows']; 40 | for ($i = 0; $i < $count; $i++) 41 | { 42 | $all[] = array('payaddress' => $ans['payaddress:'.$i], 43 | 'payratio' => $ans['payratio:'.$i], 44 | 'paypercent' => $ans['paypercent:'.$i], 45 | 'payname' => $ans['payname:'.$i], 46 | 'p_shareacc' => $ans['p_shareacc:'.$i], 47 | 'p_diffacc' => $ans['p_diffacc:'.$i], 48 | 'p_diffinv' => $ans['p_diffinv:'.$i], 49 | 'p_uhr' => $ans['p_hashrate5m:'.$i]); 50 | } 51 | 52 | if ($srt) 53 | usort($all, 'perhashorder'); 54 | 55 | for ($i = 0; $i < $count; $i++) 56 | { 57 | if ((($offset) % 2) == 0) 58 | $row = 'even'; 59 | else 60 | $row = 'odd'; 61 | 62 | $pg .= ""; 63 | $pg .= ''.$all[$i]['payaddress'].''; 64 | $pg .= ''.$all[$i]['payname'].''; 65 | 66 | $shareacc = number_format($all[$i]['p_shareacc'], 0); 67 | $totshare += $all[$i]['p_shareacc']; 68 | $diffacc = number_format($all[$i]['p_diffacc'], 0); 69 | $totdiff += $all[$i]['p_diffacc']; 70 | $pg .= "$shareacc"; 71 | $pg .= "$diffacc"; 72 | 73 | $dtot = $all[$i]['p_diffacc'] + $all[$i]['p_diffinv']; 74 | if ($dtot > 0) 75 | $rej = number_format(100.0 * $all[$i]['p_diffinv'] / $dtot, 3); 76 | else 77 | $rej = '0'; 78 | $totinvalid += $all[$i]['p_diffinv']; 79 | 80 | $pg .= "$rej%"; 81 | 82 | if ($blockacc <= 0) 83 | $blkpct = ' '; 84 | else 85 | $blkpct = number_format(100.0 * $all[$i]['p_diffacc'] / $blockacc, 3) . '%'; 86 | 87 | $pg .= "$blkpct"; 88 | 89 | $uhr = $all[$i]['p_uhr']; 90 | if ($uhr == '?') 91 | $uhr = '?GHs'; 92 | else 93 | { 94 | $totrate += $uhr; 95 | $uhr = dsprate($uhr); 96 | } 97 | $pg .= "$uhr"; 98 | 99 | $pg .= ''.$all[$i]['payratio'].''; 100 | $paypct = number_format($all[$i]['paypercent'], 3); 101 | $pg .= "$paypct%"; 102 | 103 | $pg .= "\n"; 104 | 105 | $offset++; 106 | } 107 | $pg .= ''; 108 | } 109 | return $pg; 110 | } 111 | # 112 | function pertotal($offset, $totshare, $totdiff, $totinvalid, $totrate, $blockacc, $blockreward) 113 | { 114 | $pg = ''; 115 | $totrate = dsprate($totrate); 116 | if (($offset % 2) == 0) 117 | $row = 'even'; 118 | else 119 | $row = 'odd'; 120 | $pg .= "Total:"; 121 | $pg .= " "; 122 | $shareacc = number_format($totshare, 0); 123 | $pg .= "$shareacc"; 124 | $diffacc = number_format($totdiff, 0); 125 | $pg .= "$diffacc"; 126 | $dtot = $totdiff + $totinvalid; 127 | if ($dtot > 0) 128 | $rej = number_format(100.0 * $totinvalid / $dtot, 3); 129 | else 130 | $rej = '0'; 131 | $pg .= "$rej%"; 132 | if ($blockacc <= 0) 133 | $blkpct = ' '; 134 | else 135 | $blkpct = number_format(100.0 * $totdiff / $blockacc, 3) . '%'; 136 | $pg .= "$blkpct"; 137 | $pg .= "$totrate"; 138 | $pg .= "\n"; 139 | return $pg; 140 | } 141 | # 142 | function dopercent($data, $user) 143 | { 144 | $pg = '

Address Percents

'; 145 | 146 | $pg .= "\n"; 147 | 148 | $totshare = 0; 149 | $totdiff = 0; 150 | $totinvalid = 0; 151 | $totrate = 0; 152 | $offset = 0; 153 | $blockacc = 0; 154 | $blockreward = 0; 155 | 156 | $pg .= pertitle($data, $user); 157 | $pg .= peruser($data, $user, $offset, $totshare, $totdiff, $totinvalid, 158 | $totrate, $blockacc, $blockreward, true); 159 | $pg .= pertotal($offset, $totshare, $totdiff, $totinvalid, $totrate, 160 | $blockacc, $blockreward); 161 | 162 | $pg .= "
\n"; 163 | 164 | return $pg; 165 | } 166 | # 167 | function show_percent($info, $page, $menu, $name, $user) 168 | { 169 | gopage($info, NULL, 'dopercent', $page, $menu, $name, $user); 170 | } 171 | # 172 | ?> 173 | -------------------------------------------------------------------------------- /pool/page_psperf.php: -------------------------------------------------------------------------------- 1 | s){xmin=s}if(xmaxths){ymin=ths}if(ths>ymax)ymax=ths} 13 | } 14 | for(var j=1;j=2000){ymin/=1000;ymax/=1000;tl='PH/s';for(var j=1;j 'shift key', 'slines' => 'shift lines', 51 | 'tkey' => 'time key', 'tlines' => 'time lines', 52 | 'over' => 'key overlap', 'smooth' => 'smooth', 53 | 'zerob' => 'zero based', 'utc' => 'utc'); 54 | $xon = array('skey' => 1, 'utc' => 1); 55 | if ($vlines === true) 56 | $xon['slines'] = 1; 57 | 58 | $pg .= "
"; 59 | foreach ($cbx as $nam => $txt) 60 | { 61 | $pg .= ' '; 62 | $pg .= ""; 63 | $pg .= "$txt "; 64 | } 65 | 66 | $pg .= '
'; 67 | $pg .= '
'; 68 | $pg .= 'A graph will show here if your browser supports html5/canvas'; 69 | $pg .= "
\n"; 70 | $data = str_replace(array("\\","'"), array("\\\\","\\'"), $ans['DATA']); 71 | $data .= $fld_sep . 'cols' . $val_sep . $datacols; 72 | $pg .= "\n"; 85 | } 86 | return $pg; 87 | } 88 | # 89 | function show_psperf($info, $page, $menu, $name, $user) 90 | { 91 | gopage($info, NULL, 'dopsperf', $page, $menu, $name, $user); 92 | } 93 | # 94 | ?> 95 | -------------------------------------------------------------------------------- /pool/page_reset.php: -------------------------------------------------------------------------------- 1 |
'; 8 | 9 | $pg .= '

Password Reset

'; 10 | if ($error !== null) 11 | $pg .= "
$error - please try again

"; 12 | $pg .= makeForm('reset'); 13 | $pg .= " 14 | 15 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 26 | 27 | 28 |
Enter a new password twice.
16 | " . passrequires() . " 17 |
Password:
Retype Password:
*2nd Authentication:

* 25 | Leave blank if you haven't enabled it
 
29 | "; 30 | 31 | $pg .= '
'; 32 | 33 | return $pg; 34 | } 35 | # 36 | function yok() 37 | { 38 | $pg = '

Password Reset

'; 39 | $pg .= '
Your password has been reset,'; 40 | $pg .= '
login with it on the Home page.'; 41 | return $pg; 42 | } 43 | # 44 | function resetfail() 45 | { 46 | if (isset($_SESSION['reset_user'])) 47 | unset($_SESSION['reset_user']); 48 | if (isset($_SESSION['reset_hash'])) 49 | unset($_SESSION['reset_hash']); 50 | if (isset($_SESSION['reset_email'])) 51 | unset($_SESSION['reset_email']); 52 | $pg = '

Reset Failed

'; 53 | $pg .= '
Try again from the Home page Register/Reset button later'; 54 | return $pg; 55 | } 56 | # 57 | function dbreset() 58 | { 59 | $user = $_SESSION['reset_user']; 60 | $hash = $_SESSION['reset_hash']; 61 | $email = $_SESSION['reset_email']; 62 | 63 | $pass = getparam('pass', true); 64 | $pass2 = getparam('pass2', true); 65 | $twofa = getparam('2fa', true); 66 | 67 | if (nuem($pass) || nuem($pass2)) 68 | return allow_reset('Enter both passwords'); 69 | 70 | if ($pass2 != $pass) 71 | return allow_reset("Passwords don't match"); 72 | 73 | if (safepass($pass) !== true) 74 | return allow_reset('Password is unsafe'); 75 | 76 | $ans = getAtts($user, 'KReset.str,KReset.dateexp'); 77 | if ($ans['STATUS'] != 'ok') 78 | return resetfail(); 79 | 80 | if (!isset($ans['KReset.dateexp']) || $ans['KReset.dateexp'] == 'Y') 81 | return resetfail(); 82 | 83 | if (!isset($ans['KReset.str']) || $ans['KReset.str'] != $hash) 84 | return resetfail(); 85 | 86 | $emailinfo = getOpts($user, emailOptList()); 87 | if ($emailinfo['STATUS'] != 'ok') 88 | syserror(); 89 | 90 | $ans = resetPass($user, $pass, $twofa); 91 | if ($ans['STATUS'] != 'ok') 92 | return resetfail(); 93 | 94 | unset($_SESSION['reset_user']); 95 | unset($_SESSION['reset_hash']); 96 | unset($_SESSION['reset_email']); 97 | 98 | $ans = expAtts($user, 'KReset'); 99 | 100 | $ok = passWasReset($email, zeip(), $emailinfo); 101 | 102 | return yok(); 103 | } 104 | # 105 | function doreset($data, $u) 106 | { 107 | // Slow this right down 108 | usleep(500000); 109 | 110 | if (isset($_SESSION['reset_user']) 111 | && isset($_SESSION['reset_hash']) 112 | && isset($_SESSION['reset_email'])) 113 | return dbreset(); 114 | 115 | $code = getparam('code', true); 116 | if (nuem($code)) 117 | return resetfail(); 118 | 119 | $codes = explode('_', $code, 2); 120 | 121 | if (sizeof($codes) != 2) 122 | return resetfail(); 123 | 124 | $userhex = $codes[0]; 125 | 126 | if (strlen($userhex) == 0 || strlen($userhex) % 2) 127 | return resetfail(); 128 | 129 | $user = loginStr(pack("H*" , $userhex)); 130 | 131 | $hash = preg_replace('/[^A-Fa-f0-9]/', '', $codes[1]); 132 | 133 | if (!nuem($user) && !nuem($hash)) 134 | { 135 | $ans = getAtts($user, 'KReset.str,KReset.dateexp'); 136 | if ($ans['STATUS'] != 'ok') 137 | return resetfail(); 138 | 139 | if (!isset($ans['KReset.dateexp']) || $ans['KReset.dateexp'] == 'Y') 140 | return resetfail(); 141 | 142 | if (!isset($ans['KReset.str']) || $ans['KReset.str'] != $hash) 143 | return resetfail(); 144 | 145 | $ans = userSettings($user); 146 | if ($ans['STATUS'] != 'ok') 147 | return resetfail(); 148 | 149 | if (!isset($ans['email'])) 150 | return resetfail(); 151 | 152 | $email = $ans['email']; 153 | 154 | $_SESSION['reset_user'] = $user; 155 | $_SESSION['reset_hash'] = $hash; 156 | $_SESSION['reset_email'] = $email; 157 | 158 | return allow_reset(null); 159 | } 160 | return resetfail(); 161 | } 162 | # 163 | function show_reset($info, $page, $menu, $name, $u) 164 | { 165 | gopage($info, array(), 'doreset', $page, $menu, $name, $u, true, true, false); 166 | } 167 | # 168 | ?> 169 | -------------------------------------------------------------------------------- /pool/page_settings.php: -------------------------------------------------------------------------------- 1 | Account Settings'; 8 | 9 | if ($err != '') 10 | $pg .= "$err

"; 11 | 12 | $pg .= ''; 13 | $pg .= ''; 46 | $pg .= ''; 80 | $pg .= ''; 117 | $pg .= '
'; 14 | 15 | $_SESSION['old_set_email'] = $email; 16 | 17 | $pg .= makeForm('settings'); 18 | $pg .= ''; 19 | $pg .= ''; 22 | $pg .= ''; 27 | $pg .= ''; 32 | $pg .= ''; 37 | $pg .= ''; 40 | $pg .= ''; 43 | $pg .= '
'; 20 | $pg .= 'To change your email, enter a new email address and your password'; 21 | $pg .= '
'; 23 | $pg .= 'EMail:'; 24 | $pg .= ''; 25 | $pg .= ""; 26 | $pg .= '
'; 28 | $pg .= 'Password:'; 29 | $pg .= ''; 30 | $pg .= ''; 31 | $pg .= '
'; 33 | $pg .= '*2nd Authentication:'; 34 | $pg .= ''; 35 | $pg .= ''; 36 | $pg .= '
'; 38 | $pg .= "*Leave blank if you haven't enabled it"; 39 | $pg .= '
'; 41 | $pg .= 'Change: '; 42 | $pg .= '
'; 44 | 45 | $pg .= '
'; 47 | 48 | if (!isset($data['info']['u_multiaddr'])) 49 | { 50 | $pg .= makeForm('settings'); 51 | $pg .= ''; 52 | $pg .= ''; 56 | $pg .= ''; 61 | $pg .= ''; 66 | $pg .= ''; 71 | $pg .= ''; 74 | $pg .= ''; 77 | $pg .= '
'; 53 | $pg .= 'To change your payout address, enter a new address and your password.
'; 54 | $pg .= 'A payout address can only ever be set to one account'; 55 | $pg .= '
'; 57 | $pg .= 'BTC Address:'; 58 | $pg .= ''; 59 | $pg .= ""; 60 | $pg .= '
'; 62 | $pg .= 'Password:'; 63 | $pg .= ''; 64 | $pg .= ''; 65 | $pg .= '
'; 67 | $pg .= '*2nd Authentication:'; 68 | $pg .= ''; 69 | $pg .= ''; 70 | $pg .= '
'; 72 | $pg .= "*Leave blank if you haven't enabled it"; 73 | $pg .= '
'; 75 | $pg .= 'Change: '; 76 | $pg .= '
'; 78 | 79 | $pg .= '
'; 81 | } 82 | 83 | $pg .= makeForm('settings'); 84 | $pg .= ''; 85 | $pg .= ''; 88 | $pg .= ''; 93 | $pg .= ''; 98 | $pg .= ''; 103 | $pg .= ''; 108 | $pg .= ''; 111 | $pg .= ''; 114 | $pg .= '
'; 86 | $pg .= 'To change your password, enter your old password and new password twice'; 87 | $pg .= '
'; 89 | $pg .= 'Old Password:'; 90 | $pg .= ''; 91 | $pg .= ""; 92 | $pg .= '
'; 94 | $pg .= 'New Password:'; 95 | $pg .= ''; 96 | $pg .= ''; 97 | $pg .= '
'; 99 | $pg .= 'New Password again:'; 100 | $pg .= ''; 101 | $pg .= ''; 102 | $pg .= '
'; 104 | $pg .= '*2nd Authentication:'; 105 | $pg .= ''; 106 | $pg .= ''; 107 | $pg .= '
'; 109 | $pg .= "*Leave blank if you haven't enabled it"; 110 | $pg .= '
'; 112 | $pg .= 'Change: '; 113 | $pg .= '
'; 115 | 116 | $pg .= '
'; 118 | 119 | return $pg; 120 | } 121 | # 122 | function dosettings($data, $user) 123 | { 124 | $err = ''; 125 | $chg = getparam('Change', false); 126 | $check = false; 127 | switch ($chg) 128 | { 129 | case 'EMail': 130 | $email = getparam('email', false); 131 | $res = bademail($email); 132 | if ($res != null) 133 | $err = $res; 134 | else 135 | { 136 | $pass = getparam('pass', false); 137 | $twofa = getparam('2fa', false); 138 | $ans = userSettings($user, $email, null, $pass, $twofa); 139 | $err = 'EMail changed'; 140 | $check = true; 141 | } 142 | break; 143 | case 'Address': 144 | if (!isset($data['info']['u_multiaddr'])) 145 | { 146 | $res = emailcheck($user); 147 | if ($res != null) 148 | $err = $res; 149 | else 150 | { 151 | $addr = getparam('baddr', false); 152 | if (nuem($addr)) 153 | $addr = ''; 154 | $addrarr = array(array('addr' => trim($addr))); 155 | $pass = getparam('pass', false); 156 | $twofa = getparam('2fa', false); 157 | $ans = userSettings($user, null, $addrarr, $pass, $twofa); 158 | $err = 'Payout address changed'; 159 | $check = true; 160 | } 161 | } 162 | break; 163 | case 'Password': 164 | $res = emailcheck($user); 165 | if ($res != null) 166 | $err = $res; 167 | else 168 | { 169 | $oldpass = getparam('oldpass', false); 170 | $pass1 = getparam('pass1', false); 171 | $pass2 = getparam('pass2', false); 172 | $twofa = getparam('2fa', false); 173 | if (!safepass($pass1)) 174 | $err = 'Unsafe password. ' . passrequires(); 175 | elseif ($pass1 != $pass2) 176 | $err = "Passwords don't match"; 177 | else 178 | { 179 | $ans = setPass($user, $oldpass, $pass1, $twofa); 180 | $err = 'Password changed'; 181 | $check = true; 182 | } 183 | } 184 | break; 185 | } 186 | $doemail = false; 187 | if ($check === true) 188 | { 189 | if ($ans['STATUS'] != 'ok') 190 | { 191 | $err = $ans['STATUS']; 192 | if ($ans['ERROR'] != '') 193 | $err .= ': '.$ans['ERROR']; 194 | } 195 | else 196 | $doemail = true; 197 | } 198 | $ans = userSettings($user); 199 | if ($ans['STATUS'] != 'ok') 200 | dbdown(); // Should be no other reason? 201 | if (isset($ans['email'])) 202 | $email = $ans['email']; 203 | else 204 | $email = ''; 205 | // Use the first one - updating will expire all others 206 | if (isset($ans['rows']) and $ans['rows'] > 0) 207 | $addr = $ans['addr:0']; 208 | else 209 | $addr = ''; 210 | 211 | if ($doemail) 212 | { 213 | if ($email == '') 214 | { 215 | if ($err != '') 216 | $err .= '
'; 217 | $err .= 'An error occurred, check your details below'; 218 | goto iroiroattanoyo; 219 | } 220 | 221 | $emailinfo = getOpts($user, emailOptList()); 222 | if ($emailinfo['STATUS'] != 'ok') 223 | { 224 | if ($err != '') 225 | $err .= '
'; 226 | $err .= 'An error occurred, check your details below'; 227 | goto iroiroattanoyo; 228 | } 229 | 230 | switch ($chg) 231 | { 232 | case 'EMail': 233 | if (isset($_SESSION['old_set_email'])) 234 | $old = $_SESSION['old_set_email']; 235 | else 236 | $old = null; 237 | emailAddressChanged($email, zeip(), $emailinfo, $old); 238 | break; 239 | case 'Address': 240 | payoutAddressChanged($email, zeip(), $emailinfo); 241 | break; 242 | case 'Password': 243 | passChanged($email, zeip(), $emailinfo); 244 | break; 245 | } 246 | } 247 | iroiroattanoyo: 248 | $pg = settings($data, $user, $email, $addr, $err); 249 | return $pg; 250 | } 251 | # 252 | function show_settings($info, $page, $menu, $name, $user) 253 | { 254 | gopage($info, NULL, 'dosettings', $page, $menu, $name, $user); 255 | } 256 | # 257 | ?> 258 | -------------------------------------------------------------------------------- /pool/page_shifts.php: -------------------------------------------------------------------------------- 1 | here to jump to the start of the last payout

"; 8 | $pg .= "\n"; 9 | $pg .= ''; 10 | $pg .= ''; 11 | $pg .= ''; 12 | $pg .= ''; 13 | $pg .= ''; 14 | $pg .= ''; 15 | $pg .= ''; 16 | $pg .= ''; 17 | $pg .= ''; 18 | $pg .= ''; 19 | $pg .= ''; 20 | $pg .= ''; 21 | $pg .= "\n"; 22 | 23 | if (($ans['STATUS'] != 'ok') || !isset($ans['prefix_all'])) 24 | $pg = '

Shifts

'.$pg; 25 | else 26 | { 27 | $pre = $ans['prefix_all']; 28 | 29 | $count = $ans['rows']; 30 | $pg = '

Last '.($count+1).' Shifts

'.$pg.''; 31 | for ($i = 0; $i < $count; $i++) 32 | { 33 | $u = ''; 34 | $mark = ''; 35 | if (isset($ans['lastpayoutstart:'.$i]) 36 | && $ans['lastpayoutstart:'.$i] != '') 37 | { 38 | $u = 'u'; 39 | $mark = ''; 40 | } 41 | if (($i % 2) == 0) 42 | $row = "even$u"; 43 | else 44 | $row = "odd$u"; 45 | 46 | $pg .= ""; 47 | $shifname = $ans['shift:'.$i]; 48 | $shif = preg_replace(array('/^.* to /','/^.*fin: /'), '', $shifname); 49 | $ablock = false; 50 | if (preg_match('/to.*Block.* fin/', $shifname) == 1) 51 | $ablock = true; 52 | else 53 | { 54 | $shifex = $ans['endmarkextra:'.$i]; 55 | if (preg_match('/Block .* fin/', $shifex) == 1) 56 | $ablock = true; 57 | } 58 | if ($ablock === true) 59 | $btc = ' '; 60 | else 61 | $btc = ''; 62 | $pg .= ""; 63 | $start = $ans['start:'.$i]; 64 | $pg .= ''; 65 | $nd = $ans['end:'.$i]; 66 | $elapsed = $nd - $start; 67 | $pg .= ''; 68 | $diffacc = $ans[$pre.'diffacc:'.$i]; 69 | $pg .= ''; 70 | $diffinv = $ans[$pre.'diffinv:'.$i]; 71 | $pg .= ''; 72 | $hr = $diffacc * pow(2,32) / $elapsed; 73 | $pg .= ''; 74 | $shareacc = $ans[$pre.'shareacc:'.$i]; 75 | $pg .= ''; 76 | if ($shareacc > 0) 77 | $avgsh = $diffacc / $shareacc; 78 | else 79 | $avgsh = 0; 80 | $pg .= ''; 81 | $pg .= ''; 82 | $ppsr = (float)$ans['ppsrewarded:'.$i]; 83 | if ($ppsr > 0) 84 | $ppsd = sprintf('%.5f', $ppsr*1000.0); 85 | else 86 | $ppsd = '0'; 87 | $pg .= ""; 88 | $ppsv = (float)$ans['ppsvalue:'.$i]; 89 | if ($ppsv > 0) 90 | $pgot = number_format(100.0 * $ppsr / $ppsv, 2).'%'; 91 | else 92 | $pgot = '?'; 93 | $pg .= ""; 94 | $pg .= "\n"; 95 | } 96 | $pg .= ''; 97 | } 98 | $pg .= "
ShiftStart UTCLengthYour DiffInv DiffAvg HsSharesAvg ShareRewardsRewarded*PPS%
$shif$btc$mark'.utcd($start, true).''.howmanyhrs($elapsed).''.difffmt($diffacc).''.difffmt($diffinv).''.dsprate($hr).''.difffmt($shareacc).''.number_format($avgsh, 2).''.$ans['rewards:'.$i].'$ppsd$pgot
\n"; 99 | $pg .= "* The Rewarded value unit is satoshis per 1000diff share
"; 100 | 101 | return $pg; 102 | } 103 | # 104 | function show_shifts($info, $page, $menu, $name, $user) 105 | { 106 | gopage($info, NULL, 'doshifts', $page, $menu, $name, $user); 107 | } 108 | # 109 | ?> 110 | -------------------------------------------------------------------------------- /pool/page_stats.php: -------------------------------------------------------------------------------- 1 | Pool Stats'; 14 | 15 | if (isset($data['info']) && $data['info'] !== false) 16 | { 17 | $info = $data['info']; 18 | 19 | $pe = false; 20 | if (isset($info['p_elapsed'])) 21 | { 22 | $dspel = howlongago($info['p_elapsed']); 23 | $pg .= "Pool Uptime: $dspel"; 24 | $pe = true; 25 | } 26 | 27 | if (isset($info['ckdb_elapsed'])) 28 | { 29 | if ($pe) 30 | $pg .= ' '; 31 | $dspel = howlongago($info['ckdb_elapsed']); 32 | $pg .= "CKDB Uptime: $dspel"; 33 | } 34 | 35 | $dsp = '?THs'; 36 | $dsp5m = '?THs'; 37 | $dsp1hr = '?THs'; 38 | $dsp24hr = '?THs'; 39 | 40 | if (isset($info['p_hashrate'])) 41 | { 42 | $hr = $info['p_hashrate']; 43 | if ($hr != '?') 44 | $dsp = dsprate($hr); 45 | } 46 | 47 | if (isset($info['p_hashrate5m'])) 48 | { 49 | $hr = $info['p_hashrate5m']; 50 | if ($hr != '?') 51 | $dsp5m = dsprate($hr); 52 | } 53 | 54 | if (isset($info['p_hashrate1hr'])) 55 | { 56 | $hr = $info['p_hashrate1hr']; 57 | if ($hr != '?') 58 | $dsp1hr = dsprate($hr); 59 | } 60 | 61 | if (isset($info['p_hashrate24hr'])) 62 | { 63 | $hr = $info['p_hashrate24hr']; 64 | if ($hr != '?') 65 | $dsp24hr = dsprate($hr); 66 | } 67 | 68 | $pg .= ''; 69 | $pg .= ""; 70 | $pg .= ""; 71 | $pg .= ""; 72 | $pg .= ""; 73 | $pg .= '
Pool Hashrate: $dsp5m: $dsp5m1hr: $dsp1hr24hr: $dsp24hr

'; 74 | } 75 | 76 | $ans = getAllUsers($user); 77 | 78 | $pg .= "\n"; 79 | $pg .= ''; 80 | $pg .= ''; 81 | $pg .= ''; 82 | $pg .= "\n"; 83 | if ($ans['STATUS'] == 'ok') 84 | { 85 | $pg .= ''; 86 | $all = array(); 87 | $count = $ans['rows']; 88 | for ($i = 0; $i < $count; $i++) 89 | { 90 | $all[] = array('username' => $ans['username:'.$i], 91 | 'userid' => $ans['userid:'.$i], 92 | 'u_hashrate5m' => $ans['u_hashrate5m:'.$i]); 93 | } 94 | 95 | usort($all, 'allusersort'); 96 | 97 | for ($i = 0; $i < $count; $i++) 98 | { 99 | if (($i % 2) == 0) 100 | $row = 'even'; 101 | else 102 | $row = 'odd'; 103 | 104 | $pg .= ""; 105 | $pg .= ''; 106 | $uhr = $all[$i]['u_hashrate5m']; 107 | if ($uhr == '?') 108 | $dsp = '?GHs'; 109 | else 110 | $dsp = dsprate($uhr); 111 | $pg .= ""; 112 | $pg .= "\n"; 113 | } 114 | $pg .= ''; 115 | } 116 | $pg .= "
UsernameHash Rate 5m
'.htmlspecialchars($all[$i]['username']).'$dsp
\n"; 117 | 118 | return $pg; 119 | } 120 | # 121 | function show_stats($info, $page, $menu, $name, $user) 122 | { 123 | gopage($info, NULL, 'dostats', $page, $menu, $name, $user); 124 | } 125 | # 126 | ?> 127 | -------------------------------------------------------------------------------- /pool/page_userinfo.php: -------------------------------------------------------------------------------- 1 | Block Acclaim'; 23 | $pg .= "\n"; 24 | $pg .= ''; 25 | $pg .= ''; 26 | $pg .= ''; 27 | if ($sall) 28 | { 29 | $pg .= ''; 30 | $pg .= ''; 31 | } 32 | $pg .= "\n"; 33 | 34 | if ($ans['STATUS'] == 'ok') 35 | { 36 | $pg .= ''; 37 | $all = array(); 38 | $count = $ans['rows']; 39 | for ($i = 0; $i < $count; $i++) 40 | { 41 | if ($sall) 42 | $diffacc = $ans['diffacc:'.$i]; 43 | else 44 | $diffacc = 0; 45 | 46 | $all[] = array('blocks' => $ans['blocks:'.$i], 47 | 'username' => $ans['username:'.$i], 48 | 'diffacc' => $diffacc); 49 | } 50 | usort($all, 'blocksorder'); 51 | 52 | for ($i = 0; $i < $count; $i++) 53 | { 54 | $bl = $all[$i]['blocks']; 55 | if ($sall == false && $bl < 1) 56 | break; 57 | 58 | if (($i % 2) == 0) 59 | $row = 'even'; 60 | else 61 | $row = 'odd'; 62 | 63 | $pg .= ""; 64 | $un = htmlspecialchars($all[$i]['username']); 65 | $pg .= ""; 66 | $pg .= ""; 67 | if ($sall) 68 | { 69 | $diffacc = $all[$i]['diffacc']; 70 | $pg .= ''; 71 | if ($bl == 0) 72 | $bl = 1; 73 | $pg .= ''; 74 | } 75 | $pg .= "\n"; 76 | } 77 | $pg .= ''; 78 | } 79 | $pg .= "
UserBlocksDiffAvg
$un$bl'.difffmt($diffacc).''.difffmt($diffacc/$bl).'
\n"; 80 | 81 | return $pg; 82 | } 83 | # 84 | function show_userinfo($info, $page, $menu, $name, $user) 85 | { 86 | gopage($info, NULL, 'douserinfo', $page, $menu, $name, $user); 87 | } 88 | # 89 | ?> 90 | -------------------------------------------------------------------------------- /pool/page_userset.php: -------------------------------------------------------------------------------- 1 | User Settings'; 6 | 7 | if ($err != '') 8 | $pg .= "$err

"; 9 | 10 | $pg .= ''; 11 | $pg .= ''; 14 | $pg .= ''; 58 | $pg .= '
'; 12 | $pg .= ""; 13 | $pg .= 'mini header
'; 15 | 16 | $pg .= makeForm('userset'); 17 | $pg .= ''; 18 | $pg .= '"; 30 | $pg .= ''; 39 | if ($api !== false) 40 | { 41 | $pg .= ''; 42 | $pg .= ''; 48 | $pg .= ''; 54 | } 55 | $pg .= '
'; 19 | if ($api === false) 20 | { 21 | $pg .= "You don't have an API Key setup yet"; 22 | $draw = false; 23 | } 24 | else 25 | { 26 | addQR(); 27 | $pg .= 'Your current API Key is:'; 28 | $pg .= '
'; 29 | $pg .= "$api
'; 31 | $pg .= 'A qrcode will show here if your browser supports html5/canvas'; 32 | $pg .= "
"; 33 | $draw = true; 34 | } 35 | $pg .= '
'; 36 | $pg .= 'Click to generate a new API key'; 37 | $pg .= ": "; 38 | $pg .= '
 
You can access the API via:'; 43 | $pg .= '
'; 44 | $pg .= "/index.php?k=api&username="; 45 | $pg .= htmlspecialchars(urlencode($user)); 46 | $pg .= "&api=$api&json=y
"; 47 | $pg .= '
You can get your workers via:'; 49 | $pg .= '
'; 50 | $pg .= "/index.php?k=api&username="; 51 | $pg .= htmlspecialchars(urlencode($user)); 52 | $pg .= "&api=$api&json=y&work=y
"; 53 | $pg .= '
'; 56 | 57 | $pg .= '
'; 59 | 60 | if ($draw !== false) 61 | { 62 | $qr = shell_exec("../pool/myqr.sh '$api'"); 63 | if ($qr !== null and strlen($qr) > 30) 64 | { 65 | $pg .= "\n"; 67 | 68 | if (strpos($qr, 'var tw=1,fa=0,qrx=') === false) 69 | error_log("QR error for '$user' res='$qr'"); 70 | } 71 | else 72 | { 73 | if ($qr === null) 74 | $qr = 'null'; 75 | error_log("QR failed for '$user' res='$qr'"); 76 | } 77 | } 78 | 79 | return $pg; 80 | } 81 | # 82 | function douserset($data, $user) 83 | { 84 | $err = ''; 85 | $chg = getparam('Change', false); 86 | $api = false; 87 | switch ($chg) 88 | { 89 | case 'API Key': 90 | $ans = getAtts($user, 'KAPIKey.str,KAPIKey.dateexp'); 91 | if ($ans['STATUS'] != 'ok') 92 | dbdown(); // Should be no other reason? 93 | if (isset($ans['KAPIKey.dateexp']) && $ans['KAPIKey.dateexp'] == 'N') 94 | { 95 | $err = 'You can only change it once a day'; 96 | if (isset($ans['KAPIKey.str'])) 97 | $api = $ans['KAPIKey.str']; 98 | } 99 | else 100 | { 101 | $ran = $ans['STAMP'].$user.rand(100000000,999999999); 102 | $api = hash('md4', $ran); 103 | 104 | $day = 60 * 60 * 24; 105 | $ans = setAtts($user, array('ua_KAPIKey.str' => $api, 106 | 'ua_KAPIKey.date' => "now+$day")); 107 | if ($ans['STATUS'] != 'ok') 108 | syserror(); 109 | 110 | } 111 | break; 112 | } 113 | if ($api === false) 114 | { 115 | $ans = getAtts($user, 'KAPIKey.str'); 116 | if ($ans['STATUS'] != 'ok') 117 | dbdown(); // Should be no other reason? 118 | if (isset($ans['KAPIKey.str'])) 119 | $api = $ans['KAPIKey.str']; 120 | } 121 | $pg = uset($data, $user, $api, $err); 122 | return $pg; 123 | } 124 | # 125 | function show_userset($info, $page, $menu, $name, $user) 126 | { 127 | gopage($info, NULL, 'douserset', $page, $menu, $name, $user); 128 | } 129 | # 130 | ?> 131 | -------------------------------------------------------------------------------- /pool/page_usperf.php: -------------------------------------------------------------------------------- 1 | =0&&fi>=0){var xs,xf;xs=(st-x0)/(x1-x0);xf=(fi-x0)/(x1-x0);gfs(c,'$fs');gbe(c,xs,0);gln(c,xs,1);gln(c,xf,1);gln(c,xf,0);gle(c);gfl(c);gfz(c,xs,1,0,2,'Last 5Nd Reward \u279c','$ff','left')}}} 6 | function gdrw(c,d,cbx){gc(c);ghrs(c);gopt(c,cbx); 7 | gfs(c,'white');gss(c,'#0000c0');glw(c,2);gbd(c); 8 | var rows=d['rows'],ymin=-1,ymax=0,xmin=-1,xmax=0,tda=[]; 9 | var w=d['arp'].split(',');var cols=d['cols'].split(','); 10 | gsh(c,w); 11 | for(var j=1;js){xmin=s}if(xmaxths){ymin=ths}if(ths>ymax)ymax=ths;document.getElementById('worker'+j).value=d[pre+'worker']} 14 | } 15 | for(var j=1;j1){w+=','}w+=e.value.trim()}}if(w){scnv('workers',w)}}"; 24 | return $g; 25 | } 26 | # 27 | function dousperf($data, $user) 28 | { 29 | global $fld_sep, $val_sep; 30 | 31 | // This also defines how many worker fields there are 32 | $cols = array('#0000c0', '#00dd00', '#e06020', '#b020e0'); 33 | $cols2 = array('#2090e0', '#e0c040', '#ff6090', '#90e040'); 34 | $nc = count($cols)+count($cols2); 35 | 36 | $workers = 'all'; 37 | if (isset($_COOKIE['workers'])) 38 | { 39 | $w = substr(trim($_COOKIE['workers']), 0, 1024); 40 | if ($w !== false) 41 | { 42 | $wa = explode(',', $w, $nc+1); 43 | if (count($wa) > $nc) 44 | { 45 | $w = ''; 46 | for ($i = 0; $i < $nc; $i++) 47 | $w .= (($i == 0) ? '' : ',').$wa[$i]; 48 | } 49 | $workers = $w; 50 | } 51 | } 52 | 53 | $ans = getShiftData($user, $workers); 54 | 55 | $iCrap = strpos($_SERVER['HTTP_USER_AGENT'],'iP'); 56 | if ($iCrap) 57 | $vlines = false; 58 | else 59 | $vlines = true; 60 | 61 | $pg = '

User Shift Reward Performance


'; 62 | 63 | if ($ans['STATUS'] == 'ok' and $ans['DATA'] != '') 64 | { 65 | addGBase(); 66 | addTips(); 67 | $cbx = array('skey' => 'shift key', 'slines' => 'shift lines', 68 | 'tkey' => 'time key', 'tlines' => 'time lines', 69 | 'over' => 'key overlap', 'smooth' => 'smooth', 70 | 'zerob' => 'zero based', 'utc' => 'utc'); 71 | $xon = array('skey' => 1, 'utc' => 1); 72 | if ($vlines === true) 73 | $xon['slines'] = 1; 74 | 75 | $pg .= '
'; 76 | 77 | $tt = "
  • all = all workers
  • noname = worker with no workername
  • "; 78 | $tt .= "
  • or full workername without the username i.e. .worker or _worker
  • "; 79 | $tt .= "
  • add a '*' on the end to match multiple workers e.g. .S3*
"; 80 | $pg .= "?"; 81 | $pg .= "$tt"; 82 | 83 | $i = 0; 84 | $datacols = ''; 85 | $onch = " onchange='wch()'"; 86 | foreach ($cols as $col) 87 | { 88 | $i++; 89 | $pg .= " Worker$i"; 90 | $pg .= ":"; 91 | $pg .= " "; 92 | 93 | if ($i > 1) 94 | $datacols .= ','; 95 | $datacols .= $col; 96 | } 97 | $oncl = "wch();location.href=\"".makeURL('usperf')."\""; 98 | $pg .= "
"; 99 | 100 | # the rest of the workers/colours go below the graph 101 | $pg2 = '
'; 102 | foreach ($cols2 as $col) 103 | { 104 | $i++; 105 | $pg2 .= " Worker$i"; 106 | $pg2 .= ":"; 107 | $pg2 .= " "; 108 | 109 | if ($i > 1) 110 | $datacols .= ','; 111 | $datacols .= $col; 112 | } 113 | $pg2 .= "
\n"; 114 | 115 | foreach ($cbx as $nam => $txt) 116 | { 117 | $pg .= ' '; 118 | $pg .= ""; 119 | $pg .= "$txt "; 120 | } 121 | 122 | $pg .= '
'; 123 | $pg .= '
'; 124 | $pg .= 'A graph will show here if your browser supports html5/canvas'; 125 | $pg .= "
\n"; 126 | $pg .= $pg2; 127 | $data = str_replace(array("\\","'"), array("\\\\","\\'"), $ans['DATA']); 128 | $data .= $fld_sep . 'cols' . $val_sep . $datacols; 129 | $pg .= "\n"; 142 | } 143 | return $pg; 144 | } 145 | # 146 | function show_usperf($info, $page, $menu, $name, $user) 147 | { 148 | gopage($info, NULL, 'dousperf', $page, $menu, $name, $user); 149 | } 150 | # 151 | ?> 152 | -------------------------------------------------------------------------------- /pool/page_workmgt.php: -------------------------------------------------------------------------------- 1 | Worker Management'; 6 | 7 | if ($err != '') 8 | $pg .= "$err

"; 9 | 10 | $ans = getWorkers($user, 'N'); 11 | 12 | if ($ans['STATUS'] == 'ok') 13 | { 14 | if (isset($ans['oldworkers']) && $ans['oldworkers'] == '0') 15 | $chk = ''; 16 | else 17 | $chk = ' checked'; 18 | $pg .= makeForm('workmgt'); 19 | $pg .= 'Active workers (7 days)'; 20 | $pg .= ""; 21 | $pg .= ''; 22 | $pg .= '

'; 23 | } 24 | 25 | $pg .= makeForm('workmgt'); 26 | $pg .= "\n"; 27 | $pg .= ''; 28 | $pg .= ''; 29 | $pg .= ''; 30 | $pg .= ''; 31 | 32 | $offset = 0; 33 | if ($ans['STATUS'] == 'ok') 34 | { 35 | $count = $ans['rows']; 36 | for ($i = 0; $i < $count; $i++) 37 | { 38 | if ((($offset) % 2) == 0) 39 | $row = 'even'; 40 | else 41 | $row = 'odd'; 42 | 43 | $pg .= ""; 44 | 45 | $wn = htmlspecialchars($ans['workername:'.$i]); 46 | $wnv = urlencode($ans['workername:'.$i]); 47 | $pg .= ''; 50 | 51 | $md = intval($ans['difficultydefault:'.$i]); 52 | $pg .= '"; 56 | 57 | $pg .= "\n"; 58 | 59 | $offset++; 60 | } 61 | } 62 | $pg .= ''; 66 | $pg .= "
Worker NameMinimum Diff
'; 48 | $pg .= ""; 49 | $pg .= $wn.''; 53 | $pg .= ""; 54 | $pg .= ""; 55 | $pg .= "
*'; 63 | $pg .= ' A value of 0, less than the pool minimum,
'; 64 | $pg .= 'or less than the pool calculated value for you,
'; 65 | $pg .= 'will use the pool calculated value
\n"; 67 | 68 | return $pg; 69 | } 70 | # 71 | function doworkmgt($data, $user) 72 | { 73 | $err = ''; 74 | $S = getparam('S', false); 75 | $chk = getparam('seven', false); 76 | if ($S == 'Update') 77 | { 78 | $settings = array(); 79 | if ($chk == 'on') 80 | $settings['oldworkers'] = '7'; 81 | else 82 | $settings['oldworkers'] = '0'; 83 | $ans = workerSet($user, $settings); 84 | if ($ans['STATUS'] != 'ok') 85 | $err = $ans['ERROR']; 86 | } 87 | else 88 | { 89 | $OK = getparam('OK', false); 90 | $count = getparam('rows', false); 91 | if ($OK == 'OK' && !nuem($count)) 92 | { 93 | if ($count > 0 && $count < 9999) 94 | { 95 | $settings = array(); 96 | for ($i = 0; $i < $count; $i++) 97 | { 98 | $wn = urldecode(getparam('workername:'.$i, false)); 99 | $md = getparam('difficultydefault:'.$i, false); 100 | if (!nuem($wn) && !nuem($md)) 101 | { 102 | $settings['workername:'.$i] = $wn; 103 | $settings['difficultydefault:'.$i] = $md; 104 | } 105 | } 106 | $ans = workerSet($user, $settings); 107 | if ($ans['STATUS'] != 'ok') 108 | $err = $ans['ERROR']; 109 | } 110 | } 111 | } 112 | 113 | $pg = workmgtuser($data, $user, $err); 114 | 115 | return $pg; 116 | } 117 | # 118 | function show_workmgt($info, $page, $menu, $name, $user) 119 | { 120 | gopage($info, NULL, 'doworkmgt', $page, $menu, $name, $user); 121 | } 122 | # 123 | ?> 124 | -------------------------------------------------------------------------------- /pool/param.php: -------------------------------------------------------------------------------- 1 | 39 | -------------------------------------------------------------------------------- /pool/prime.php: -------------------------------------------------------------------------------- 1 | $options) 35 | if ($options !== NULL) 36 | foreach ($options as $name => $pagename) 37 | if ($pagename === $p) 38 | { 39 | $page = $p; 40 | $n = " - $name"; 41 | } 42 | 43 | if ($page === '' and $p == 'blocks') 44 | { 45 | $p = 'pblocks'; 46 | goto bp; 47 | } 48 | if ($page === '') 49 | showPage($info, 'index', $menu, '', $user); 50 | else 51 | showPage($info, $page, $menu, $n, $user); 52 | } 53 | # 54 | function def_menu() 55 | { 56 | $dmenu = array('Home' => array('Home' => ''), 57 | 'Pool' => array( 58 | 'Blocks' => 'pblocks' 59 | ), 60 | 'gap' => array( # options not shown 61 | 'API' => 'api'), 62 | 'Help' => array( 63 | 'Payouts' => 'payout')); 64 | return $dmenu; 65 | } 66 | # 67 | function check() 68 | { 69 | $dmenu = def_menu(); 70 | $menu = array( 71 | 'Home' => array( 72 | 'Home' => '' 73 | ), 74 | 'Account' => array( 75 | 'Rewards' => 'mpayouts', 76 | 'Payments' => 'payments', 77 | 'Settings' => 'settings', 78 | 'User Settings' => 'userset', 79 | '2FA Settings' => '2fa' 80 | ), 81 | 'Workers' => array( 82 | 'Shifts' => 'shifts', 83 | 'Shift Graph' => 'usperf', 84 | 'Workers' => 'workers', 85 | 'Management' => 'workmgt' 86 | ), 87 | 'Pool' => array( 88 | 'Stats' => 'stats', 89 | 'Blocks' => 'blocks', 90 | 'Graph' => 'psperf', 91 | 'Acclaim' => 'userinfo', 92 | 'Luck' => 'luck' 93 | ), 94 | 'Admin' => NULL, 95 | 'gap' => array( # options not shown 96 | 'API' => 'api', 97 | 'PBlocks' => 'pblocks' 98 | ), 99 | 'Help' => array( 100 | 'Payouts' => 'payout' 101 | ) 102 | ); 103 | tryLogInOut(); 104 | $who = loggedIn(); 105 | if ($who === false) 106 | { 107 | $p = getparam('k', true); 108 | if ($p == 'reset') 109 | showPage(NULL, 'reset', $dmenu, '', $who); 110 | else 111 | { 112 | if (requestLoginRegReset() == true) 113 | showPage(NULL, 'reg', $dmenu, '', $who); 114 | else 115 | { 116 | $p = getparam('k', true); 117 | process($p, $who, $dmenu); 118 | } 119 | } 120 | } 121 | else 122 | { 123 | $p = getparam('k', true); 124 | process($p, $who, $menu); 125 | } 126 | } 127 | # 128 | check(); 129 | # 130 | ?> 131 | -------------------------------------------------------------------------------- /pool/socket.php: -------------------------------------------------------------------------------- 1 | $sec, 'usec' => $usec); 18 | socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, $tmoval); 19 | socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, $tmoval); 20 | } 21 | # 22 | # Note that $port in AF_UNIX should be the socket filename 23 | function _getsock($fun, $port, $tmo, $unix=true) 24 | { 25 | $socket = null; 26 | if ($unix === true) 27 | $socket = socket_create(AF_UNIX, SOCK_STREAM, 0); 28 | else 29 | $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); 30 | if ($socket === false || $socket === null) 31 | { 32 | $sle = socket_last_error(); 33 | $sockerr = socket_strerror($sle); 34 | $msg = "$fun() _getsock() create($port) failed"; 35 | error_log("CKPERR: $msg ($sle) '$sockerr'"); 36 | return false; 37 | } 38 | 39 | if ($unix === true) 40 | $res = socket_connect($socket, $port, NULL); 41 | else 42 | $res = socket_connect($socket, '127.0.0.1', $port); 43 | if ($res === false) 44 | { 45 | // try 3x 46 | if ($unix === true) 47 | $res = socket_connect($socket, $port); 48 | else 49 | { 50 | sleep(2); 51 | $res = socket_connect($socket, '127.0.0.1', $port); 52 | } 53 | if ($res === false) 54 | { 55 | if ($unix === true) 56 | $res = socket_connect($socket, $port); 57 | else 58 | { 59 | sleep(5); 60 | $res = socket_connect($socket, '127.0.0.1', $port); 61 | } 62 | if ($res === false) 63 | { 64 | $sle = socket_last_error(); 65 | $sockerr = socket_strerror($sle); 66 | if ($unix === true) 67 | $msg = "$fun() _getsock() connect($port) failed 3x"; 68 | else 69 | $msg = "$fun() _getsock() connect($port) failed 3x (+2+5s sleep)"; 70 | error_log("CKPERR: $msg ($sle) '$sockerr'"); 71 | socket_close($socket); 72 | return false; 73 | } 74 | } 75 | } 76 | # Avoid getting locked up for long 77 | socktmo($socket, $tmo); 78 | # Enable timeout 79 | socket_set_block($socket); 80 | return $socket; 81 | } 82 | # 83 | function getsock($fun, $tmo) 84 | { 85 | return _getsock($fun, '/opt/ckdb/listenerweb', $tmo); 86 | } 87 | # 88 | function readsockline($fun, $socket) 89 | { 90 | $siz = socket_read($socket, 4, PHP_BINARY_READ); 91 | if ($siz === false) 92 | { 93 | $sle = socket_last_error(); 94 | $sockerr = socket_strerror($sle); 95 | $msg = "$fun() readsockline() failed"; 96 | error_log("CKPERR: $msg ($sle) '$sockerr'"); 97 | return false; 98 | } 99 | if (strlen($siz) != 4) 100 | { 101 | $msg = "$fun() readsockline() short 4 read got ".strlen($siz); 102 | error_log("CKPERR: $msg"); 103 | return false; 104 | } 105 | $len = ord($siz[0]) + ord($siz[1])*256 + 106 | ord($siz[2])*65536 + ord($siz[3])*16777216; 107 | $ans = ''; 108 | $left = $len; 109 | while ($left > 0) 110 | { 111 | $line = socket_read($socket, $left, PHP_BINARY_READ); 112 | if ($line === false) 113 | { 114 | $sle = socket_last_error(); 115 | $sockerr = socket_strerror($sle); 116 | $msg = "$fun() readsockline() $left failed (len=$len)"; 117 | error_log("CKPERR: $msg ($sle) '$sockerr'"); 118 | return false; 119 | } 120 | $red = strlen($line); 121 | if ($red == 0) 122 | { 123 | $msg = "$fun() readsockline() incomplete (".($len-$left)." vs $len)"; 124 | $sub = "'".substr($line, 0, 30)."'"; 125 | if (strlen($line) > 30) 126 | $sub .= '...'; 127 | error_log("CKPERR: $msg $sub"); 128 | return false; 129 | } 130 | $left -= $red; 131 | $ans .= $line; 132 | } 133 | return $ans; 134 | } 135 | # 136 | function dosend($fun, $socket, $msg) 137 | { 138 | $msg .= "\n"; 139 | $len = strlen($msg); 140 | 141 | $sen = $len; 142 | $siz = chr($sen % 256); 143 | $sen = $sen >> 8; 144 | $siz .= chr($sen % 256); 145 | $sen = $sen >> 8; 146 | $siz .= chr($sen % 256); 147 | $sen = $sen >> 8; 148 | $siz .= chr($sen % 256); 149 | 150 | $msg = $siz . $msg; 151 | 152 | $len += 4; 153 | $left = $len; 154 | $ret = false; 155 | while ($left > 0) 156 | { 157 | $res = socket_write($socket, substr($msg, 0 - $left), $left); 158 | if ($res === false) 159 | { 160 | $sockerr = socket_strerror(socket_last_error()); 161 | $msg = "$fun() sendsock() failed"; 162 | error_log("CKPERR: $msg '$sockerr'"); 163 | break; 164 | } 165 | if ($res == 0) 166 | { 167 | $msg = "$fun() sendsock() incomplete (".($len-$left)." vs $len)"; 168 | error_log("CKPERR: $msg"); 169 | break; 170 | } 171 | $left -= $res; 172 | } 173 | if ($left == 0) 174 | $ret = true; 175 | 176 | return $ret; 177 | } 178 | # 179 | function sendsock($fun, $msg, $tmo = false) 180 | { 181 | $ret = false; 182 | $socket = getsock($fun, $tmo); 183 | if ($socket !== false) 184 | { 185 | $ret = dosend($fun, $socket, $msg); 186 | socket_close($socket); 187 | } 188 | return $ret; 189 | } 190 | # 191 | # This is the only function in here you call 192 | # You pass it a string $fun for debugging 193 | # and the data $msg to send to ckdb 194 | # and it returns $ret = false on error or $ret = the string reply 195 | # 196 | # Alerts are always tagged on the end as: $fld_sep alert $val_sep text 197 | # There's allowed to be more than one. They are removed 198 | # 199 | function sendsockreply($fun, $msg, $tmo = false) 200 | { 201 | global $fld_sep, $val_sep, $alrts; 202 | 203 | $ret = false; 204 | $socket = getsock($fun, $tmo); 205 | if ($socket !== false) 206 | { 207 | $ret = dosend($fun, $socket, $msg); 208 | if ($ret !== false) 209 | $ret = readsockline($fun, $socket); 210 | 211 | socket_close($socket); 212 | } 213 | $al = $fld_sep . 'alert' . $val_sep; 214 | if ($ret !== false and strpos($ret, $al) !== false) 215 | { 216 | $all = explode($al, $ret); 217 | $ret = $all[0]; 218 | $skip = true; 219 | foreach ($all as $lrt) 220 | { 221 | if ($skip) 222 | $skip = false; 223 | else 224 | // Discard duplicates 225 | $alrts[preg_replace("/[\n\r]*$/",'',$lrt)] = 1; 226 | } 227 | } 228 | return $ret; 229 | } 230 | # 231 | ?> 232 | -------------------------------------------------------------------------------- /pool/worker.php: -------------------------------------------------------------------------------- 1 | 5 | 6 | CKPool 7 | 22 | 23 | -------------------------------------------------------------------------------- /sql/bs.sql: -------------------------------------------------------------------------------- 1 | -- SQL to calculate a block's diffacc (difficulty accepted) 2 | -- This should match the block's confirmed diffacc 3 | -- i.e. when a block has statsconfirmed='Y' 4 | -- If the block has any unaged sharesummaries, 5 | -- the script will abort and report the count 6 | -- Sharesummaries are aged at ~10 minutes after the next workinfo, 7 | -- after the sharesummary's workinfo, was first generated 8 | -- You need to set the block number at line 21 - hi := blockheight; 9 | 10 | SET SESSION AUTHORIZATION 'postgres'; 11 | 12 | DO $$ 13 | DECLARE 14 | hi INT; 15 | hi0 INT; 16 | wi BIGINT; 17 | wi0 BIGINT; 18 | ssc INT; 19 | da BIGINT; 20 | BEGIN 21 | hi := 318177; 22 | 23 | -- This will randomly choose between multiple blocks of the same height 24 | -- if we happen to orphan ourselves on block 'hi' 25 | select workinfoid from blocks where height = hi 26 | and expirydate > '6666-06-01' limit 1 into wi; 27 | IF NOT found THEN 28 | RAISE EXCEPTION 'Block % not found', hi; 29 | END IF; 30 | 31 | select max(height) from blocks where height < hi into hi0; 32 | IF hi0 is NULL THEN 33 | wi0 := -1; 34 | ELSE 35 | -- This will randomly choose between multiple blocks of the same height 36 | -- if we happen to orphan ourselves on block 'hi0' 37 | select workinfoid from blocks where height = hi0 38 | and expirydate > '6666-06-01' limit 1 into wi0; 39 | END IF; 40 | 41 | RAISE NOTICE 'Block: %(%)', hi, wi; 42 | 43 | IF hi0 is NULL THEN 44 | RAISE NOTICE 'No previous block'; 45 | ELSE 46 | RAISE NOTICE 'Previous block: %(%)', hi0, wi0; 47 | END IF; 48 | 49 | select count(*) from sharesummary where workinfoid > wi0 50 | and workinfoid <= wi and complete = 'n' into ssc; 51 | 52 | IF ssc > 0 THEN 53 | RAISE EXCEPTION 'Unaged sharesummary records: %', ssc; 54 | ELSE 55 | select sum(diffacc) from sharesummary where workinfoid > wi0 56 | and workinfoid <= wi into da; 57 | 58 | RAISE NOTICE 'diffacc: %', to_char(da::bigint, 'FM999,999,999,999,999,990'); 59 | END IF; 60 | END $$; 61 | -------------------------------------------------------------------------------- /sql/initid.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | fldsep="`echo -e '\x09'`" 4 | # 5 | addid() 6 | { 7 | msg="newid.$1.idname=$1${fldsep}idvalue=$2" 8 | echo "$msg" 9 | } 10 | # 11 | # Default to yyyymmddXXXXXX 12 | # thus on reinit it will always be above old values 13 | # XXXXXX should allow enough per day to avoid overlap with other ids 14 | # but of course overlapping with another id doesn't technically matter 15 | now="`date +%Y%m%d`" 16 | # 17 | addid workerid ${now}100000 18 | addid paymentid ${now}200000 19 | addid authid ${now}300000 20 | addid userid ${now}400000 21 | addid markerid ${now}500000 22 | addid paymentaddressid ${now}600000 23 | addid payoutid ${now}700000 24 | -------------------------------------------------------------------------------- /sql/reloadstatus.sql: -------------------------------------------------------------------------------- 1 | select 'sharesummary' as "sharesummary",min(firstshare) as "min incomplete firstshare",max(firstshare) as "(max incomplete firstshare)" from sharesummary where complete = 'n'; 2 | select 'sharesummary' as "sharesummary",max(firstshare) as "max complete firstshare",min(firstshare) as "(min complete firstshare)" from sharesummary where complete != 'n'; 3 | select 'workinfo' as "workinfo",max(createdate) as "max createdate" from workinfo; 4 | select 'auths' as "auths",max(createdate) as "max createdate" from auths; 5 | select 'poolstats' as "poolstats",max(createdate) as "max createdate" from poolstats; 6 | select 'userstats' as "userstats",max(statsdate) as "max statsdate - start of this hour" from userstats; 7 | select 'blocks' as "blocks",max(createdate) as "max createdate" from blocks; 8 | -------------------------------------------------------------------------------- /sql/tabdump.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # idcontrol is updated after the rows are loaded 4 | # for users, paymentaddresses and workers 5 | # 6 | # note that this doesn't save idcontrol since it 7 | # would cause a consistency problem with the reload 8 | # Instead it generates it based on the current DB 9 | # 10 | # Obviously ... don't run the output file when CKDB is running 11 | # 12 | # initid.sh would also be useful to create any missing idcontrol 13 | # records, before using this to update them 14 | # 15 | t0="optioncontrol paymentaddresses useratts users workers version" 16 | # 17 | usAge() 18 | { 19 | echo "usAge: `basename $0` -r > log.sql" 20 | echo " -r = do it" 21 | echo " dump tables not part of the reload" 22 | exit 1 23 | } 24 | # 25 | idctl() 26 | { 27 | echo " 28 | update idcontrol 29 | set lastid=(select max($1) from $2), 30 | modifydate=now(),modifyby='$idn', 31 | modifycode='$mc',modifyinet='$mi' 32 | where idname='$1';" 33 | } 34 | # 35 | process() 36 | { 37 | t="" 38 | for i in $t0 ; do 39 | t="$t -t $i" 40 | echo "delete from $i;" 41 | done 42 | pg_dump -a $t ckdb 43 | # 44 | idn="tabdump-`date "+%Y%m%d%H%M%S"`" 45 | mc="`basename $0`" 46 | mi="127.0.0.1" 47 | # 48 | idctl userid users 49 | idctl workerid workers 50 | idctl paymentaddressid paymentaddresses 51 | 52 | # these below are just to make sure the DB is consistent 53 | idctl markerid workmarkers 54 | idctl paymentid payments 55 | idctl payoutid payouts 56 | } 57 | # 58 | if [ "$1" != "-r" ] ; then 59 | echo "Missing -r" 60 | usAge 61 | fi 62 | # 63 | process 64 | -------------------------------------------------------------------------------- /sql/tables.sql: -------------------------------------------------------------------------------- 1 | \t 2 | select 'accountadjustment' as "accountadjustment",count(*) from accountadjustment; 3 | select 'accountbalance' as "accountbalance",count(*) from accountbalance; 4 | select 'auths' as "auths",count(*) from auths; 5 | select 'blocks' as "blocks",count(*) from blocks; 6 | select 'eventlog' as "eventlog",count(*) from eventlog; 7 | select 'idcontrol' as "idcontrol",count(*) from idcontrol; 8 | select 'markersummary' as "markersummary",count(*) from markersummary; 9 | select 'miningpayouts' as "miningpayouts",count(*) from miningpayouts; 10 | select 'optioncontrol' as "optioncontrol",count(*) from optioncontrol; 11 | select 'paymentaddresses' as "paymentaddresses",count(*) from paymentaddresses; 12 | select 'payments' as "payments",count(*) from payments; 13 | select 'poolstats' as "poolstats",count(*) from poolstats; 14 | select 'shareerrors' as "shareerrors",count(*) from shareerrors; 15 | select 'shares' as "shares",count(*) from shares; 16 | select 'sharesummary' as "sharesummary",count(*) from sharesummary; 17 | select 'users' as "users",count(*) from users; 18 | select 'useratts' as "useratts",count(*) from useratts; 19 | select 'userstats' as "userstats",count(*) from userstats; 20 | select 'version' as "version",count(*) from version; 21 | select 'workers' as "workers",count(*) from workers; 22 | select 'workinfo' as "workinfo",count(*) from workinfo; 23 | select 'workmarkers' as "workmarkers",count(*) from workmarkers; 24 | \t 25 | -------------------------------------------------------------------------------- /sql/v0.6-v0.7.sql: -------------------------------------------------------------------------------- 1 | SET SESSION AUTHORIZATION 'postgres'; 2 | 3 | BEGIN transaction; 4 | 5 | DO $$ 6 | DECLARE ver TEXT; 7 | BEGIN 8 | 9 | UPDATE version set version='0.7' where vlock=1 and version='0.6'; 10 | 11 | IF found THEN 12 | RETURN; 13 | END IF; 14 | 15 | SELECT version into ver from version 16 | WHERE vlock=1; 17 | 18 | RAISE EXCEPTION 'Wrong DB version - expect "0.6" - found "%"', ver; 19 | 20 | END $$; 21 | 22 | ALTER TABLE ONLY sharesummary 23 | ADD COLUMN lastdiffacc float DEFAULT 0; 24 | 25 | ALTER TABLE ONLY sharesummary 26 | ALTER COLUMN lastdiffacc DROP DEFAULT; 27 | 28 | END transaction; 29 | -------------------------------------------------------------------------------- /sql/v0.7-v0.8.sql: -------------------------------------------------------------------------------- 1 | SET SESSION AUTHORIZATION 'postgres'; 2 | 3 | BEGIN transaction; 4 | 5 | DO $$ 6 | DECLARE ver TEXT; 7 | BEGIN 8 | 9 | UPDATE version set version='0.8' where vlock=1 and version='0.7'; 10 | 11 | IF found THEN 12 | RETURN; 13 | END IF; 14 | 15 | SELECT version into ver from version 16 | WHERE vlock=1; 17 | 18 | RAISE EXCEPTION 'Wrong DB version - expect "0.7" - found "%"', ver; 19 | 20 | END $$; 21 | 22 | ALTER TABLE ONLY auths 23 | ADD COLUMN preauth char DEFAULT 'N' NOT NULL; 24 | 25 | ALTER TABLE ONLY blocks 26 | ADD COLUMN diffacc float DEFAULT 0 NOT NULL, 27 | ADD COLUMN differr float DEFAULT 0 NOT NULL, 28 | ADD COLUMN sharecount bigint DEFAULT 0 NOT NULL, 29 | ADD COLUMN errorcount bigint DEFAULT 0 NOT NULL, 30 | ADD COLUMN elapsed bigint DEFAULT 0 NOT NULL; 31 | 32 | END transaction; 33 | -------------------------------------------------------------------------------- /sql/v0.8-v0.9.sql: -------------------------------------------------------------------------------- 1 | SET SESSION AUTHORIZATION 'postgres'; 2 | 3 | BEGIN transaction; 4 | 5 | DO $$ 6 | DECLARE ver TEXT; 7 | BEGIN 8 | 9 | UPDATE version set version='0.9' where vlock=1 and version='0.8'; 10 | 11 | IF found THEN 12 | RETURN; 13 | END IF; 14 | 15 | SELECT version into ver from version 16 | WHERE vlock=1; 17 | 18 | RAISE EXCEPTION 'Wrong DB version - expect "0.8" - found "%"', ver; 19 | 20 | END $$; 21 | 22 | DROP TABLE IF EXISTS workmarkers; 23 | 24 | CREATE TABLE workmarkers ( 25 | markerid bigint NOT NULL, 26 | workinfoidend bigint NOT NULL, 27 | workinfoidstart bigint NOT NULL, 28 | description character varying(256) DEFAULT ''::character varying NOT NULL, 29 | createdate timestamp with time zone NOT NULL, 30 | createby character varying(64) DEFAULT ''::character varying NOT NULL, 31 | createcode character varying(128) DEFAULT ''::character varying NOT NULL, 32 | createinet character varying(128) DEFAULT ''::character varying NOT NULL, 33 | expirydate timestamp with time zone DEFAULT '6666-06-06 06:06:06+00', 34 | PRIMARY KEY (markerid) 35 | ); 36 | 37 | ALTER TABLE ONLY blocks 38 | DROP COLUMN differr, 39 | DROP COLUMN sharecount, 40 | DROP COLUMN errorcount, 41 | ADD COLUMN diffinv float DEFAULT 0 NOT NULL, 42 | ADD COLUMN shareacc float DEFAULT 0 NOT NULL, 43 | ADD COLUMN shareinv float DEFAULT 0 NOT NULL, 44 | ADD COLUMN statsconfirmed char DEFAULT 'N' NOT NULL; 45 | 46 | END transaction; 47 | -------------------------------------------------------------------------------- /sql/v0.9-v0.9.1.sql: -------------------------------------------------------------------------------- 1 | SET SESSION AUTHORIZATION 'postgres'; 2 | 3 | BEGIN transaction; 4 | 5 | DO $$ 6 | DECLARE ver TEXT; 7 | BEGIN 8 | 9 | UPDATE version set version='0.9.1' where vlock=1 and version='0.9'; 10 | 11 | IF found THEN 12 | RETURN; 13 | END IF; 14 | 15 | SELECT version into ver from version 16 | WHERE vlock=1; 17 | 18 | RAISE EXCEPTION 'Wrong DB version - expect "0.9" - found "%"', ver; 19 | 20 | END $$; 21 | 22 | CREATE TABLE useratts ( 23 | userid bigint NOT NULL, 24 | attname character varying(64) NOT NULL, 25 | attstr character varying(256) DEFAULT ''::character varying NOT NULL, 26 | attstr2 character varying(256) DEFAULT ''::character varying NOT NULL, 27 | attnum bigint DEFAULT 0 NOT NULL, 28 | attnum2 bigint DEFAULT 0 NOT NULL, 29 | attdate timestamp with time zone DEFAULT '1970-01-01 00:00:00+00', 30 | attdate2 timestamp with time zone DEFAULT '1970-01-01 00:00:00+00', 31 | createdate timestamp with time zone NOT NULL, 32 | createby character varying(64) DEFAULT ''::character varying NOT NULL, 33 | createcode character varying(128) DEFAULT ''::character varying NOT NULL, 34 | createinet character varying(128) DEFAULT ''::character varying NOT NULL, 35 | expirydate timestamp with time zone DEFAULT '6666-06-06 06:06:06+00', 36 | PRIMARY KEY (userid, attname, expirydate) 37 | ); 38 | 39 | ALTER TABLE ONLY users 40 | ADD COLUMN salt character varying(256) DEFAULT ''::character varying NOT NULL; 41 | 42 | END transaction; 43 | -------------------------------------------------------------------------------- /sql/v0.9.1-v0.9.2.sql: -------------------------------------------------------------------------------- 1 | SET SESSION AUTHORIZATION 'postgres'; 2 | 3 | BEGIN transaction; 4 | 5 | DO $$ 6 | DECLARE ver TEXT; 7 | BEGIN 8 | 9 | UPDATE version set version='0.9.2' where vlock=1 and version='0.9.1'; 10 | 11 | IF found THEN 12 | RETURN; 13 | END IF; 14 | 15 | SELECT version into ver from version 16 | WHERE vlock=1; 17 | 18 | RAISE EXCEPTION 'Wrong DB version - expect "0.9.1" - found "%"', ver; 19 | 20 | END $$; 21 | 22 | ALTER TABLE ONLY useratts 23 | ADD COLUMN status character varying(256) DEFAULT ''::character varying NOT NULL; 24 | 25 | ALTER TABLE ONLY users 26 | ADD COLUMN status character varying(256) DEFAULT ''::character varying NOT NULL; 27 | 28 | END transaction; 29 | -------------------------------------------------------------------------------- /sql/v0.9.2-v0.9.3.sql: -------------------------------------------------------------------------------- 1 | SET SESSION AUTHORIZATION 'postgres'; 2 | 3 | BEGIN transaction; 4 | 5 | DO $$ 6 | DECLARE ver TEXT; 7 | BEGIN 8 | 9 | UPDATE version set version='0.9.3' where vlock=1 and version='0.9.2'; 10 | 11 | IF found THEN 12 | RETURN; 13 | END IF; 14 | 15 | SELECT version into ver from version 16 | WHERE vlock=1; 17 | 18 | RAISE EXCEPTION 'Wrong DB version - expect "0.9.2" - found "%"', ver; 19 | 20 | END $$; 21 | 22 | DROP table workmarkers; 23 | 24 | CREATE TABLE workmarkers ( -- range of workinfo for share accounting 25 | markerid bigint NOT NULL, 26 | poolinstance character varying(256) NOT NULL, 27 | workinfoidend bigint NOT NULL, 28 | workinfoidstart bigint NOT NULL, 29 | description character varying(256) DEFAULT ''::character varying NOT NULL, 30 | status char NOT NULL, 31 | createdate timestamp with time zone NOT NULL, 32 | createby character varying(64) DEFAULT ''::character varying NOT NULL, 33 | createcode character varying(128) DEFAULT ''::character varying NOT NULL, 34 | createinet character varying(128) DEFAULT ''::character varying NOT NULL, 35 | expirydate timestamp with time zone DEFAULT '6666-06-06 06:06:06+00', 36 | PRIMARY KEY (markerid) 37 | ); 38 | 39 | DROP table markersummary; 40 | 41 | CREATE TABLE markersummary ( -- sum of sharesummary for a workinfo range 42 | markerid bigint NOT NULL, 43 | userid bigint NOT NULL, 44 | workername character varying(256) NOT NULL, 45 | diffacc float NOT NULL, 46 | diffsta float NOT NULL, 47 | diffdup float NOT NULL, 48 | diffhi float NOT NULL, 49 | diffrej float NOT NULL, 50 | shareacc float NOT NULL, 51 | sharesta float NOT NULL, 52 | sharedup float NOT NULL, 53 | sharehi float NOT NULL, 54 | sharerej float NOT NULL, 55 | sharecount bigint NOT NULL, 56 | errorcount bigint NOT NULL, 57 | firstshare timestamp with time zone NOT NULL, 58 | lastshare timestamp with time zone NOT NULL, 59 | lastdiffacc float NOT NULL, 60 | createdate timestamp with time zone NOT NULL, 61 | createby character varying(64) NOT NULL, 62 | createcode character varying(128) NOT NULL, 63 | createinet character varying(128) NOT NULL, 64 | modifydate timestamp with time zone NOT NULL, 65 | modifyby character varying(64) NOT NULL, 66 | modifycode character varying(128) NOT NULL, 67 | modifyinet character varying(128) NOT NULL, 68 | PRIMARY KEY (markerid, userid, workername) 69 | ); 70 | 71 | END transaction; 72 | -------------------------------------------------------------------------------- /sql/v0.9.3-v0.9.4.sql: -------------------------------------------------------------------------------- 1 | SET SESSION AUTHORIZATION 'postgres'; 2 | 3 | BEGIN transaction; 4 | 5 | DO $$ 6 | DECLARE ver TEXT; 7 | BEGIN 8 | 9 | UPDATE version set version='0.9.4' where vlock=1 and version='0.9.3'; 10 | 11 | IF found THEN 12 | RETURN; 13 | END IF; 14 | 15 | SELECT version into ver from version 16 | WHERE vlock=1; 17 | 18 | RAISE EXCEPTION 'Wrong DB version - expect "0.9.3" - found "%"', ver; 19 | 20 | END $$; 21 | 22 | ALTER TABLE sharesummary DROP CONSTRAINT sharesummary_pkey; 23 | 24 | ALTER TABLE sharesummary ADD CONSTRAINT sharesummary_pkey 25 | PRIMARY KEY (workinfoid, userid, workername); 26 | 27 | END transaction; 28 | -------------------------------------------------------------------------------- /sql/v0.9.4-v0.9.5.sql: -------------------------------------------------------------------------------- 1 | SET SESSION AUTHORIZATION 'postgres'; 2 | 3 | BEGIN transaction; 4 | 5 | DO $$ 6 | DECLARE ver TEXT; 7 | BEGIN 8 | 9 | UPDATE version set version='0.9.5' where vlock=1 and version='0.9.4'; 10 | 11 | IF found THEN 12 | RETURN; 13 | END IF; 14 | 15 | SELECT version into ver from version 16 | WHERE vlock=1; 17 | 18 | RAISE EXCEPTION 'Wrong DB version - expect "0.9.4" - found "%"', ver; 19 | 20 | END $$; 21 | 22 | CREATE TABLE marks ( -- workinfoids to make workmarkers 23 | poolinstance character varying(256) NOT NULL, 24 | workinfoid bigint NOT NULL, 25 | description character varying(256) DEFAULT ''::character varying NOT NULL, 26 | marktype char NOT NULL, -- 'b'lock(end) 'p'plns-begin 's'hift-begin 'e'=shift-end 27 | status char NOT NULL, 28 | createdate timestamp with time zone NOT NULL, 29 | createby character varying(64) DEFAULT ''::character varying NOT NULL, 30 | createcode character varying(128) DEFAULT ''::character varying NOT NULL, 31 | createinet character varying(128) DEFAULT ''::character varying NOT NULL, 32 | expirydate timestamp with time zone DEFAULT '6666-06-06 06:06:06+00', 33 | PRIMARY KEY (poolinstance, workinfoid, expirydate) 34 | ); 35 | 36 | ALTER TABLE workmarkers DROP CONSTRAINT workmarkers_pkey; 37 | 38 | ALTER TABLE workmarkers ADD CONSTRAINT workmarkers_pkey 39 | PRIMARY KEY (markerid, expirydate); 40 | 41 | END transaction; 42 | -------------------------------------------------------------------------------- /sql/v0.9.5-v0.9.6.sql: -------------------------------------------------------------------------------- 1 | SET SESSION AUTHORIZATION 'postgres'; 2 | 3 | BEGIN transaction; 4 | 5 | DO $$ 6 | DECLARE ver TEXT; 7 | BEGIN 8 | 9 | UPDATE version set version='0.9.6' where vlock=1 and version='0.9.5'; 10 | 11 | IF found THEN 12 | RETURN; 13 | END IF; 14 | 15 | SELECT version into ver from version 16 | WHERE vlock=1; 17 | 18 | RAISE EXCEPTION 'Wrong DB version - expect "0.9.5" - found "%"', ver; 19 | 20 | END $$; 21 | 22 | DROP TABLE marks; 23 | 24 | CREATE TABLE marks ( -- workinfoids to make workmarkers 25 | poolinstance character varying(256) NOT NULL, 26 | workinfoid bigint NOT NULL, 27 | description character varying(256) DEFAULT ''::character varying NOT NULL, 28 | extra character varying(256) DEFAULT ''::character varying NOT NULL, 29 | marktype char NOT NULL, -- 'b'lock(end) 'p'plns-begin 's'hift-begin 'e'=shift-end 30 | status char NOT NULL, 31 | createdate timestamp with time zone NOT NULL, 32 | createby character varying(64) DEFAULT ''::character varying NOT NULL, 33 | createcode character varying(128) DEFAULT ''::character varying NOT NULL, 34 | createinet character varying(128) DEFAULT ''::character varying NOT NULL, 35 | expirydate timestamp with time zone DEFAULT '6666-06-06 06:06:06+00', 36 | PRIMARY KEY (poolinstance, workinfoid, expirydate) 37 | ); 38 | 39 | END transaction; 40 | -------------------------------------------------------------------------------- /sql/v0.9.6-v1.0.0.sql: -------------------------------------------------------------------------------- 1 | SET SESSION AUTHORIZATION 'postgres'; 2 | 3 | BEGIN transaction; 4 | 5 | DO $$ 6 | DECLARE ver TEXT; 7 | BEGIN 8 | 9 | UPDATE version set version='1.0.0' where vlock=1 and version='0.9.6'; 10 | 11 | IF found THEN 12 | RETURN; 13 | END IF; 14 | 15 | SELECT version into ver from version 16 | WHERE vlock=1; 17 | 18 | RAISE EXCEPTION 'Wrong DB version - expect "0.9.6" - found "%"', ver; 19 | 20 | END $$; 21 | 22 | DROP TABLE payments; 23 | CREATE TABLE payments ( 24 | paymentid bigint NOT NULL, -- unique per record 25 | payoutid bigint NOT NULL, 26 | userid bigint NOT NULL, 27 | subname character varying(256) NOT NULL, 28 | paydate timestamp with time zone NOT NULL, 29 | payaddress character varying(256) DEFAULT ''::character varying NOT NULL, 30 | originaltxn character varying(256) DEFAULT ''::character varying NOT NULL, 31 | amount bigint NOT NULL, -- satoshis 32 | diffacc float DEFAULT 0 NOT NULL, 33 | committxn character varying(256) DEFAULT ''::character varying NOT NULL, 34 | commitblockhash character varying(256) DEFAULT ''::character varying NOT NULL, 35 | createdate timestamp with time zone NOT NULL, 36 | createby character varying(64) DEFAULT ''::character varying NOT NULL, 37 | createcode character varying(128) DEFAULT ''::character varying NOT NULL, 38 | createinet character varying(128) DEFAULT ''::character varying NOT NULL, 39 | expirydate timestamp with time zone DEFAULT '6666-06-06 06:06:06+00', 40 | PRIMARY KEY (paymentid, expirydate) 41 | ); 42 | CREATE UNIQUE INDEX payuserid ON payments USING btree (payoutid, userid, subname, payaddress, originaltxn, expirydate); 43 | 44 | DROP TABLE accountbalance; 45 | CREATE TABLE accountbalance ( -- summarised from miningpayouts and payments - RAM only 46 | userid bigint NOT NULL, 47 | confirmedpaid bigint DEFAULT 0 NOT NULL, -- satoshis 48 | confirmedunpaid bigint DEFAULT 0 NOT NULL, -- satoshis 49 | pendingconfirm bigint DEFAULT 0 NOT NULL, -- satoshis 50 | heightupdate integer not NULL, 51 | createdate timestamp with time zone NOT NULL, 52 | createby character varying(64) DEFAULT ''::character varying NOT NULL, 53 | createcode character varying(128) DEFAULT ''::character varying NOT NULL, 54 | createinet character varying(128) DEFAULT ''::character varying NOT NULL, 55 | modifydate timestamp with time zone DEFAULT '6666-06-06 06:06:06+00', 56 | modifyby character varying(64) DEFAULT ''::character varying NOT NULL, 57 | modifycode character varying(128) DEFAULT ''::character varying NOT NULL, 58 | modifyinet character varying(128) DEFAULT ''::character varying NOT NULL, 59 | PRIMARY KEY (userid) 60 | ); 61 | 62 | DROP TABLE miningpayouts; 63 | CREATE TABLE miningpayouts ( 64 | payoutid bigint NOT NULL, 65 | userid bigint NOT NULL, 66 | diffacc float DEFAULT 0 NOT NULL, 67 | amount bigint DEFAULT 0 NOT NULL, -- satoshis 68 | createdate timestamp with time zone NOT NULL, 69 | createby character varying(64) DEFAULT ''::character varying NOT NULL, 70 | createcode character varying(128) DEFAULT ''::character varying NOT NULL, 71 | createinet character varying(128) DEFAULT ''::character varying NOT NULL, 72 | expirydate timestamp with time zone DEFAULT '6666-06-06 06:06:06+00', 73 | PRIMARY KEY (payoutid, userid, expirydate) 74 | ); 75 | 76 | CREATE TABLE payouts ( 77 | payoutid bigint NOT NULL, -- unique per record 78 | height integer not NULL, 79 | blockhash character varying(256) NOT NULL, 80 | minerreward bigint NOT NULL, -- satoshis 81 | workinfoidstart bigint NOT NULL, 82 | workinfoidend bigint NOT NULL, -- should be block workinfoid 83 | elapsed bigint NOT NULL, 84 | status char DEFAULT ' ' NOT NULL, 85 | diffwanted float DEFAULT 0 NOT NULL, 86 | diffused float DEFAULT 0 NOT NULL, 87 | shareacc float DEFAULT 0 NOT NULL, 88 | lastshareacc timestamp with time zone NOT NULL, 89 | stats text DEFAULT ''::text NOT NULL, 90 | createdate timestamp with time zone NOT NULL, 91 | createby character varying(64) DEFAULT ''::character varying NOT NULL, 92 | createcode character varying(128) DEFAULT ''::character varying NOT NULL, 93 | createinet character varying(128) DEFAULT ''::character varying NOT NULL, 94 | expirydate timestamp with time zone DEFAULT '6666-06-06 06:06:06+00', 95 | PRIMARY KEY (payoutid, expirydate) 96 | ); 97 | CREATE UNIQUE INDEX payoutsblock ON payouts USING btree (height, blockhash, expirydate); 98 | 99 | insert into idcontrol (idname,lastid,createdate,createby) values ('payoutid',999,now(),'1.0.0update'); 100 | 101 | END transaction; 102 | -------------------------------------------------------------------------------- /sql/v1.0.0-v1.0.1.sql: -------------------------------------------------------------------------------- 1 | SET SESSION AUTHORIZATION 'postgres'; 2 | 3 | BEGIN transaction; 4 | 5 | DO $$ 6 | DECLARE ver TEXT; 7 | BEGIN 8 | 9 | UPDATE version set version='1.0.1' where vlock=1 and version='1.0.0'; 10 | 11 | IF found THEN 12 | RETURN; 13 | END IF; 14 | 15 | SELECT version into ver from version 16 | WHERE vlock=1; 17 | 18 | RAISE EXCEPTION 'Wrong DB version - expect "1.0.0" - found "%"', ver; 19 | 20 | END $$; 21 | 22 | ALTER TABLE ONLY users 23 | ADD COLUMN userdata text DEFAULT ''::text NOT NULL, 24 | ADD COLUMN userbits bigint NOT NULL DEFAULT 0; 25 | 26 | ALTER TABLE ONLY users 27 | ALTER COLUMN userbits DROP DEFAULT; 28 | 29 | -- match based on ckdb_data.c like_address() 30 | UPDATE users set userbits=1 where username ~ '[13][A-HJ-NP-Za-km-z1-9]{15,}'; 31 | 32 | ALTER TABLE ONLY workers 33 | ADD COLUMN workerbits bigint NOT NULL DEFAULT 0; 34 | 35 | ALTER TABLE ONLY workers 36 | ALTER COLUMN workerbits DROP DEFAULT; 37 | 38 | END transaction; 39 | -------------------------------------------------------------------------------- /sql/v1.0.1-v1.0.2.sql: -------------------------------------------------------------------------------- 1 | SET SESSION AUTHORIZATION 'postgres'; 2 | 3 | BEGIN transaction; 4 | 5 | DO $$ 6 | DECLARE ver TEXT; 7 | BEGIN 8 | 9 | UPDATE version set version='1.0.2' where vlock=1 and version='1.0.1'; 10 | 11 | IF found THEN 12 | RETURN; 13 | END IF; 14 | 15 | SELECT version into ver from version 16 | WHERE vlock=1; 17 | 18 | RAISE EXCEPTION 'Wrong DB version - expect "1.0.1" - found "%"', ver; 19 | 20 | END $$; 21 | 22 | ALTER TABLE ONLY blocks 23 | ADD COLUMN info character varying(64) DEFAULT ''::character varying NOT NULL; 24 | 25 | END transaction; 26 | -------------------------------------------------------------------------------- /sql/v1.0.2-v1.0.3.sql: -------------------------------------------------------------------------------- 1 | SET SESSION AUTHORIZATION 'postgres'; 2 | 3 | BEGIN transaction; 4 | 5 | DO $$ 6 | DECLARE ver TEXT; 7 | BEGIN 8 | 9 | UPDATE version set version='1.0.3' where vlock=1 and version='1.0.2'; 10 | 11 | IF found THEN 12 | RETURN; 13 | END IF; 14 | 15 | SELECT version into ver from version 16 | WHERE vlock=1; 17 | 18 | RAISE EXCEPTION 'Wrong DB version - expect "1.0.2" - found "%"', ver; 19 | 20 | END $$; 21 | 22 | ALTER TABLE ONLY markersummary 23 | ADD COLUMN firstshareacc timestamp with time zone DEFAULT '1970-01-01 00:00:00+00' NOT NULL, 24 | ADD COLUMN lastshareacc timestamp with time zone DEFAULT '1970-01-01 00:00:00+00' NOT NULL; 25 | 26 | ALTER TABLE ONLY markersummary 27 | ALTER COLUMN firstshareacc DROP DEFAULT, 28 | ALTER COLUMN lastshareacc DROP DEFAULT; 29 | 30 | ALTER TABLE ONLY sharesummary 31 | ADD COLUMN firstshareacc timestamp with time zone DEFAULT '1970-01-01 00:00:00+00' NOT NULL, 32 | ADD COLUMN lastshareacc timestamp with time zone DEFAULT '1970-01-01 00:00:00+00' NOT NULL; 33 | 34 | ALTER TABLE ONLY sharesummary 35 | ALTER COLUMN firstshareacc DROP DEFAULT, 36 | ALTER COLUMN lastshareacc DROP DEFAULT; 37 | 38 | END transaction; 39 | -------------------------------------------------------------------------------- /sql/v1.0.3-v1.0.4.sql: -------------------------------------------------------------------------------- 1 | SET SESSION AUTHORIZATION 'postgres'; 2 | 3 | BEGIN transaction; 4 | 5 | DO $$ 6 | DECLARE ver TEXT; 7 | BEGIN 8 | 9 | UPDATE version set version='1.0.4' where vlock=1 and version='1.0.3'; 10 | 11 | IF found THEN 12 | RETURN; 13 | END IF; 14 | 15 | SELECT version into ver from version 16 | WHERE vlock=1; 17 | 18 | RAISE EXCEPTION 'Wrong DB version - expect "1.0.3" - found "%"', ver; 19 | 20 | END $$; 21 | 22 | ALTER TABLE ONLY paymentaddresses 23 | ADD COLUMN payname character varying(64) DEFAULT ''::character varying NOT NULL, 24 | ADD COLUMN status char DEFAULT ' ' NOT NULL; 25 | 26 | END transaction; 27 | -------------------------------------------------------------------------------- /sql/v1.0.4-v1.0.5.sql: -------------------------------------------------------------------------------- 1 | SET SESSION AUTHORIZATION 'postgres'; 2 | 3 | BEGIN transaction; 4 | 5 | DO $$ 6 | DECLARE ver TEXT; 7 | BEGIN 8 | 9 | UPDATE version set version='1.0.5' where vlock=1 and version='1.0.4'; 10 | 11 | IF found THEN 12 | RETURN; 13 | END IF; 14 | 15 | SELECT version into ver from version 16 | WHERE vlock=1; 17 | 18 | RAISE EXCEPTION 'Wrong DB version - expect "1.0.4" - found "%"', ver; 19 | 20 | END $$; 21 | 22 | ALTER TABLE ONLY shares 23 | ADD COLUMN ntime character varying(64) DEFAULT ''::character varying NOT NULL, 24 | ADD COLUMN minsdiff float DEFAULT 0::float NOT NULL; 25 | 26 | ALTER TABLE ONLY shares 27 | ALTER COLUMN ntime DROP DEFAULT, 28 | ALTER COLUMN minsdiff DROP DEFAULT; 29 | 30 | END transaction; 31 | -------------------------------------------------------------------------------- /sql/v1.0.5-v1.0.6.sql: -------------------------------------------------------------------------------- 1 | SET SESSION AUTHORIZATION 'postgres'; 2 | 3 | BEGIN transaction; 4 | 5 | DO $$ 6 | DECLARE ver TEXT; 7 | BEGIN 8 | 9 | UPDATE version set version='1.0.6' where vlock=1 and version='1.0.5'; 10 | 11 | IF found THEN 12 | RETURN; 13 | END IF; 14 | 15 | SELECT version into ver from version 16 | WHERE vlock=1; 17 | 18 | RAISE EXCEPTION 'Wrong DB version - expect "1.0.5" - found "%"', ver; 19 | 20 | END $$; 21 | 22 | ALTER TABLE ONLY shares 23 | ADD COLUMN agent character varying(128) DEFAULT ''::character varying NOT NULL, 24 | ADD COLUMN address character varying(128) DEFAULT ''::character varying NOT NULL; 25 | 26 | END transaction; 27 | -------------------------------------------------------------------------------- /sql/v1.0.6-v1.0.7.sql: -------------------------------------------------------------------------------- 1 | SET SESSION AUTHORIZATION 'postgres'; 2 | 3 | BEGIN transaction; 4 | 5 | DO $$ 6 | DECLARE ver TEXT; 7 | BEGIN 8 | 9 | UPDATE version set version='1.0.7' where vlock=1 and version='1.0.6'; 10 | 11 | IF found THEN 12 | RETURN; 13 | END IF; 14 | 15 | SELECT version into ver from version 16 | WHERE vlock=1; 17 | 18 | RAISE EXCEPTION 'Wrong DB version - expect "1.0.6" - found "%"', ver; 19 | 20 | END $$; 21 | 22 | CREATE TABLE keysummary ( 23 | markerid bigint NOT NULL, 24 | keytype char NOT NULL, 25 | key character varying(128) NOT NULL, 26 | diffacc float NOT NULL, 27 | diffsta float NOT NULL, 28 | diffdup float NOT NULL, 29 | diffhi float NOT NULL, 30 | diffrej float NOT NULL, 31 | shareacc float NOT NULL, 32 | sharesta float NOT NULL, 33 | sharedup float NOT NULL, 34 | sharehi float NOT NULL, 35 | sharerej float NOT NULL, 36 | sharecount bigint NOT NULL, 37 | errorcount bigint NOT NULL, 38 | firstshare timestamp with time zone NOT NULL, 39 | lastshare timestamp with time zone NOT NULL, 40 | firstshareacc timestamp with time zone NOT NULL, 41 | lastshareacc timestamp with time zone NOT NULL, 42 | lastdiffacc float NOT NULL, 43 | createdate timestamp with time zone NOT NULL, 44 | createby character varying(64) NOT NULL, 45 | createcode character varying(128) NOT NULL, 46 | createinet character varying(128) NOT NULL, 47 | PRIMARY KEY (markerid, keytype, key) 48 | ); 49 | 50 | -- only in RAM so no need for it in the DB - for a while now 51 | DROP table sharesummary; 52 | 53 | END transaction; 54 | -------------------------------------------------------------------------------- /sql/v1.0.7-v1.0.8.sql: -------------------------------------------------------------------------------- 1 | SET SESSION AUTHORIZATION 'postgres'; 2 | 3 | BEGIN transaction; 4 | 5 | DO $$ 6 | DECLARE ver TEXT; 7 | BEGIN 8 | 9 | UPDATE version set version='1.0.8' where vlock=1 and version='1.0.7'; 10 | 11 | IF found THEN 12 | RETURN; 13 | END IF; 14 | 15 | SELECT version into ver from version 16 | WHERE vlock=1; 17 | 18 | RAISE EXCEPTION 'Wrong DB version - expect "1.0.7" - found "%"', ver; 19 | 20 | END $$; 21 | 22 | ALTER TABLE workinfo ALTER COLUMN coinbase2 TYPE varchar(511); 23 | 24 | END transaction; 25 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = jansson-2.10 2 | 3 | ACLOCAL_AMFLAGS = -I m4 4 | AM_CPPFLAGS = -I$(top_srcdir)/src/jansson-2.10/src 5 | 6 | native_objs := 7 | 8 | if HAVE_AVX2 9 | native_objs += sha256_code_release/sha256_avx2_rorx2.A 10 | endif 11 | if HAVE_AVX1 12 | native_objs += sha256_code_release/sha256_avx1.A 13 | endif 14 | if HAVE_SSE4 15 | native_objs += sha256_code_release/sha256_sse4.A 16 | endif 17 | 18 | %.A: %.asm 19 | yasm -f x64 -f elf64 -X gnu -g dwarf2 -D LINUX -o $@ $< 20 | 21 | noinst_LIBRARIES = libckpool.a 22 | libckpool_a_SOURCES = libckpool.c libckpool.h sha2.c sha2.h 23 | libckpool_a_LIBADD = $(native_objs) 24 | 25 | bin_PROGRAMS = ckpool ckpmsg notifier 26 | ckpool_SOURCES = ckpool.c ckpool.h generator.c generator.h bitcoin.c bitcoin.h \ 27 | stratifier.c stratifier.h connector.c connector.h uthash.h \ 28 | utlist.h 29 | ckpool_LDADD = libckpool.a @JANSSON_LIBS@ @LIBS@ 30 | 31 | ckpmsg_SOURCES = ckpmsg.c 32 | ckpmsg_LDADD = libckpool.a @JANSSON_LIBS@ 33 | 34 | notifier_SOURCES = notifier.c 35 | notifier_LDADD = libckpool.a @JANSSON_LIBS@ 36 | 37 | if WANT_CKDB 38 | bin_PROGRAMS += ckdb 39 | ckdb_SOURCES = ckdb.c ckdb_cmd.c ckdb_data.c ckdb_dbio.c ckdb_btc.c \ 40 | ckdb_crypt.c ckdb.h klist.c ktree.c klist.h ktree.h 41 | ckdb_LDADD = libckpool.a @JANSSON_LIBS@ @LIBS@ 42 | endif 43 | -------------------------------------------------------------------------------- /src/bitcoin.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2017 Con Kolivas 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms of the GNU General Public License as published by the Free 6 | * Software Foundation; either version 3 of the License, or (at your option) 7 | * any later version. See COPYING for more details. 8 | */ 9 | 10 | #ifndef BITCOIN_H 11 | #define BITCOIN_H 12 | 13 | typedef struct genwork gbtbase_t; 14 | 15 | bool validate_address(connsock_t *cs, const char *address); 16 | bool gen_gbtbase(connsock_t *cs, gbtbase_t *gbt); 17 | void clear_gbtbase(gbtbase_t *gbt); 18 | int get_blockcount(connsock_t *cs); 19 | bool get_blockhash(connsock_t *cs, int height, char *hash); 20 | bool get_bestblockhash(connsock_t *cs, char *hash); 21 | bool submit_block(connsock_t *cs, const char *params); 22 | void precious_block(connsock_t *cs, const char *params); 23 | void submit_txn(connsock_t *cs, const char *params); 24 | char *get_txn(connsock_t *cs, const char *hash); 25 | 26 | #endif /* BITCOIN_H */ 27 | -------------------------------------------------------------------------------- /src/ckdb.php: -------------------------------------------------------------------------------- 1 | 1) 57 | { 58 | if ($argv[1] == '-?' || $argv[1] == '-h' || $argv[1] == '-help' 59 | || $argv[1] == '--help') 60 | usAge($argv[0]); 61 | 62 | $a = 1; 63 | if ($argv[$a] == '-t') 64 | { 65 | $tabs = false; 66 | $a++; 67 | } 68 | $socket_name = $argv[$a++]; 69 | if (count($argv) > $a) 70 | { 71 | $socket_dir = $argv[$a++]; 72 | if (count($argv) > $a) 73 | $socket_file = $argv[$a]; 74 | } 75 | } 76 | # 77 | while ($line = fgets(STDIN)) 78 | { 79 | $line = trim($line); 80 | if (strlen($line) > 0) 81 | { 82 | $rep = msg($line, $tabs); 83 | if ($rep === false) 84 | echo "Failed\n"; 85 | else 86 | echo "$rep\n"; 87 | } 88 | } 89 | ?> 90 | -------------------------------------------------------------------------------- /src/cmd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | tab=" " 4 | # 5 | cmd=" 6 | a genoff - turn off mark and payout generation (2 commands) 7 | b genon - turn on mark and payout generation (2 commands) 8 | c hold user - put a payout hold on user 9 | d lock user reason - put a mining lock on user| a blank reason unlocks user 10 | e pay block - display payout info for block height 11 | f opay payoutid - orphan payoutid 12 | g unhold user - remove a payout hold on a user 13 | h ban ip eventname - ban an ip eventname, forever until ckdb restart 14 | i unban ip eventname - unban an ip eventname| use 'exp' to clear it afterwards 15 | j exp - remove all expired IP bans 16 | k block height - show block details 17 | l reject height blockhash - reject a block as unworthy| when it wasn't actually a block, just a close share 18 | m reject2 height blockhash type desc - reject a block with type and desc| e.g. 'Stale' and 'Share was submitted after the block changed' 19 | n terminate - I'll be back 20 | " 21 | # 22 | msg=" 23 | a marks.1.action=genoff|payouts.1.action=genoff 24 | b marks.1.action=genon|payouts.1.action=genon 25 | c setatts.1.ua_HoldPayouts.str=Y${tab}username=@user@ 26 | d userstatus.1.username=@user@${tab}status=@reason@ 27 | e query.1.request=payout${tab}height=@block@ 28 | f payouts.1.action=orphan${tab}payoutid=@payoutid@ 29 | g expatts.1.attlist=HoldPayouts${tab}username=@user@ 30 | h events.1.action=ban${tab}ip=@ip@${tab}eventname=@eventname@ 31 | i events.1.action=unban${tab}ip=@ip@${tab}eventname=@eventname@ 32 | j events.1.action=expire 33 | k query.1.request=block${tab}height=@height@ 34 | l blockstatus.1.action=reject${tab}height=@height@${tab}blockhash=@blockhash@${tab}info= 35 | m blockstatus.1.action=reject${tab}height=@height@${tab}blockhash=@blockhash@${tab}info=@type@:@desc@ 36 | n terminate 37 | " 38 | # grep pattern matching the starting field used in cmd -> msg 39 | letters="[a-n]" 40 | # params allowed to be entered as blank (but will be prompted for if blank) 41 | allowblank="|reason|" 42 | # 43 | cproc() 44 | { 45 | echo "$cmd" | cut -d' ' -f2 | tr "\n" "|" | sed -e "s/|||*/|/g" 46 | } 47 | # 48 | getex() 49 | { 50 | let="`echo "$cmd" | grep "^$letters $1 " | cut -d' ' -f1`" 51 | echo "$msg" | grep "^$let " | cut -d' ' -f2- 52 | } 53 | # 54 | dsp0() 55 | { 56 | grep -v "^$" | cut -d' ' -f2- | tr "|" "\n" | sed -e "s/^/ /" 57 | } 58 | # 59 | dsp() 60 | { 61 | echo "$cmd" | grep "^$letters $1 " | dsp0 62 | } 63 | # 64 | cmds="`cproc`" 65 | # 66 | cmdz() 67 | { 68 | echo "$cmds" | tr '|' ' ' | sed -e "s/^ *//" -e "s/ *$//" 69 | } 70 | # 71 | pars() 72 | { 73 | echo "$cmd" | grep "^$letters $1" | cut -d'-' -f1 | cut -d' ' -f3- 74 | } 75 | # 76 | show() 77 | { 78 | echo "$1" | sed -e "s/$tab/'TAB'/g" -e "s/|/ and /g" 79 | } 80 | # 81 | usAge() 82 | { 83 | echo "usAge: `basename $0` [cmd [params...]]" 84 | echo " missing cmd or required params are prompted for" 85 | echo " it's easiest to just run `basename $0` with no cmd/params :)" 86 | echo " params can't contain TAB or '|'" 87 | echo " cmd [params...] is one of:" 88 | echo "$cmd" | dsp0 89 | exit 1 90 | } 91 | # 92 | if [ "$1" = "-?" -o "$1" = "-h" -o "$1" = "-help" -o "$1" = "--help" ] ; then 93 | usAge 94 | fi 95 | # 96 | if [ -z "$1" ] ; then 97 | echo "(`cmdz`)" 98 | read -p " or '?' for help: " cm 99 | else 100 | cm="$1" 101 | fi 102 | # 103 | ok="`echo "$cmds" | grep "|$cm|"`" 104 | # 105 | if [ -z "$ok" ] ; then 106 | usAge 107 | fi 108 | # 109 | echo "`dsp $cm`" 110 | ex0="`getex $cm`" 111 | # 112 | p="1" 113 | for i in `pars $cm` ; do 114 | p="$[$p+1]" 115 | v="${@:$p:1}" 116 | if [ -z "$v" ] ; then 117 | read -p "$i: " v 118 | fi 119 | t="`echo "$v" | grep "$tab"`" 120 | if [ "$t" ] ; then 121 | echo "ERR: values can't contain TAB" 122 | usAge 123 | fi 124 | m="`echo "$v" | grep "|"`" 125 | if [ "$m" ] ; then 126 | echo "ERR: values can't contain '|'" 127 | usAge 128 | fi 129 | ab="`echo "$allowblank" | grep "|$i|"`" 130 | if [ -z "$ab" ] ; then 131 | if [ -z "$v" ] ; then 132 | echo "ERR: $i can't be blank" 133 | usAge 134 | fi 135 | fi 136 | ex="`echo "$ex0" | sed -e "s|@$i@|$v|g"`" # allow / 137 | ex0="$ex" 138 | done 139 | # 140 | s="" 141 | multi="`echo "$ex0" | grep '|'`" 142 | if [ "$multi" ] ; then 143 | s="s" 144 | fi 145 | # 146 | echo "Command$s: `show "$ex0"`" 147 | read -p "ok? (y): " ok 148 | if [ "${ok:0:1}" = "y" ] ; then 149 | echo "$ex0" | tr "|" "\n" | php ckdb.php 150 | echo "Done" 151 | else 152 | echo "Aborted" 153 | fi 154 | -------------------------------------------------------------------------------- /src/connector.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2016 Con Kolivas 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms of the GNU General Public License as published by the Free 6 | * Software Foundation; either version 3 of the License, or (at your option) 7 | * any later version. See COPYING for more details. 8 | */ 9 | 10 | #ifndef CONNECTOR_H 11 | #define CONNECTOR_H 12 | 13 | int64_t connector_newclientid(ckpool_t *ckp); 14 | void connector_upstream_msg(ckpool_t *ckp, char *msg); 15 | void connector_add_message(ckpool_t *ckp, json_t *val); 16 | char *connector_stats(void *data, const int runtime); 17 | void connector_send_fd(ckpool_t *ckp, const int fdno, const int sockd); 18 | void *connector(void *arg); 19 | 20 | #endif /* CONNECTOR_H */ 21 | -------------------------------------------------------------------------------- /src/generator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2017 Con Kolivas 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms of the GNU General Public License as published by the Free 6 | * Software Foundation; either version 3 of the License, or (at your option) 7 | * any later version. See COPYING for more details. 8 | */ 9 | 10 | #ifndef GENERATOR_H 11 | #define GENERATOR_H 12 | 13 | #include "config.h" 14 | 15 | #define GETBEST_FAILED -1 16 | #define GETBEST_NOTIFY 0 17 | #define GETBEST_SUCCESS 1 18 | 19 | void generator_add_send(ckpool_t *ckp, json_t *val); 20 | struct genwork *generator_getbase(ckpool_t *ckp); 21 | int generator_getbest(ckpool_t *ckp, char *hash); 22 | bool generator_checkaddr(ckpool_t *ckp, const char *addr); 23 | char *generator_get_txn(ckpool_t *ckp, const char *hash); 24 | bool generator_submitblock(ckpool_t *ckp, const char *buf); 25 | void generator_preciousblock(ckpool_t *ckp, const char *hash); 26 | bool generator_get_blockhash(ckpool_t *ckp, int height, char *hash); 27 | void *generator(void *arg); 28 | 29 | #endif /* GENERATOR_H */ 30 | -------------------------------------------------------------------------------- /src/jansson-2.10/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009-2016 Petri Lehtinen 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /src/jansson-2.10/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = CHANGES LICENSE README.rst 2 | SUBDIRS = src 3 | 4 | # "make distcheck" builds the dvi target, so use it to check that the 5 | # documentation is built correctly. 6 | dvi: 7 | $(MAKE) SPHINXOPTS_EXTRA=-W html 8 | 9 | pkgconfigdir = $(libdir)/pkgconfig 10 | pkgconfig_DATA = jansson.pc 11 | -------------------------------------------------------------------------------- /src/jansson-2.10/README.rst: -------------------------------------------------------------------------------- 1 | Jansson README 2 | ============== 3 | 4 | .. image:: https://travis-ci.org/akheron/jansson.png 5 | :target: https://travis-ci.org/akheron/jansson 6 | 7 | .. image:: https://ci.appveyor.com/api/projects/status/lmhkkc4q8cwc65ko 8 | :target: https://ci.appveyor.com/project/akheron/jansson 9 | 10 | .. image:: https://coveralls.io/repos/akheron/jansson/badge.png?branch=master 11 | :target: https://coveralls.io/r/akheron/jansson?branch=master 12 | 13 | Jansson_ is a C library for encoding, decoding and manipulating JSON 14 | data. Its main features and design principles are: 15 | 16 | - Simple and intuitive API and data model 17 | 18 | - `Comprehensive documentation`_ 19 | 20 | - No dependencies on other libraries 21 | 22 | - Full Unicode support (UTF-8) 23 | 24 | - Extensive test suite 25 | 26 | Jansson is licensed under the `MIT license`_; see LICENSE in the 27 | source distribution for details. 28 | 29 | 30 | Compilation and Installation 31 | ---------------------------- 32 | 33 | If you obtained a source tarball, just use the standard autotools 34 | commands:: 35 | 36 | $ ./configure 37 | $ make 38 | $ make install 39 | 40 | To run the test suite, invoke:: 41 | 42 | $ make check 43 | 44 | If the source has been checked out from a Git repository, the 45 | ./configure script has to be generated first. The easiest way is to 46 | use autoreconf:: 47 | 48 | $ autoreconf -i 49 | 50 | 51 | Documentation 52 | ------------- 53 | 54 | Documentation is available at http://jansson.readthedocs.io/en/latest/. 55 | 56 | The documentation source is in the ``doc/`` subdirectory. To generate 57 | HTML documentation, invoke:: 58 | 59 | $ make html 60 | 61 | Then, point your browser to ``doc/_build/html/index.html``. Sphinx_ 62 | 1.0 or newer is required to generate the documentation. 63 | 64 | 65 | .. _Jansson: http://www.digip.org/jansson/ 66 | .. _`Comprehensive documentation`: http://jansson.readthedocs.io/en/latest/ 67 | .. _`MIT license`: http://www.opensource.org/licenses/mit-license.php 68 | .. _Sphinx: http://sphinx.pocoo.org/ 69 | -------------------------------------------------------------------------------- /src/jansson-2.10/android/jansson_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2016 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | * 7 | * 8 | * This file specifies a part of the site-specific configuration for 9 | * Jansson, namely those things that affect the public API in 10 | * jansson.h. 11 | * 12 | * The configure script copies this file to jansson_config.h and 13 | * replaces @var@ substitutions by values that fit your system. If you 14 | * cannot run the configure script, you can do the value substitution 15 | * by hand. 16 | */ 17 | 18 | #ifndef JANSSON_CONFIG_H 19 | #define JANSSON_CONFIG_H 20 | 21 | /* If your compiler supports the inline keyword in C, JSON_INLINE is 22 | defined to `inline', otherwise empty. In C++, the inline is always 23 | supported. */ 24 | #ifdef __cplusplus 25 | #define JSON_INLINE inline 26 | #else 27 | #define JSON_INLINE inline 28 | #endif 29 | 30 | /* If your compiler supports the `long long` type and the strtoll() 31 | library function, JSON_INTEGER_IS_LONG_LONG is defined to 1, 32 | otherwise to 0. */ 33 | #define JSON_INTEGER_IS_LONG_LONG 1 34 | 35 | /* If locale.h and localeconv() are available, define to 1, 36 | otherwise to 0. */ 37 | #define JSON_HAVE_LOCALECONV 0 38 | 39 | /* Maximum recursion depth for parsing JSON input. 40 | This limits the depth of e.g. array-within-array constructions. */ 41 | #define JSON_PARSER_MAX_DEPTH 2048 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/jansson-2.10/configure.ac: -------------------------------------------------------------------------------- 1 | AC_PREREQ([2.60]) 2 | AC_INIT([jansson], [2.10], [petri@digip.org]) 3 | 4 | AC_CONFIG_AUX_DIR([.]) 5 | AM_INIT_AUTOMAKE([1.10 foreign]) 6 | 7 | AC_CONFIG_SRCDIR([src/value.c]) 8 | AC_CONFIG_HEADERS([jansson_private_config.h]) 9 | 10 | # Checks for programs. 11 | AC_PROG_CC 12 | AC_PROG_LIBTOOL 13 | AM_CONDITIONAL([GCC], [test x$GCC = xyes]) 14 | 15 | # Checks for libraries. 16 | 17 | # Checks for header files. 18 | AC_CHECK_HEADERS([endian.h fcntl.h locale.h sched.h unistd.h sys/param.h sys/stat.h sys/time.h sys/types.h]) 19 | 20 | # Checks for typedefs, structures, and compiler characteristics. 21 | AC_TYPE_INT32_T 22 | AC_TYPE_UINT32_T 23 | AC_TYPE_UINT16_T 24 | AC_TYPE_UINT8_T 25 | AC_TYPE_LONG_LONG_INT 26 | 27 | AC_C_INLINE 28 | case $ac_cv_c_inline in 29 | yes) json_inline=inline;; 30 | no) json_inline=;; 31 | *) json_inline=$ac_cv_c_inline;; 32 | esac 33 | AC_SUBST([json_inline]) 34 | 35 | # Checks for library functions. 36 | AC_CHECK_FUNCS([close getpid gettimeofday localeconv open read sched_yield strtoll]) 37 | 38 | AC_MSG_CHECKING([for gcc __sync builtins]) 39 | have_sync_builtins=no 40 | AC_TRY_LINK( 41 | [], [unsigned long val; __sync_bool_compare_and_swap(&val, 0, 1);], 42 | [have_sync_builtins=yes], 43 | ) 44 | if test "x$have_sync_builtins" = "xyes"; then 45 | AC_DEFINE([HAVE_SYNC_BUILTINS], [1], 46 | [Define to 1 if gcc's __sync builtins are available]) 47 | fi 48 | AC_MSG_RESULT([$have_sync_builtins]) 49 | 50 | AC_MSG_CHECKING([for gcc __atomic builtins]) 51 | have_atomic_builtins=no 52 | AC_TRY_LINK( 53 | [], [char l; unsigned long v; __atomic_test_and_set(&l, __ATOMIC_RELAXED); __atomic_store_n(&v, 1, __ATOMIC_RELEASE); __atomic_load_n(&v, __ATOMIC_ACQUIRE);], 54 | [have_atomic_builtins=yes], 55 | ) 56 | if test "x$have_atomic_builtins" = "xyes"; then 57 | AC_DEFINE([HAVE_ATOMIC_BUILTINS], [1], 58 | [Define to 1 if gcc's __atomic builtins are available]) 59 | fi 60 | AC_MSG_RESULT([$have_atomic_builtins]) 61 | 62 | case "$ac_cv_type_long_long_int$ac_cv_func_strtoll" in 63 | yesyes) json_have_long_long=1;; 64 | *) json_have_long_long=0;; 65 | esac 66 | AC_SUBST([json_have_long_long]) 67 | 68 | case "$ac_cv_header_locale_h$ac_cv_func_localeconv" in 69 | yesyes) json_have_localeconv=1;; 70 | *) json_have_localeconv=0;; 71 | esac 72 | AC_SUBST([json_have_localeconv]) 73 | 74 | # Features 75 | AC_ARG_ENABLE([urandom], 76 | [AS_HELP_STRING([--disable-urandom], 77 | [Don't use /dev/urandom to seed the hash function])], 78 | [use_urandom=$enableval], [use_urandom=yes]) 79 | 80 | if test "x$use_urandom" = xyes; then 81 | AC_DEFINE([USE_URANDOM], [1], 82 | [Define to 1 if /dev/urandom should be used for seeding the hash function]) 83 | fi 84 | 85 | AC_ARG_ENABLE([windows-cryptoapi], 86 | [AS_HELP_STRING([--disable-windows-cryptoapi], 87 | [Don't use CryptGenRandom to seed the hash function])], 88 | [use_windows_cryptoapi=$enableval], [use_windows_cryptoapi=yes]) 89 | 90 | if test "x$use_windows_cryptoapi" = xyes; then 91 | AC_DEFINE([USE_WINDOWS_CRYPTOAPI], [1], 92 | [Define to 1 if CryptGenRandom should be used for seeding the hash function]) 93 | fi 94 | 95 | AC_ARG_ENABLE([initial-hashtable-order], 96 | [AS_HELP_STRING([--enable-initial-hashtable-order=VAL], 97 | [Number of buckets new object hashtables contain is 2 raised to this power. The default is 3, so empty hashtables contain 2^3 = 8 buckets.])], 98 | [initial_hashtable_order=$enableval], [initial_hashtable_order=3]) 99 | AC_DEFINE_UNQUOTED([INITIAL_HASHTABLE_ORDER], [$initial_hashtable_order], 100 | [Number of buckets new object hashtables contain is 2 raised to this power. E.g. 3 -> 2^3 = 8.]) 101 | 102 | if test x$GCC = xyes; then 103 | AM_CFLAGS="-Wall -Wextra -Wdeclaration-after-statement" 104 | fi 105 | AC_SUBST([AM_CFLAGS]) 106 | 107 | AC_CONFIG_FILES([ 108 | jansson.pc 109 | Makefile 110 | src/Makefile 111 | src/jansson_config.h 112 | ]) 113 | AC_OUTPUT 114 | -------------------------------------------------------------------------------- /src/jansson-2.10/jansson.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=${prefix}/include 5 | 6 | Name: Jansson 7 | Description: Library for encoding, decoding and manipulating JSON data 8 | Version: @VERSION@ 9 | Libs: -L${libdir} -ljansson 10 | Cflags: -I${includedir} 11 | -------------------------------------------------------------------------------- /src/jansson-2.10/jansson_private_config.h.in: -------------------------------------------------------------------------------- 1 | /* jansson_private_config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if gcc's __atomic builtins are available */ 4 | #undef HAVE_ATOMIC_BUILTINS 5 | 6 | /* Define to 1 if you have the `close' function. */ 7 | #undef HAVE_CLOSE 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_DLFCN_H 11 | 12 | /* Define to 1 if you have the header file. */ 13 | #undef HAVE_ENDIAN_H 14 | 15 | /* Define to 1 if you have the header file. */ 16 | #undef HAVE_FCNTL_H 17 | 18 | /* Define to 1 if you have the `getpid' function. */ 19 | #undef HAVE_GETPID 20 | 21 | /* Define to 1 if you have the `gettimeofday' function. */ 22 | #undef HAVE_GETTIMEOFDAY 23 | 24 | /* Define to 1 if you have the header file. */ 25 | #undef HAVE_INTTYPES_H 26 | 27 | /* Define to 1 if you have the `localeconv' function. */ 28 | #undef HAVE_LOCALECONV 29 | 30 | /* Define to 1 if you have the header file. */ 31 | #undef HAVE_LOCALE_H 32 | 33 | /* Define to 1 if the system has the type 'long long int'. */ 34 | #undef HAVE_LONG_LONG_INT 35 | 36 | /* Define to 1 if you have the header file. */ 37 | #undef HAVE_MEMORY_H 38 | 39 | /* Define to 1 if you have the `open' function. */ 40 | #undef HAVE_OPEN 41 | 42 | /* Define to 1 if you have the `read' function. */ 43 | #undef HAVE_READ 44 | 45 | /* Define to 1 if you have the header file. */ 46 | #undef HAVE_SCHED_H 47 | 48 | /* Define to 1 if you have the `sched_yield' function. */ 49 | #undef HAVE_SCHED_YIELD 50 | 51 | /* Define to 1 if you have the header file. */ 52 | #undef HAVE_STDINT_H 53 | 54 | /* Define to 1 if you have the header file. */ 55 | #undef HAVE_STDLIB_H 56 | 57 | /* Define to 1 if you have the header file. */ 58 | #undef HAVE_STRINGS_H 59 | 60 | /* Define to 1 if you have the header file. */ 61 | #undef HAVE_STRING_H 62 | 63 | /* Define to 1 if you have the `strtoll' function. */ 64 | #undef HAVE_STRTOLL 65 | 66 | /* Define to 1 if gcc's __sync builtins are available */ 67 | #undef HAVE_SYNC_BUILTINS 68 | 69 | /* Define to 1 if you have the header file. */ 70 | #undef HAVE_SYS_PARAM_H 71 | 72 | /* Define to 1 if you have the header file. */ 73 | #undef HAVE_SYS_STAT_H 74 | 75 | /* Define to 1 if you have the header file. */ 76 | #undef HAVE_SYS_TIME_H 77 | 78 | /* Define to 1 if you have the header file. */ 79 | #undef HAVE_SYS_TYPES_H 80 | 81 | /* Define to 1 if you have the header file. */ 82 | #undef HAVE_UNISTD_H 83 | 84 | /* Define to 1 if the system has the type 'unsigned long long int'. */ 85 | #undef HAVE_UNSIGNED_LONG_LONG_INT 86 | 87 | /* Number of buckets new object hashtables contain is 2 raised to this power. 88 | E.g. 3 -> 2^3 = 8. */ 89 | #undef INITIAL_HASHTABLE_ORDER 90 | 91 | /* Define to the sub-directory where libtool stores uninstalled libraries. */ 92 | #undef LT_OBJDIR 93 | 94 | /* Name of package */ 95 | #undef PACKAGE 96 | 97 | /* Define to the address where bug reports for this package should be sent. */ 98 | #undef PACKAGE_BUGREPORT 99 | 100 | /* Define to the full name of this package. */ 101 | #undef PACKAGE_NAME 102 | 103 | /* Define to the full name and version of this package. */ 104 | #undef PACKAGE_STRING 105 | 106 | /* Define to the one symbol short name of this package. */ 107 | #undef PACKAGE_TARNAME 108 | 109 | /* Define to the home page for this package. */ 110 | #undef PACKAGE_URL 111 | 112 | /* Define to the version of this package. */ 113 | #undef PACKAGE_VERSION 114 | 115 | /* Define to 1 if you have the ANSI C header files. */ 116 | #undef STDC_HEADERS 117 | 118 | /* Define to 1 if /dev/urandom should be used for seeding the hash function */ 119 | #undef USE_URANDOM 120 | 121 | /* Define to 1 if CryptGenRandom should be used for seeding the hash function 122 | */ 123 | #undef USE_WINDOWS_CRYPTOAPI 124 | 125 | /* Version number of package */ 126 | #undef VERSION 127 | 128 | /* Define for Solaris 2.5.1 so the uint32_t typedef from , 129 | , or is not used. If the typedef were allowed, the 130 | #define below would cause a syntax error. */ 131 | #undef _UINT32_T 132 | 133 | /* Define for Solaris 2.5.1 so the uint8_t typedef from , 134 | , or is not used. If the typedef were allowed, the 135 | #define below would cause a syntax error. */ 136 | #undef _UINT8_T 137 | 138 | /* Define to `__inline__' or `__inline' if that's what the C compiler 139 | calls it, or to nothing if 'inline' is not supported under any name. */ 140 | #ifndef __cplusplus 141 | #undef inline 142 | #endif 143 | 144 | /* Define to the type of a signed integer type of width exactly 32 bits if 145 | such a type exists and the standard includes do not define it. */ 146 | #undef int32_t 147 | 148 | /* Define to the type of an unsigned integer type of width exactly 16 bits if 149 | such a type exists and the standard includes do not define it. */ 150 | #undef uint16_t 151 | 152 | /* Define to the type of an unsigned integer type of width exactly 32 bits if 153 | such a type exists and the standard includes do not define it. */ 154 | #undef uint32_t 155 | 156 | /* Define to the type of an unsigned integer type of width exactly 8 bits if 157 | such a type exists and the standard includes do not define it. */ 158 | #undef uint8_t 159 | -------------------------------------------------------------------------------- /src/jansson-2.10/src/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = jansson.def 2 | 3 | include_HEADERS = jansson.h 4 | nodist_include_HEADERS = jansson_config.h 5 | 6 | lib_LTLIBRARIES = libjansson.la 7 | libjansson_la_SOURCES = \ 8 | dump.c \ 9 | error.c \ 10 | hashtable.c \ 11 | hashtable.h \ 12 | hashtable_seed.c \ 13 | jansson_private.h \ 14 | load.c \ 15 | lookup3.h \ 16 | memory.c \ 17 | pack_unpack.c \ 18 | strbuffer.c \ 19 | strbuffer.h \ 20 | strconv.c \ 21 | utf.c \ 22 | utf.h \ 23 | value.c 24 | libjansson_la_LDFLAGS = \ 25 | -no-undefined \ 26 | -export-symbols-regex '^json_' \ 27 | -version-info 14:0:10 28 | -------------------------------------------------------------------------------- /src/jansson-2.10/src/error.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "jansson_private.h" 3 | 4 | void jsonp_error_init(json_error_t *error, const char *source) 5 | { 6 | if(error) 7 | { 8 | error->text[0] = '\0'; 9 | error->line = -1; 10 | error->column = -1; 11 | error->position = 0; 12 | if(source) 13 | jsonp_error_set_source(error, source); 14 | else 15 | error->source[0] = '\0'; 16 | } 17 | } 18 | 19 | void jsonp_error_set_source(json_error_t *error, const char *source) 20 | { 21 | size_t length; 22 | 23 | if(!error || !source) 24 | return; 25 | 26 | length = strlen(source); 27 | if(length < JSON_ERROR_SOURCE_LENGTH) 28 | strncpy(error->source, source, length + 1); 29 | else { 30 | size_t extra = length - JSON_ERROR_SOURCE_LENGTH + 4; 31 | strncpy(error->source, "...", 3); 32 | strncpy(error->source + 3, source + extra, length - extra + 1); 33 | } 34 | } 35 | 36 | void jsonp_error_set(json_error_t *error, int line, int column, 37 | size_t position, const char *msg, ...) 38 | { 39 | va_list ap; 40 | 41 | va_start(ap, msg); 42 | jsonp_error_vset(error, line, column, position, msg, ap); 43 | va_end(ap); 44 | } 45 | 46 | void jsonp_error_vset(json_error_t *error, int line, int column, 47 | size_t position, const char *msg, va_list ap) 48 | { 49 | if(!error) 50 | return; 51 | 52 | if(error->text[0] != '\0') { 53 | /* error already set */ 54 | return; 55 | } 56 | 57 | error->line = line; 58 | error->column = column; 59 | error->position = (int)position; 60 | 61 | vsnprintf(error->text, JSON_ERROR_TEXT_LENGTH, msg, ap); 62 | error->text[JSON_ERROR_TEXT_LENGTH - 1] = '\0'; 63 | } 64 | -------------------------------------------------------------------------------- /src/jansson-2.10/src/hashtable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2016 Petri Lehtinen 3 | * 4 | * This library is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #ifndef HASHTABLE_H 9 | #define HASHTABLE_H 10 | 11 | #include 12 | #include "jansson.h" 13 | 14 | struct hashtable_list { 15 | struct hashtable_list *prev; 16 | struct hashtable_list *next; 17 | }; 18 | 19 | /* "pair" may be a bit confusing a name, but think of it as a 20 | key-value pair. In this case, it just encodes some extra data, 21 | too */ 22 | struct hashtable_pair { 23 | struct hashtable_list list; 24 | struct hashtable_list ordered_list; 25 | size_t hash; 26 | json_t *value; 27 | char key[1]; 28 | }; 29 | 30 | struct hashtable_bucket { 31 | struct hashtable_list *first; 32 | struct hashtable_list *last; 33 | }; 34 | 35 | typedef struct hashtable { 36 | size_t size; 37 | struct hashtable_bucket *buckets; 38 | size_t order; /* hashtable has pow(2, order) buckets */ 39 | struct hashtable_list list; 40 | struct hashtable_list ordered_list; 41 | } hashtable_t; 42 | 43 | 44 | #define hashtable_key_to_iter(key_) \ 45 | (&(container_of(key_, struct hashtable_pair, key)->ordered_list)) 46 | 47 | 48 | /** 49 | * hashtable_init - Initialize a hashtable object 50 | * 51 | * @hashtable: The (statically allocated) hashtable object 52 | * 53 | * Initializes a statically allocated hashtable object. The object 54 | * should be cleared with hashtable_close when it's no longer used. 55 | * 56 | * Returns 0 on success, -1 on error (out of memory). 57 | */ 58 | int hashtable_init(hashtable_t *hashtable); 59 | 60 | /** 61 | * hashtable_close - Release all resources used by a hashtable object 62 | * 63 | * @hashtable: The hashtable 64 | * 65 | * Destroys a statically allocated hashtable object. 66 | */ 67 | void hashtable_close(hashtable_t *hashtable); 68 | 69 | /** 70 | * hashtable_set - Add/modify value in hashtable 71 | * 72 | * @hashtable: The hashtable object 73 | * @key: The key 74 | * @serial: For addition order of keys 75 | * @value: The value 76 | * 77 | * If a value with the given key already exists, its value is replaced 78 | * with the new value. Value is "stealed" in the sense that hashtable 79 | * doesn't increment its refcount but decreases the refcount when the 80 | * value is no longer needed. 81 | * 82 | * Returns 0 on success, -1 on failure (out of memory). 83 | */ 84 | int hashtable_set(hashtable_t *hashtable, const char *key, json_t *value); 85 | 86 | /** 87 | * hashtable_get - Get a value associated with a key 88 | * 89 | * @hashtable: The hashtable object 90 | * @key: The key 91 | * 92 | * Returns value if it is found, or NULL otherwise. 93 | */ 94 | void *hashtable_get(hashtable_t *hashtable, const char *key); 95 | 96 | /** 97 | * hashtable_del - Remove a value from the hashtable 98 | * 99 | * @hashtable: The hashtable object 100 | * @key: The key 101 | * 102 | * Returns 0 on success, or -1 if the key was not found. 103 | */ 104 | int hashtable_del(hashtable_t *hashtable, const char *key); 105 | 106 | /** 107 | * hashtable_clear - Clear hashtable 108 | * 109 | * @hashtable: The hashtable object 110 | * 111 | * Removes all items from the hashtable. 112 | */ 113 | void hashtable_clear(hashtable_t *hashtable); 114 | 115 | /** 116 | * hashtable_iter - Iterate over hashtable 117 | * 118 | * @hashtable: The hashtable object 119 | * 120 | * Returns an opaque iterator to the first element in the hashtable. 121 | * The iterator should be passed to hashtable_iter_* functions. 122 | * The hashtable items are not iterated over in any particular order. 123 | * 124 | * There's no need to free the iterator in any way. The iterator is 125 | * valid as long as the item that is referenced by the iterator is not 126 | * deleted. Other values may be added or deleted. In particular, 127 | * hashtable_iter_next() may be called on an iterator, and after that 128 | * the key/value pair pointed by the old iterator may be deleted. 129 | */ 130 | void *hashtable_iter(hashtable_t *hashtable); 131 | 132 | /** 133 | * hashtable_iter_at - Return an iterator at a specific key 134 | * 135 | * @hashtable: The hashtable object 136 | * @key: The key that the iterator should point to 137 | * 138 | * Like hashtable_iter() but returns an iterator pointing to a 139 | * specific key. 140 | */ 141 | void *hashtable_iter_at(hashtable_t *hashtable, const char *key); 142 | 143 | /** 144 | * hashtable_iter_next - Advance an iterator 145 | * 146 | * @hashtable: The hashtable object 147 | * @iter: The iterator 148 | * 149 | * Returns a new iterator pointing to the next element in the 150 | * hashtable or NULL if the whole hastable has been iterated over. 151 | */ 152 | void *hashtable_iter_next(hashtable_t *hashtable, void *iter); 153 | 154 | /** 155 | * hashtable_iter_key - Retrieve the key pointed by an iterator 156 | * 157 | * @iter: The iterator 158 | */ 159 | void *hashtable_iter_key(void *iter); 160 | 161 | /** 162 | * hashtable_iter_value - Retrieve the value pointed by an iterator 163 | * 164 | * @iter: The iterator 165 | */ 166 | void *hashtable_iter_value(void *iter); 167 | 168 | /** 169 | * hashtable_iter_set - Set the value pointed by an iterator 170 | * 171 | * @iter: The iterator 172 | * @value: The value to set 173 | */ 174 | void hashtable_iter_set(void *iter, json_t *value); 175 | 176 | #endif 177 | -------------------------------------------------------------------------------- /src/jansson-2.10/src/jansson.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | json_delete 3 | json_true 4 | json_false 5 | json_null 6 | json_string 7 | json_stringn 8 | json_string_nocheck 9 | json_stringn_nocheck 10 | json_string_value 11 | json_string_length 12 | json_string_set 13 | json_string_setn 14 | json_string_set_nocheck 15 | json_string_setn_nocheck 16 | json_integer 17 | json_integer_value 18 | json_integer_set 19 | json_real 20 | json_real_value 21 | json_real_set 22 | json_number_value 23 | json_array 24 | json_array_size 25 | json_array_get 26 | json_array_set_new 27 | json_array_append_new 28 | json_array_insert_new 29 | json_array_remove 30 | json_array_clear 31 | json_array_extend 32 | json_object 33 | json_object_size 34 | json_object_get 35 | json_object_set_new 36 | json_object_set_new_nocheck 37 | json_object_del 38 | json_object_clear 39 | json_object_update 40 | json_object_update_existing 41 | json_object_update_missing 42 | json_object_iter 43 | json_object_iter_at 44 | json_object_iter_next 45 | json_object_iter_key 46 | json_object_iter_value 47 | json_object_iter_set_new 48 | json_object_key_to_iter 49 | json_object_seed 50 | json_dumps 51 | json_dumpb 52 | json_dumpf 53 | json_dumpfd 54 | json_dump_file 55 | json_dump_callback 56 | json_loads 57 | json_loadb 58 | json_loadf 59 | json_loadfd 60 | json_load_file 61 | json_load_callback 62 | json_equal 63 | json_copy 64 | json_deep_copy 65 | json_pack 66 | json_pack_ex 67 | json_vpack_ex 68 | json_unpack 69 | json_unpack_ex 70 | json_vunpack_ex 71 | json_set_alloc_funcs 72 | json_get_alloc_funcs 73 | 74 | -------------------------------------------------------------------------------- /src/jansson-2.10/src/jansson_config.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2016 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | * 7 | * 8 | * This file specifies a part of the site-specific configuration for 9 | * Jansson, namely those things that affect the public API in 10 | * jansson.h. 11 | * 12 | * The configure script copies this file to jansson_config.h and 13 | * replaces @var@ substitutions by values that fit your system. If you 14 | * cannot run the configure script, you can do the value substitution 15 | * by hand. 16 | */ 17 | 18 | #ifndef JANSSON_CONFIG_H 19 | #define JANSSON_CONFIG_H 20 | 21 | /* If your compiler supports the inline keyword in C, JSON_INLINE is 22 | defined to `inline', otherwise empty. In C++, the inline is always 23 | supported. */ 24 | #ifdef __cplusplus 25 | #define JSON_INLINE inline 26 | #else 27 | #define JSON_INLINE @json_inline@ 28 | #endif 29 | 30 | /* If your compiler supports the `long long` type and the strtoll() 31 | library function, JSON_INTEGER_IS_LONG_LONG is defined to 1, 32 | otherwise to 0. */ 33 | #define JSON_INTEGER_IS_LONG_LONG @json_have_long_long@ 34 | 35 | /* If locale.h and localeconv() are available, define to 1, 36 | otherwise to 0. */ 37 | #define JSON_HAVE_LOCALECONV @json_have_localeconv@ 38 | 39 | /* Maximum recursion depth for parsing JSON input. 40 | This limits the depth of e.g. array-within-array constructions. */ 41 | #define JSON_PARSER_MAX_DEPTH 2048 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/jansson-2.10/src/jansson_private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2016 Petri Lehtinen 3 | * Copyright (c) 2015,2017 Con Kolivas 4 | * 5 | * Jansson is free software; you can redistribute it and/or modify 6 | * it under the terms of the MIT license. See LICENSE for details. 7 | */ 8 | 9 | #ifndef JANSSON_PRIVATE_H 10 | #define JANSSON_PRIVATE_H 11 | 12 | #include "jansson_private_config.h" 13 | #include 14 | #include "jansson.h" 15 | #include "hashtable.h" 16 | #include "strbuffer.h" 17 | 18 | #define container_of(ptr_, type_, member_) \ 19 | ((type_ *)((char *)ptr_ - offsetof(type_, member_))) 20 | 21 | /* On some platforms, max() may already be defined */ 22 | #ifndef max 23 | #define max(a, b) ((a) > (b) ? (a) : (b)) 24 | #endif 25 | 26 | /* va_copy is a C99 feature. In C89 implementations, it's sometimes 27 | available as __va_copy. If not, memcpy() should do the trick. */ 28 | #ifndef va_copy 29 | #ifdef __va_copy 30 | #define va_copy __va_copy 31 | #else 32 | #define va_copy(a, b) memcpy(&(a), &(b), sizeof(va_list)) 33 | #endif 34 | #endif 35 | 36 | typedef struct { 37 | json_t json; 38 | hashtable_t hashtable; 39 | int visited; 40 | } json_object_t; 41 | 42 | typedef struct { 43 | json_t json; 44 | size_t size; 45 | size_t entries; 46 | json_t **table; 47 | int visited; 48 | } json_array_t; 49 | 50 | typedef struct { 51 | json_t json; 52 | char *value; 53 | size_t length; 54 | } json_string_t; 55 | 56 | typedef struct { 57 | json_t json; 58 | double value; 59 | } json_real_t; 60 | 61 | typedef struct { 62 | json_t json; 63 | json_int_t value; 64 | } json_integer_t; 65 | 66 | #define json_to_object(json_) container_of(json_, json_object_t, json) 67 | #define json_to_array(json_) container_of(json_, json_array_t, json) 68 | #define json_to_string(json_) container_of(json_, json_string_t, json) 69 | #define json_to_real(json_) container_of(json_, json_real_t, json) 70 | #define json_to_integer(json_) container_of(json_, json_integer_t, json) 71 | 72 | /* Create a string by taking ownership of an existing buffer */ 73 | json_t *jsonp_stringn_nocheck_own(const char *value, size_t len); 74 | 75 | /* Error message formatting */ 76 | void jsonp_error_init(json_error_t *error, const char *source); 77 | void jsonp_error_set_source(json_error_t *error, const char *source); 78 | void jsonp_error_set(json_error_t *error, int line, int column, 79 | size_t position, const char *msg, ...); 80 | void jsonp_error_vset(json_error_t *error, int line, int column, 81 | size_t position, const char *msg, va_list ap); 82 | 83 | /* Locale independent string<->double conversions */ 84 | int jsonp_strtod(strbuffer_t *strbuffer, double *out); 85 | int jsonp_dtostr(char *buffer, size_t size, double value, int prec); 86 | 87 | /* Wrappers for custom memory functions */ 88 | void* jsonp_malloc(size_t size); 89 | void jsonp_free(void *ptr); 90 | void jsonp_free(void *ptr); 91 | void _jsonp_free(void **ptr); 92 | #define jsonp_free(ptr) _jsonp_free((void *)&(ptr)) 93 | 94 | char *jsonp_strndup(const char *str, size_t length); 95 | char *jsonp_strdup(const char *str); 96 | char *jsonp_strsteal(strbuffer_t *strbuff); 97 | char *jsonp_eolstrsteal(strbuffer_t *strbuff); 98 | 99 | 100 | /* Windows compatibility */ 101 | #if defined(_WIN32) || defined(WIN32) 102 | # if defined(_MSC_VER) /* MS compiller */ 103 | # if (_MSC_VER < 1900) && !defined(snprintf) /* snprintf not defined yet & not introduced */ 104 | # define snprintf _snprintf 105 | # endif 106 | # if (_MSC_VER < 1500) && !defined(vsnprintf) /* vsnprintf not defined yet & not introduced */ 107 | # define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a) 108 | # endif 109 | # else /* Other Windows compiller, old definition */ 110 | # define snprintf _snprintf 111 | # define vsnprintf _vsnprintf 112 | # endif 113 | #endif 114 | 115 | #endif 116 | -------------------------------------------------------------------------------- /src/jansson-2.10/src/memory.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2016 Petri Lehtinen 3 | * Copyright (c) 2011-2012 Basile Starynkevitch 4 | * Copyright (c) 2015,2017 Con Kolivas 5 | * 6 | * Jansson is free software; you can redistribute it and/or modify it 7 | * under the terms of the MIT license. See LICENSE for details. 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | #include "jansson.h" 14 | #include "jansson_private.h" 15 | 16 | /* C89 allows these to be macros */ 17 | #undef malloc 18 | #undef free 19 | 20 | /* memory function pointers */ 21 | static json_malloc_t do_malloc = malloc; 22 | static json_free_t do_free = free; 23 | 24 | void *jsonp_malloc(size_t size) 25 | { 26 | if(!size) 27 | return NULL; 28 | 29 | return (*do_malloc)(size); 30 | } 31 | 32 | void _jsonp_free(void **ptr) 33 | { 34 | if(!*ptr) 35 | return; 36 | 37 | (*do_free)(*ptr); 38 | *ptr = NULL; 39 | } 40 | 41 | char *jsonp_strdup(const char *str) 42 | { 43 | return jsonp_strndup(str, strlen(str)); 44 | } 45 | 46 | char *jsonp_strndup(const char *str, size_t len) 47 | { 48 | char *new_str; 49 | 50 | new_str = jsonp_malloc(len + 1); 51 | if(!new_str) 52 | return NULL; 53 | 54 | memcpy(new_str, str, len); 55 | new_str[len] = '\0'; 56 | return new_str; 57 | } 58 | 59 | char *jsonp_strsteal(strbuffer_t *strbuff) 60 | { 61 | size_t len = strbuff->length + 1; 62 | char *ret = realloc(strbuff->value, len); 63 | 64 | return ret; 65 | } 66 | 67 | char *jsonp_eolstrsteal(strbuffer_t *strbuff) 68 | { 69 | size_t len = strbuff->length + 2; 70 | char *ret = realloc(strbuff->value, len); 71 | 72 | ret[strbuff->length] = '\n'; 73 | ret[strbuff->length + 1] = '\0'; 74 | return ret; 75 | } 76 | 77 | void json_set_alloc_funcs(json_malloc_t malloc_fn, json_free_t free_fn) 78 | { 79 | do_malloc = malloc_fn; 80 | do_free = free_fn; 81 | } 82 | 83 | void json_get_alloc_funcs(json_malloc_t *malloc_fn, json_free_t *free_fn) 84 | { 85 | if (malloc_fn) 86 | *malloc_fn = do_malloc; 87 | if (free_fn) 88 | *free_fn = do_free; 89 | } 90 | -------------------------------------------------------------------------------- /src/jansson-2.10/src/strbuffer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2016 Petri Lehtinen 3 | * Copyright (c) 2015,2017 Con Kolivas 4 | * 5 | * Jansson is free software; you can redistribute it and/or modify 6 | * it under the terms of the MIT license. See LICENSE for details. 7 | */ 8 | 9 | #ifndef _GNU_SOURCE 10 | #define _GNU_SOURCE 11 | #endif 12 | 13 | #include 14 | #include 15 | #include 16 | #include "jansson_private.h" 17 | #include "strbuffer.h" 18 | 19 | #define STRBUFFER_MIN_SIZE 4096 20 | #define STRBUFFER_FACTOR 2 21 | #define STRBUFFER_SIZE_MAX ((size_t)-1) 22 | 23 | int strbuffer_init(strbuffer_t *strbuff) 24 | { 25 | strbuff->size = STRBUFFER_MIN_SIZE; 26 | strbuff->length = 0; 27 | 28 | strbuff->value = jsonp_malloc(strbuff->size); 29 | if(!strbuff->value) 30 | return -1; 31 | 32 | /* initialize to empty */ 33 | strbuff->value[0] = '\0'; 34 | return 0; 35 | } 36 | 37 | void strbuffer_close(strbuffer_t *strbuff) 38 | { 39 | if(strbuff->value) 40 | jsonp_free(strbuff->value); 41 | 42 | strbuff->size = 0; 43 | strbuff->length = 0; 44 | strbuff->value = NULL; 45 | } 46 | 47 | void strbuffer_clear(strbuffer_t *strbuff) 48 | { 49 | strbuff->length = 0; 50 | strbuff->value[0] = '\0'; 51 | } 52 | 53 | const char *strbuffer_value(const strbuffer_t *strbuff) 54 | { 55 | return strbuff->value; 56 | } 57 | 58 | char *strbuffer_steal_value(strbuffer_t *strbuff) 59 | { 60 | char *result = strbuff->value; 61 | strbuff->value = NULL; 62 | return result; 63 | } 64 | 65 | int strbuffer_append_byte(strbuffer_t *strbuff, char byte) 66 | { 67 | return strbuffer_append_bytes(strbuff, &byte, 1); 68 | } 69 | 70 | int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size) 71 | { 72 | /* Leave room for EOL and NULL bytes */ 73 | if(size + 2 > strbuff->size - strbuff->length) 74 | { 75 | int backoff = 1; 76 | size_t new_size; 77 | char *new_value; 78 | 79 | /* avoid integer overflow */ 80 | if (strbuff->size > STRBUFFER_SIZE_MAX / STRBUFFER_FACTOR 81 | || size > STRBUFFER_SIZE_MAX - 1 82 | || strbuff->length > STRBUFFER_SIZE_MAX - 1 - size) 83 | return -1; 84 | 85 | new_size = max(strbuff->size * STRBUFFER_FACTOR, 86 | strbuff->length + size + 1); 87 | 88 | while (42) { 89 | new_value = realloc(strbuff->value, new_size); 90 | if (new_value) 91 | break; 92 | usleep(backoff * 1000); 93 | backoff <<= 1; 94 | } 95 | 96 | strbuff->value = new_value; 97 | strbuff->size = new_size; 98 | } 99 | 100 | memcpy(strbuff->value + strbuff->length, data, size); 101 | strbuff->length += size; 102 | strbuff->value[strbuff->length] = '\0'; 103 | 104 | return 0; 105 | } 106 | 107 | char strbuffer_pop(strbuffer_t *strbuff) 108 | { 109 | if(strbuff->length > 0) { 110 | char c = strbuff->value[--strbuff->length]; 111 | strbuff->value[strbuff->length] = '\0'; 112 | return c; 113 | } 114 | else 115 | return '\0'; 116 | } 117 | -------------------------------------------------------------------------------- /src/jansson-2.10/src/strbuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2016 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #ifndef STRBUFFER_H 9 | #define STRBUFFER_H 10 | 11 | #include 12 | 13 | typedef struct { 14 | char *value; 15 | size_t length; /* bytes used */ 16 | size_t size; /* bytes allocated */ 17 | } strbuffer_t; 18 | 19 | int strbuffer_init(strbuffer_t *strbuff); 20 | void strbuffer_close(strbuffer_t *strbuff); 21 | 22 | void strbuffer_clear(strbuffer_t *strbuff); 23 | 24 | const char *strbuffer_value(const strbuffer_t *strbuff); 25 | 26 | /* Steal the value and close the strbuffer */ 27 | char *strbuffer_steal_value(strbuffer_t *strbuff); 28 | 29 | int strbuffer_append_byte(strbuffer_t *strbuff, char byte); 30 | int strbuffer_append_bytes(strbuffer_t *strbuff, const char *data, size_t size); 31 | 32 | char strbuffer_pop(strbuffer_t *strbuff); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/jansson-2.10/src/strconv.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #ifdef __MINGW32__ 7 | #undef __NO_ISOCEXT /* ensure stdlib.h will declare prototypes for mingw own 'strtod' replacement, called '__strtod' */ 8 | #endif 9 | #include "jansson_private.h" 10 | #include "strbuffer.h" 11 | 12 | /* need jansson_private_config.h to get the correct snprintf */ 13 | #ifdef HAVE_CONFIG_H 14 | #include 15 | #endif 16 | 17 | #ifdef __MINGW32__ 18 | #define strtod __strtod 19 | #endif 20 | 21 | #if JSON_HAVE_LOCALECONV 22 | #include 23 | 24 | /* 25 | - This code assumes that the decimal separator is exactly one 26 | character. 27 | 28 | - If setlocale() is called by another thread between the call to 29 | localeconv() and the call to sprintf() or strtod(), the result may 30 | be wrong. setlocale() is not thread-safe and should not be used 31 | this way. Multi-threaded programs should use uselocale() instead. 32 | */ 33 | 34 | static void to_locale(strbuffer_t *strbuffer) 35 | { 36 | const char *point; 37 | char *pos; 38 | 39 | point = localeconv()->decimal_point; 40 | if(*point == '.') { 41 | /* No conversion needed */ 42 | return; 43 | } 44 | 45 | pos = strchr(strbuffer->value, '.'); 46 | if(pos) 47 | *pos = *point; 48 | } 49 | 50 | static void from_locale(char *buffer) 51 | { 52 | const char *point; 53 | char *pos; 54 | 55 | point = localeconv()->decimal_point; 56 | if(*point == '.') { 57 | /* No conversion needed */ 58 | return; 59 | } 60 | 61 | pos = strchr(buffer, *point); 62 | if(pos) 63 | *pos = '.'; 64 | } 65 | #endif 66 | 67 | int jsonp_strtod(strbuffer_t *strbuffer, double *out) 68 | { 69 | double value; 70 | char *end; 71 | 72 | #if JSON_HAVE_LOCALECONV 73 | to_locale(strbuffer); 74 | #endif 75 | 76 | errno = 0; 77 | value = strtod(strbuffer->value, &end); 78 | assert(end == strbuffer->value + strbuffer->length); 79 | 80 | if((value == HUGE_VAL || value == -HUGE_VAL) && errno == ERANGE) { 81 | /* Overflow */ 82 | return -1; 83 | } 84 | 85 | *out = value; 86 | return 0; 87 | } 88 | 89 | int jsonp_dtostr(char *buffer, size_t size, double value, int precision) 90 | { 91 | int ret; 92 | char *start, *end; 93 | size_t length; 94 | 95 | if (precision == 0) 96 | precision = 17; 97 | 98 | ret = snprintf(buffer, size, "%.*g", precision, value); 99 | if(ret < 0) 100 | return -1; 101 | 102 | length = (size_t)ret; 103 | if(length >= size) 104 | return -1; 105 | 106 | #if JSON_HAVE_LOCALECONV 107 | from_locale(buffer); 108 | #endif 109 | 110 | /* Make sure there's a dot or 'e' in the output. Otherwise 111 | a real is converted to an integer when decoding */ 112 | if(strchr(buffer, '.') == NULL && 113 | strchr(buffer, 'e') == NULL) 114 | { 115 | if(length + 3 >= size) { 116 | /* No space to append ".0" */ 117 | return -1; 118 | } 119 | buffer[length] = '.'; 120 | buffer[length + 1] = '0'; 121 | buffer[length + 2] = '\0'; 122 | length += 2; 123 | } 124 | 125 | /* Remove leading '+' from positive exponent. Also remove leading 126 | zeros from exponents (added by some printf() implementations) */ 127 | start = strchr(buffer, 'e'); 128 | if(start) { 129 | start++; 130 | end = start + 1; 131 | 132 | if(*start == '-') 133 | start++; 134 | 135 | while(*end == '0') 136 | end++; 137 | 138 | if(end != start) { 139 | memmove(start, end, length - (size_t)(end - buffer)); 140 | length -= (size_t)(end - start); 141 | } 142 | } 143 | 144 | return (int)length; 145 | } 146 | -------------------------------------------------------------------------------- /src/jansson-2.10/src/utf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2016 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #include 9 | #include "utf.h" 10 | 11 | int utf8_encode(int32_t codepoint, char *buffer, size_t *size) 12 | { 13 | if(codepoint < 0) 14 | return -1; 15 | else if(codepoint < 0x80) 16 | { 17 | buffer[0] = (char)codepoint; 18 | *size = 1; 19 | } 20 | else if(codepoint < 0x800) 21 | { 22 | buffer[0] = 0xC0 + ((codepoint & 0x7C0) >> 6); 23 | buffer[1] = 0x80 + ((codepoint & 0x03F)); 24 | *size = 2; 25 | } 26 | else if(codepoint < 0x10000) 27 | { 28 | buffer[0] = 0xE0 + ((codepoint & 0xF000) >> 12); 29 | buffer[1] = 0x80 + ((codepoint & 0x0FC0) >> 6); 30 | buffer[2] = 0x80 + ((codepoint & 0x003F)); 31 | *size = 3; 32 | } 33 | else if(codepoint <= 0x10FFFF) 34 | { 35 | buffer[0] = 0xF0 + ((codepoint & 0x1C0000) >> 18); 36 | buffer[1] = 0x80 + ((codepoint & 0x03F000) >> 12); 37 | buffer[2] = 0x80 + ((codepoint & 0x000FC0) >> 6); 38 | buffer[3] = 0x80 + ((codepoint & 0x00003F)); 39 | *size = 4; 40 | } 41 | else 42 | return -1; 43 | 44 | return 0; 45 | } 46 | 47 | size_t utf8_check_first(char byte) 48 | { 49 | unsigned char u = (unsigned char)byte; 50 | 51 | if(u < 0x80) 52 | return 1; 53 | 54 | if(0x80 <= u && u <= 0xBF) { 55 | /* second, third or fourth byte of a multi-byte 56 | sequence, i.e. a "continuation byte" */ 57 | return 0; 58 | } 59 | else if(u == 0xC0 || u == 0xC1) { 60 | /* overlong encoding of an ASCII byte */ 61 | return 0; 62 | } 63 | else if(0xC2 <= u && u <= 0xDF) { 64 | /* 2-byte sequence */ 65 | return 2; 66 | } 67 | 68 | else if(0xE0 <= u && u <= 0xEF) { 69 | /* 3-byte sequence */ 70 | return 3; 71 | } 72 | else if(0xF0 <= u && u <= 0xF4) { 73 | /* 4-byte sequence */ 74 | return 4; 75 | } 76 | else { /* u >= 0xF5 */ 77 | /* Restricted (start of 4-, 5- or 6-byte sequence) or invalid 78 | UTF-8 */ 79 | return 0; 80 | } 81 | } 82 | 83 | size_t utf8_check_full(const char *buffer, size_t size, int32_t *codepoint) 84 | { 85 | size_t i; 86 | int32_t value = 0; 87 | unsigned char u = (unsigned char)buffer[0]; 88 | 89 | if(size == 2) 90 | { 91 | value = u & 0x1F; 92 | } 93 | else if(size == 3) 94 | { 95 | value = u & 0xF; 96 | } 97 | else if(size == 4) 98 | { 99 | value = u & 0x7; 100 | } 101 | else 102 | return 0; 103 | 104 | for(i = 1; i < size; i++) 105 | { 106 | u = (unsigned char)buffer[i]; 107 | 108 | if(u < 0x80 || u > 0xBF) { 109 | /* not a continuation byte */ 110 | return 0; 111 | } 112 | 113 | value = (value << 6) + (u & 0x3F); 114 | } 115 | 116 | if(value > 0x10FFFF) { 117 | /* not in Unicode range */ 118 | return 0; 119 | } 120 | 121 | else if(0xD800 <= value && value <= 0xDFFF) { 122 | /* invalid code point (UTF-16 surrogate halves) */ 123 | return 0; 124 | } 125 | 126 | else if((size == 2 && value < 0x80) || 127 | (size == 3 && value < 0x800) || 128 | (size == 4 && value < 0x10000)) { 129 | /* overlong encoding */ 130 | return 0; 131 | } 132 | 133 | if(codepoint) 134 | *codepoint = value; 135 | 136 | return 1; 137 | } 138 | 139 | const char *utf8_iterate(const char *buffer, size_t bufsize, int32_t *codepoint, int noutf8) 140 | { 141 | size_t count = 1; 142 | int32_t value; 143 | 144 | if(!bufsize) 145 | return buffer; 146 | 147 | if (!noutf8) { 148 | count = utf8_check_first(buffer[0]); 149 | if(count <= 0) 150 | return NULL; 151 | } 152 | 153 | if(count == 1) 154 | value = (unsigned char)buffer[0]; 155 | else 156 | { 157 | if(count > bufsize || !utf8_check_full(buffer, count, &value)) 158 | return NULL; 159 | } 160 | 161 | if(codepoint) 162 | *codepoint = value; 163 | 164 | return buffer + count; 165 | } 166 | 167 | int utf8_check_string(const char *string, size_t length) 168 | { 169 | size_t i; 170 | 171 | for(i = 0; i < length; i++) 172 | { 173 | size_t count = utf8_check_first(string[i]); 174 | if(count == 0) 175 | return 0; 176 | else if(count > 1) 177 | { 178 | if(count > length - i) 179 | return 0; 180 | 181 | if(!utf8_check_full(&string[i], count, NULL)) 182 | return 0; 183 | 184 | i += count - 1; 185 | } 186 | } 187 | 188 | return 1; 189 | } 190 | -------------------------------------------------------------------------------- /src/jansson-2.10/src/utf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2016 Petri Lehtinen 3 | * 4 | * Jansson is free software; you can redistribute it and/or modify 5 | * it under the terms of the MIT license. See LICENSE for details. 6 | */ 7 | 8 | #ifndef UTF_H 9 | #define UTF_H 10 | 11 | #ifdef HAVE_CONFIG_H 12 | #include 13 | #endif 14 | 15 | #ifdef HAVE_STDINT_H 16 | #include 17 | #endif 18 | 19 | int utf8_encode(int32_t codepoint, char *buffer, size_t *size); 20 | 21 | size_t utf8_check_first(char byte); 22 | size_t utf8_check_full(const char *buffer, size_t size, int32_t *codepoint); 23 | const char *utf8_iterate(const char *buffer, size_t size, int32_t *codepoint, int noutf8); 24 | 25 | int utf8_check_string(const char *string, size_t length); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/jansson-2.10/test-driver: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # test-driver - basic testsuite driver script. 3 | 4 | scriptversion=2013-07-13.22; # UTC 5 | 6 | # Copyright (C) 2011-2014 Free Software Foundation, Inc. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2, or (at your option) 11 | # any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | # As a special exception to the GNU General Public License, if you 22 | # distribute this file as part of a program that contains a 23 | # configuration script generated by Autoconf, you may include it under 24 | # the same distribution terms that you use for the rest of that program. 25 | 26 | # This file is maintained in Automake, please report 27 | # bugs to or send patches to 28 | # . 29 | 30 | # Make unconditional expansion of undefined variables an error. This 31 | # helps a lot in preventing typo-related bugs. 32 | set -u 33 | 34 | usage_error () 35 | { 36 | echo "$0: $*" >&2 37 | print_usage >&2 38 | exit 2 39 | } 40 | 41 | print_usage () 42 | { 43 | cat <$log_file 2>&1 108 | estatus=$? 109 | 110 | if test $enable_hard_errors = no && test $estatus -eq 99; then 111 | tweaked_estatus=1 112 | else 113 | tweaked_estatus=$estatus 114 | fi 115 | 116 | case $tweaked_estatus:$expect_failure in 117 | 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;; 118 | 0:*) col=$grn res=PASS recheck=no gcopy=no;; 119 | 77:*) col=$blu res=SKIP recheck=no gcopy=yes;; 120 | 99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;; 121 | *:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;; 122 | *:*) col=$red res=FAIL recheck=yes gcopy=yes;; 123 | esac 124 | 125 | # Report the test outcome and exit status in the logs, so that one can 126 | # know whether the test passed or failed simply by looking at the '.log' 127 | # file, without the need of also peaking into the corresponding '.trs' 128 | # file (automake bug#11814). 129 | echo "$res $test_name (exit status: $estatus)" >>$log_file 130 | 131 | # Report outcome to console. 132 | echo "${col}${res}${std}: $test_name" 133 | 134 | # Register the test result, and other relevant metadata. 135 | echo ":test-result: $res" > $trs_file 136 | echo ":global-test-result: $res" >> $trs_file 137 | echo ":recheck: $recheck" >> $trs_file 138 | echo ":copy-in-global-log: $gcopy" >> $trs_file 139 | 140 | # Local Variables: 141 | # mode: shell-script 142 | # sh-indentation: 2 143 | # eval: (add-hook 'write-file-hooks 'time-stamp) 144 | # time-stamp-start: "scriptversion=" 145 | # time-stamp-format: "%:y-%02m-%02d.%02H" 146 | # time-stamp-time-zone: "UTC" 147 | # time-stamp-end: "; # UTC" 148 | # End: 149 | -------------------------------------------------------------------------------- /src/ktree.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 1995-2016 Andrew Smith 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms of the GNU General Public License as published by the Free 6 | * Software Foundation; either version 3 of the License, or (at your option) 7 | * any later version. See COPYING for more details. 8 | */ 9 | 10 | #ifndef ___KTREE_H 11 | #define ___KTREE_H 12 | 13 | #include "klist.h" 14 | #include "libckpool.h" 15 | 16 | #define quithere(status, fmt, ...) \ 17 | quitfrom(status, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__) 18 | 19 | #define KTREE_FFL " - from %s %s() line %d" 20 | #define KTREE_FFL_HERE __FILE__, __func__, __LINE__ 21 | #define KTREE_FFL_PASS file, func, line 22 | #define KTREE_FFL_ARGS __maybe_unused const char *file, \ 23 | __maybe_unused const char *func, \ 24 | __maybe_unused const int line 25 | 26 | #define cmp_t int32_t 27 | 28 | #define CMP_STR(a,b) strcmp((a),(b)) 29 | #define CMP_INT(a,b) ((a)-(b)) 30 | #define CMP_BIG_Z(a,b) (((a) < (b)) ? -1 : 1) 31 | #define CMP_BIG(a,b) (((a) == (b)) ? 0 : CMP_BIG_Z(a,b)) 32 | #define CMP_TV(a,b) (((a).tv_sec == (b).tv_sec) ? CMP_BIG((a).tv_usec,(b).tv_usec) : \ 33 | CMP_BIG_Z((a).tv_sec,(b).tv_sec)) 34 | #define CMP_BIGINT CMP_BIG 35 | #define CMP_DOUBLE CMP_BIG 36 | 37 | #define _TREE_WRITE(_t, _c, _fl, _f, _l) _LIST_WRITE(_t, _c, _fl, _f, _l) 38 | #define _TREE_READ(_t, _c, _fl, _f, _l) _LIST_READ(_t, _c, _fl, _f, _l) 39 | 40 | typedef struct knode 41 | { 42 | K_ITEM *kitem; 43 | bool isNil; 44 | bool red; 45 | struct knode *parent; 46 | struct knode *left; 47 | struct knode *right; 48 | K_ITEM *data; 49 | long test; 50 | } K_NODE; 51 | 52 | typedef struct ktree 53 | { 54 | const char *name; 55 | K_NODE *root; 56 | cmp_t (*cmp_funct)(K_ITEM *, K_ITEM *); 57 | K_LIST *master; 58 | K_LIST *node_free; 59 | K_STORE *node_store; 60 | } K_TREE; 61 | 62 | typedef void *K_TREE_CTX; 63 | 64 | // Avoid allocating too much ram up front for temporary trees 65 | #define NODE_ALLOC 64 66 | #define NODE_LIMIT 0 67 | 68 | extern K_TREE *_new_ktree(const char *name, cmp_t (*cmp_funct)(K_ITEM *, K_ITEM *), 69 | K_LIST *master, int alloc, int limit, bool local_tree, 70 | KTREE_FFL_ARGS); 71 | #define new_ktree(_name, _cmp_funct, _master) \ 72 | _new_ktree(_name, _cmp_funct, _master, _master->allocate, _master->limit, false, KLIST_FFL_HERE) 73 | #define new_ktree_local(_name, _cmp_funct, _master) \ 74 | _new_ktree(_name, _cmp_funct, _master, _master->allocate, _master->limit, true, KLIST_FFL_HERE) 75 | #define new_ktree_auto(_name, _cmp_funct, _master) \ 76 | _new_ktree(_name, _cmp_funct, _master, NODE_ALLOC, NODE_LIMIT, true, KLIST_FFL_HERE) 77 | #define new_ktree_size(_name, _cmp_funct, _master, _alloc, _limit) \ 78 | _new_ktree(_name, _cmp_funct, _master, _alloc, _limit, false, KLIST_FFL_HERE) 79 | extern void _dump_ktree(K_TREE *tree, char *(*dsp_funct)(K_ITEM *), KTREE_FFL_ARGS); 80 | #define dump_ktree(_tree, _dsp_funct) _dump_ktree(_tree, _dsp_funct, KLIST_FFL_HERE) 81 | extern void _dsp_ktree(K_TREE *tree, char *filename, char *msg, KTREE_FFL_ARGS); 82 | #define dsp_ktree(_tree, _filename, _msg) _dsp_ktree(_tree, _filename, _msg, KLIST_FFL_HERE) 83 | extern K_ITEM *_first_in_ktree(K_TREE *tree, K_TREE_CTX *ctx, LOCK_MAYBE bool chklock, KTREE_FFL_ARGS); 84 | #define first_in_ktree(_tree, _ctx) _first_in_ktree(_tree, _ctx, true, KLIST_FFL_HERE) 85 | #define first_in_ktree_nolock(_ktree, _ctx) _first_in_ktree(_ktree, _ctx, false, KLIST_FFL_HERE) 86 | extern K_ITEM *_last_in_ktree(K_TREE *tree, K_TREE_CTX *ctx, KTREE_FFL_ARGS); 87 | #define last_in_ktree(_tree, _ctx) _last_in_ktree(_tree, _ctx, KLIST_FFL_HERE) 88 | extern K_ITEM *_next_in_ktree(K_TREE_CTX *ctx, KTREE_FFL_ARGS); 89 | #define next_in_ktree(_ctx) _next_in_ktree(_ctx, KLIST_FFL_HERE) 90 | // No difference for now 91 | #define next_in_ktree_nolock(_ctx) _next_in_ktree(_ctx, KLIST_FFL_HERE) 92 | extern K_ITEM *_prev_in_ktree(K_TREE_CTX *ctx, KTREE_FFL_ARGS); 93 | #define prev_in_ktree(_ctx) _prev_in_ktree(_ctx, KLIST_FFL_HERE) 94 | // No difference for now 95 | #define prev_in_ktree_nolock(_ctx) _prev_in_ktree(_ctx, KLIST_FFL_HERE) 96 | extern void _add_to_ktree(K_TREE *tree, K_ITEM *data, LOCK_MAYBE bool chklock, KTREE_FFL_ARGS); 97 | #define add_to_ktree(_tree, _data) _add_to_ktree(_tree, _data, true, KLIST_FFL_HERE) 98 | #define add_to_ktree_nolock(_tree, _data) _add_to_ktree(_tree, _data, false, KLIST_FFL_HERE) 99 | extern K_ITEM *_find_in_ktree(K_TREE *tree, K_ITEM *data, K_TREE_CTX *ctx, bool chklock, KTREE_FFL_ARGS); 100 | #define find_in_ktree(_tree, _data, _ctx) _find_in_ktree(_tree, _data, _ctx, true, KLIST_FFL_HERE) 101 | #define find_in_ktree_nolock(_tree, _data, _ctx) _find_in_ktree(_tree, _data, _ctx, false, KLIST_FFL_HERE) 102 | extern K_ITEM *_find_after_in_ktree(K_TREE *ktree, K_ITEM *data, K_TREE_CTX *ctx, LOCK_MAYBE bool chklock, KTREE_FFL_ARGS); 103 | #define find_after_in_ktree(_ktree, _data, _ctx) _find_after_in_ktree(_ktree, _data, _ctx, true, KLIST_FFL_HERE) 104 | //#define find_after_in_ktree_nolock(_ktree, _data, _ctx) _find_after_in_ktree(_ktree, _data, _ctx, false, KLIST_FFL_HERE) 105 | extern K_ITEM *_find_before_in_ktree(K_TREE *ktree, K_ITEM *data, K_TREE_CTX *ctx, KTREE_FFL_ARGS); 106 | #define find_before_in_ktree(_ktree, _data, _ctx) _find_before_in_ktree(_ktree, _data, _ctx, KLIST_FFL_HERE) 107 | extern void _remove_from_ktree(K_TREE *tree, K_ITEM *data, K_TREE_CTX *ctx, LOCK_MAYBE bool chklock, KTREE_FFL_ARGS); 108 | extern void _remove_from_ktree_free(K_TREE *tree, K_ITEM *data, bool chklock, KTREE_FFL_ARGS); 109 | #define remove_from_ktree(_tree, _data) _remove_from_ktree_free(_tree, _data, true, KLIST_FFL_HERE) 110 | //#define remove_from_ktree_nolock(_tree, _data) _remove_from_ktree_free(_tree, _data, false, KLIST_FFL_HERE) 111 | extern void _free_ktree(K_TREE *tree, void (*free_funct)(void *), KTREE_FFL_ARGS); 112 | #define free_ktree(_tree, _free_funct) do { \ 113 | _free_ktree(_tree, _free_funct, KLIST_FFL_HERE); \ 114 | _tree = NULL; \ 115 | } while (0) 116 | 117 | #endif 118 | -------------------------------------------------------------------------------- /src/notifier.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2016 Con Kolivas 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms of the GNU General Public License as published by the Free 6 | * Software Foundation; either version 3 of the License, or (at your option) 7 | * any later version. See COPYING for more details. 8 | */ 9 | 10 | #include "config.h" 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | #include "libckpool.h" 17 | 18 | int main(int argc, char **argv) 19 | { 20 | char *name = NULL, *socket_dir = NULL; 21 | bool proxy = false; 22 | int c, sockd; 23 | 24 | while ((c = getopt(argc, argv, "n:s:p")) != -1) { 25 | switch(c) { 26 | case 'n': 27 | name = strdup(optarg); 28 | break; 29 | case 's': 30 | socket_dir = strdup(optarg); 31 | break; 32 | case 'p': 33 | proxy = true; 34 | break; 35 | } 36 | } 37 | if (!socket_dir) 38 | socket_dir = strdup("/tmp"); 39 | trail_slash(&socket_dir); 40 | if (!name) { 41 | if (proxy) 42 | name = strdup("ckproxy"); 43 | else 44 | name = strdup("ckpool"); 45 | } 46 | realloc_strcat(&socket_dir, name); 47 | dealloc(name); 48 | trail_slash(&socket_dir); 49 | realloc_strcat(&socket_dir, "stratifier"); 50 | sockd = open_unix_client(socket_dir); 51 | if (sockd < 0) { 52 | LOGERR("Failed to open socket: %s", socket_dir); 53 | exit(1); 54 | } 55 | if (!send_unix_msg(sockd, "update")) { 56 | LOGERR("Failed to send stratifier update msg"); 57 | exit(1); 58 | } 59 | LOGNOTICE("Notified stratifier of block update"); 60 | exit(0); 61 | } 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/relog.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | p1() 4 | { 5 | while true ; do 6 | read line 7 | if [ "$?" != "0" ] ; then 8 | return 9 | fi 10 | # echo "$line" 11 | if [ ! -f "$line" ] ; then 12 | echo "ERR: file not found: '$line'" 13 | else 14 | base="`echo "$line" | sed -e "s/\(^.*ckdb2014\).*$/\1/"`" 15 | rest="`echo "$line" | sed -e "s/^.*ckdb2014\(.*\).log$/\1/"`" 16 | m="${rest:0:2}" 17 | d="${rest:2:2}" 18 | h="${rest:4:2}" 19 | tz="`date -d"2014-$m-$d 00:00" +%z`" 20 | fix="`date -u -d"2014-$m-$d $h:00 $tz" +"%m%d%H"`" 21 | echo "mv '$line' '$base$fix.log2'" 22 | mv "$line" "$base$fix.log2" 23 | fi 24 | done 25 | } 26 | # 27 | p2() 28 | { 29 | while true ; do 30 | read line 31 | if [ "$?" != "0" ] ; then 32 | return 33 | fi 34 | nn="${line/log2/log}" 35 | echo "mv '$line' '$nn'" 36 | mv "$line" "$nn" 37 | done 38 | } 39 | # 40 | if [ "$1" = "/" ] ; then 41 | dir="$1" 42 | else 43 | dir="${1%%/}" 44 | fi 45 | # 46 | ls $dir/ckdb20140*.log | p1 47 | ls $dir/ckdb20140*.log2 | p2 48 | -------------------------------------------------------------------------------- /src/sha2.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FIPS 180-2 SHA-224/256/384/512 implementation 3 | * Last update: 02/02/2007 4 | * Issue date: 04/30/2005 5 | * 6 | * Copyright (C) 2013-2014, Con Kolivas 7 | * Copyright (C) 2005, 2007 Olivier Gay 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 3. Neither the name of the project nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 | * SUCH DAMAGE. 33 | */ 34 | 35 | #include "config.h" 36 | 37 | #ifndef SHA2_H 38 | #define SHA2_H 39 | 40 | #define SHA256_DIGEST_SIZE ( 256 / 8) 41 | #define SHA256_BLOCK_SIZE ( 512 / 8) 42 | 43 | #define SHFR(x, n) (x >> n) 44 | #define ROTR(x, n) ((x >> n) | (x << ((sizeof(x) << 3) - n))) 45 | #define CH(x, y, z) ((x & y) ^ (~x & z)) 46 | #define MAJ(x, y, z) ((x & y) ^ (x & z) ^ (y & z)) 47 | 48 | #define SHA256_F1(x) (ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22)) 49 | #define SHA256_F2(x) (ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25)) 50 | #define SHA256_F3(x) (ROTR(x, 7) ^ ROTR(x, 18) ^ SHFR(x, 3)) 51 | #define SHA256_F4(x) (ROTR(x, 17) ^ ROTR(x, 19) ^ SHFR(x, 10)) 52 | 53 | typedef struct { 54 | unsigned int tot_len; 55 | unsigned int len; 56 | unsigned char block[2 * SHA256_BLOCK_SIZE]; 57 | uint32_t h[8]; 58 | } sha256_ctx; 59 | 60 | extern uint32_t sha256_k[64]; 61 | 62 | void sha256_init(sha256_ctx * ctx); 63 | void sha256_update(sha256_ctx *ctx, const unsigned char *message, 64 | unsigned int len); 65 | void sha256_final(sha256_ctx *ctx, unsigned char *digest); 66 | void sha256(const unsigned char *message, unsigned int len, 67 | unsigned char *digest); 68 | 69 | #endif /* !SHA2_H */ 70 | -------------------------------------------------------------------------------- /src/sha256_code_release/open_software_license.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012, Intel Corporation 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the 15 | distribution. 16 | 17 | * Neither the name of the Intel Corporation nor the names of its 18 | contributors may be used to endorse or promote products derived from 19 | this software without specific prior written permission. 20 | 21 | 22 | THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION ""AS IS"" AND ANY 23 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 25 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION OR 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 30 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 31 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 32 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | -------------------------------------------------------------------------------- /src/stratifier.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2017 Con Kolivas 3 | * 4 | * This program is free software; you can redistribute it and/or modify it 5 | * under the terms of the GNU General Public License as published by the Free 6 | * Software Foundation; either version 3 of the License, or (at your option) 7 | * any later version. See COPYING for more details. 8 | */ 9 | 10 | #ifndef STRATIFIER_H 11 | #define STRATIFIER_H 12 | 13 | /* Generic structure for both workbase in stratifier and gbtbase in generator */ 14 | struct genwork { 15 | /* Hash table data */ 16 | UT_hash_handle hh; 17 | 18 | /* The next two fields need to be consecutive as both of them are 19 | * used as the key for their hashtable entry in remote_workbases */ 20 | int64_t id; 21 | /* The client id this workinfo came from if remote */ 22 | int64_t client_id; 23 | 24 | char idstring[20]; 25 | 26 | /* How many readers we currently have of this workbase, set 27 | * under write workbase_lock */ 28 | int readcount; 29 | 30 | /* The id a remote workinfo is mapped to locally */ 31 | int64_t mapped_id; 32 | 33 | ts_t gentime; 34 | tv_t retired; 35 | 36 | /* GBT/shared variables */ 37 | char target[68]; 38 | double diff; 39 | double network_diff; 40 | uint32_t version; 41 | uint32_t curtime; 42 | char prevhash[68]; 43 | char ntime[12]; 44 | uint32_t ntime32; 45 | char bbversion[12]; 46 | char nbit[12]; 47 | uint64_t coinbasevalue; 48 | int height; 49 | char *flags; 50 | int txns; 51 | char *txn_data; 52 | char *txn_hashes; 53 | char witnessdata[80]; //null-terminated ascii 54 | bool insert_witness; 55 | int merkles; 56 | char merklehash[16][68]; 57 | char merklebin[16][32]; 58 | json_t *merkle_array; 59 | 60 | /* Template variables, lengths are binary lengths! */ 61 | char *coinb1; // coinbase1 62 | uchar *coinb1bin; 63 | int coinb1len; // length of above 64 | 65 | char enonce1const[32]; // extranonce1 section that is constant 66 | uchar enonce1constbin[16]; 67 | int enonce1constlen; // length of above - usually zero unless proxying 68 | int enonce1varlen; // length of unique extranonce1 string for each worker - usually 8 69 | 70 | int enonce2varlen; // length of space left for extranonce2 - usually 8 unless proxying 71 | 72 | char *coinb2; // coinbase2 73 | uchar *coinb2bin; 74 | int coinb2len; // length of above 75 | 76 | /* Cached header binary */ 77 | char headerbin[112]; 78 | 79 | char *logdir; 80 | 81 | ckpool_t *ckp; 82 | bool proxy; /* This workbase is proxied work */ 83 | 84 | bool incomplete; /* This is a remote workinfo without all the txn data */ 85 | 86 | json_t *json; /* getblocktemplate json */ 87 | }; 88 | 89 | void parse_remote_txns(ckpool_t *ckp, const json_t *val); 90 | #define parse_upstream_txns(ckp, val) parse_remote_txns(ckp, val) 91 | void parse_upstream_auth(ckpool_t *ckp, json_t *val); 92 | void parse_upstream_workinfo(ckpool_t *ckp, json_t *val); 93 | void parse_upstream_block(ckpool_t *ckp, json_t *val); 94 | void parse_upstream_reqtxns(ckpool_t *ckp, json_t *val); 95 | char *stratifier_stats(ckpool_t *ckp, void *data); 96 | void _stratifier_add_recv(ckpool_t *ckp, json_t *val, const char *file, const char *func, const int line); 97 | #define stratifier_add_recv(ckp, val) _stratifier_add_recv(ckp, val, __FILE__, __func__, __LINE__) 98 | void *stratifier(void *arg); 99 | 100 | #endif /* STRATIFIER_H */ 101 | --------------------------------------------------------------------------------