[Rel] MVP

[Fix] strdup -> strdupa in stratifier.c

Add Mempool.space start script
This commit is contained in:
User Ckpool 2025-04-04 06:54:23 +00:00 committed by Portland.HODL
parent bb7b0aebe0
commit 44804fd08c
16 changed files with 1690 additions and 52 deletions

3
.gitignore vendored
View File

@ -37,7 +37,6 @@ ltmain.sh
*.m4
.libs/
logs/
libtool

4
README
View File

@ -1,7 +1,9 @@
CKPOOL + CKPROXY + libckpool by Con Kolivas
Mempool Accelerator™ / Research FreeBSD Port - Portland.HODL
Ultra low overhead massively scalable multi-process, multi-threaded modular
bitcoin mining pool, proxy, passthrough, and library in c for Linux.
bitcoin mining pool, proxy, passthrough, and library in c for Linux. Currently
this port is in early alpha and may have bugs.
CKPOOL is code provided free of charge under the GPLv3 license but its development
is mostly paid for by commissioned funding, and the pool by default contributes

View File

@ -10,7 +10,6 @@
#include "config.h"
#include <sys/ioctl.h>
#include <sys/prctl.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
@ -20,6 +19,7 @@
#include <getopt.h>
#include <grp.h>
#include <jansson.h>
#include <libgen.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
@ -32,6 +32,8 @@
#include "stratifier.h"
#include "connector.h"
#define INET6_ADDRSTRLEN 46
ckpool_t *global_ckp;
static bool open_logfile(ckpool_t *ckp)
@ -495,7 +497,7 @@ int set_sendbufsize(ckpool_t *ckp, const int fd, const int len)
len, opt);
optlen = sizeof(opt);
opt = len * 4 / 3;
setsockopt(fd, SOL_SOCKET, SO_SNDBUFFORCE, &opt, optlen);
setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &opt, optlen);
getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &opt, &optlen);
opt /= 2;
}
@ -523,7 +525,7 @@ int set_recvbufsize(ckpool_t *ckp, const int fd, const int len)
len, opt);
optlen = sizeof(opt);
opt = len * 4 / 3;
setsockopt(fd, SOL_SOCKET, SO_RCVBUFFORCE, &opt, optlen);
setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &opt, optlen);
getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &opt, &optlen);
opt /= 2;
}
@ -1593,7 +1595,7 @@ int main(int argc, char **argv)
ckp.initial_args[ckp.args] = NULL;
appname = basename(argv[0]);
if (!strcmp(appname, "ckproxy"))
if(!strcmp(appname, "ckproxy"))
ckp.proxy = true;
while ((c = getopt_long(argc, argv, "Bc:Dd:g:HhkLl:Nn:PpqRS:s:tu", long_options, &i)) != -1) {
@ -1701,7 +1703,6 @@ int main(int argc, char **argv)
ckp.name = "ckpool";
}
snprintf(buf, 15, "%s", ckp.name);
prctl(PR_SET_NAME, buf, 0, 0, 0);
memset(buf, 0, 15);
if (ckp.grpnam) {
@ -1714,8 +1715,8 @@ int main(int argc, char **argv)
ckp.gr_gid = getegid();
if (!ckp.config) {
ckp.config = strdup(ckp.name);
realloc_strcat(&ckp.config, ".conf");
ckp.config = strdup(ckp.name);
realloc_strcat(&ckp.config, ".conf");
}
if (!ckp.socket_dir) {
ckp.socket_dir = strdup("/tmp/");
@ -1745,7 +1746,8 @@ int main(int argc, char **argv)
if (!ckp.btcdauth[i])
ckp.btcdauth[i] = strdup("user");
if (!ckp.btcdpass[i])
ckp.btcdpass[i] = strdup("pass");
ckp.btcdpass[i] = strdup
("pass");
}
ckp.donaddress = "bc1q28kkr5hk4gnqe3evma6runjrd2pvqyp8fpwfzu";
@ -1777,8 +1779,12 @@ int main(int argc, char **argv)
ckp.startdiff = 42;
if (!ckp.highdiff)
ckp.highdiff = 1000000;
if (!ckp.logdir)
if (ckp.logdir) {
char *t = strdup(ckp.logdir);
ckp.logdir = t;
} else {
ckp.logdir = strdup("logs");
}
if (!ckp.serverurls)
ckp.serverurl = ckzalloc(sizeof(char *));
if (ckp.proxy && !ckp.proxies)

View File

@ -3127,7 +3127,7 @@ static void send_subproxystats(gdata_t *gdata, const int sockd)
static void parse_globaluser(ckpool_t *ckp, gdata_t *gdata, const char *buf)
{
char *url, *username, *pass = strdupa(buf);
char *url, *username, *pass = strdup(buf);
int userid = -1, proxyid = -1;
proxy_instance_t *proxy, *tmp;
int64_t clientid = -1;

View File

@ -0,0 +1,10 @@
prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: Jansson
Description: Library for encoding, decoding and manipulating JSON data
Version: 2.14
Libs: -L${libdir} -ljansson
Cflags: -I${includedir}

View File

@ -0,0 +1,161 @@
/* jansson_private_config.h. Generated from jansson_private_config.h.in by configure. */
/* jansson_private_config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if gcc's __atomic builtins are available */
#define HAVE_ATOMIC_BUILTINS 1
/* Define to 1 if you have the 'close' function. */
#define HAVE_CLOSE 1
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
/* Define to 1 if you have the <endian.h> header file. */
#define HAVE_ENDIAN_H 1
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define to 1 if you have the 'getpid' function. */
#define HAVE_GETPID 1
/* Define to 1 if you have the 'gettimeofday' function. */
#define HAVE_GETTIMEOFDAY 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the 'localeconv' function. */
#define HAVE_LOCALECONV 1
/* Define to 1 if you have the <locale.h> header file. */
#define HAVE_LOCALE_H 1
/* Define to 1 if the system has the type 'long long int'. */
#define HAVE_LONG_LONG_INT 1
/* Define to 1 if you have the 'open' function. */
#define HAVE_OPEN 1
/* Define to 1 if you have the 'read' function. */
#define HAVE_READ 1
/* Define to 1 if you have the <sched.h> header file. */
#define HAVE_SCHED_H 1
/* Define to 1 if you have the 'sched_yield' function. */
#define HAVE_SCHED_YIELD 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdio.h> header file. */
#define HAVE_STDIO_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the 'strtoll' function. */
#define HAVE_STRTOLL 1
/* Define to 1 if gcc's __sync builtins are available */
#define HAVE_SYNC_BUILTINS 1
/* Define to 1 if you have the <sys/param.h> header file. */
#define HAVE_SYS_PARAM_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if the system has the type 'unsigned long long int'. */
#define HAVE_UNSIGNED_LONG_LONG_INT 1
/* Number of buckets new object hashtables contain is 2 raised to this power.
E.g. 3 -> 2^3 = 8. */
#define INITIAL_HASHTABLE_ORDER 3
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#define LT_OBJDIR ".libs/"
/* Name of package */
#define PACKAGE "jansson"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "https://github.com/akheron/jansson/issues"
/* Define to the full name of this package. */
#define PACKAGE_NAME "jansson"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "jansson 2.14"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "jansson"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "2.14"
/* Define to 1 if all of the C89 standard headers exist (not just the ones
required in a freestanding environment). This macro is provided for
backward compatibility; new code need not use it. */
#define STDC_HEADERS 1
/* Define to 1 if /dev/urandom should be used for seeding the hash function */
#define USE_URANDOM 1
/* Define to 1 if CryptGenRandom should be used for seeding the hash function
*/
#define USE_WINDOWS_CRYPTOAPI 1
/* Version number of package */
#define VERSION "2.14"
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
/* #undef _UINT32_T */
/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
/* #undef _UINT8_T */
/* Define to '__inline__' or '__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
/* #undef inline */
#endif
/* Define to the type of a signed integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
/* #undef int32_t */
/* Define to the type of an unsigned integer type of width exactly 16 bits if
such a type exists and the standard includes do not define it. */
/* #undef uint16_t */
/* Define to the type of an unsigned integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
/* #undef uint32_t */
/* Define to the type of an unsigned integer type of width exactly 8 bits if
such a type exists and the standard includes do not define it. */
/* #undef uint8_t */

View File

@ -3,7 +3,7 @@
/* Define to 1 if gcc's __atomic builtins are available */
#undef HAVE_ATOMIC_BUILTINS
/* Define to 1 if you have the `close' function. */
/* Define to 1 if you have the 'close' function. */
#undef HAVE_CLOSE
/* Define to 1 if you have the <dlfcn.h> header file. */
@ -15,34 +15,34 @@
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if you have the `getpid' function. */
/* Define to 1 if you have the 'getpid' function. */
#undef HAVE_GETPID
/* Define to 1 if you have the `gettimeofday' function. */
/* Define to 1 if you have the 'gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `localeconv' function. */
/* Define to 1 if you have the 'localeconv' function. */
#undef HAVE_LOCALECONV
/* Define to 1 if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
/* Define to 1 if the system has the type `long long int'. */
/* Define to 1 if the system has the type 'long long int'. */
#undef HAVE_LONG_LONG_INT
/* Define to 1 if you have the `open' function. */
/* Define to 1 if you have the 'open' function. */
#undef HAVE_OPEN
/* Define to 1 if you have the `read' function. */
/* Define to 1 if you have the 'read' function. */
#undef HAVE_READ
/* Define to 1 if you have the <sched.h> header file. */
#undef HAVE_SCHED_H
/* Define to 1 if you have the `sched_yield' function. */
/* Define to 1 if you have the 'sched_yield' function. */
#undef HAVE_SCHED_YIELD
/* Define to 1 if you have the <stdint.h> header file. */
@ -60,7 +60,7 @@
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the `strtoll' function. */
/* Define to 1 if you have the 'strtoll' function. */
#undef HAVE_STRTOLL
/* Define to 1 if gcc's __sync builtins are available */
@ -81,7 +81,7 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if the system has the type `unsigned long long int'. */
/* Define to 1 if the system has the type 'unsigned long long int'. */
#undef HAVE_UNSIGNED_LONG_LONG_INT
/* Number of buckets new object hashtables contain is 2 raised to this power.
@ -112,7 +112,7 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if all of the C90 standard headers exist (not just the ones
/* Define to 1 if all of the C89 standard headers exist (not just the ones
required in a freestanding environment). This macro is provided for
backward compatibility; new code need not use it. */
#undef STDC_HEADERS
@ -137,7 +137,7 @@
#define below would cause a syntax error. */
#undef _UINT8_T
/* Define to `__inline__' or `__inline' if that's what the C compiler
/* Define to '__inline__' or '__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
#undef inline

View File

@ -0,0 +1,51 @@
/*
* Copyright (c) 2010-2016 Petri Lehtinen <petri@digip.org>
*
* Jansson is free software; you can redistribute it and/or modify
* it under the terms of the MIT license. See LICENSE for details.
*
*
* This file specifies a part of the site-specific configuration for
* Jansson, namely those things that affect the public API in
* jansson.h.
*
* The configure script copies this file to jansson_config.h and
* replaces @var@ substitutions by values that fit your system. If you
* cannot run the configure script, you can do the value substitution
* by hand.
*/
#ifndef JANSSON_CONFIG_H
#define JANSSON_CONFIG_H
/* If your compiler supports the inline keyword in C, JSON_INLINE is
defined to `inline', otherwise empty. In C++, the inline is always
supported. */
#ifdef __cplusplus
#define JSON_INLINE inline
#else
#define JSON_INLINE inline
#endif
/* If your compiler supports the `long long` type and the strtoll()
library function, JSON_INTEGER_IS_LONG_LONG is defined to 1,
otherwise to 0. */
#define JSON_INTEGER_IS_LONG_LONG 1
/* If locale.h and localeconv() are available, define to 1,
otherwise to 0. */
#define JSON_HAVE_LOCALECONV 1
/* If __atomic builtins are available they will be used to manage
reference counts of json_t. */
#define JSON_HAVE_ATOMIC_BUILTINS 1
/* If __atomic builtins are not available we try using __sync builtins
to manage reference counts of json_t. */
#define JSON_HAVE_SYNC_BUILTINS 1
/* Maximum recursion depth for parsing JSON input.
This limits the depth of e.g. array-within-array constructions. */
#define JSON_PARSER_MAX_DEPTH 2048
#endif

View File

@ -1,9 +1,9 @@
#! /bin/sh
# test-driver - basic testsuite driver script.
scriptversion=2018-03-07.03; # UTC
scriptversion=2024-06-19.01; # UTC
# Copyright (C) 2011-2021 Free Software Foundation, Inc.
# Copyright (C) 2011-2024 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -44,11 +44,16 @@ print_usage ()
Usage:
test-driver --test-name NAME --log-file PATH --trs-file PATH
[--expect-failure {yes|no}] [--color-tests {yes|no}]
[--collect-skipped-logs {yes|no}]
[--enable-hard-errors {yes|no}] [--]
TEST-SCRIPT [TEST-SCRIPT-ARGUMENTS]
The '--test-name', '--log-file' and '--trs-file' options are mandatory.
See the GNU Automake documentation for information.
Report bugs to <bug-automake@gnu.org>.
GNU Automake home page: <https://www.gnu.org/software/automake/>.
General help using GNU software: <https://www.gnu.org/gethelp/>.
END
}
@ -57,15 +62,17 @@ log_file= # Where to save the output of the test script.
trs_file= # Where to save the metadata of the test run.
expect_failure=no
color_tests=no
collect_skipped_logs=yes
enable_hard_errors=yes
while test $# -gt 0; do
case $1 in
--help) print_usage; exit $?;;
--version) echo "test-driver $scriptversion"; exit $?;;
--version) echo "test-driver (GNU Automake) $scriptversion"; exit $?;;
--test-name) test_name=$2; shift;;
--log-file) log_file=$2; shift;;
--trs-file) trs_file=$2; shift;;
--color-tests) color_tests=$2; shift;;
--collect-skipped-logs) collect_skipped_logs=$2; shift;;
--expect-failure) expect_failure=$2; shift;;
--enable-hard-errors) enable_hard_errors=$2; shift;;
--) shift; break;;
@ -121,7 +128,7 @@ fi
case $tweaked_estatus:$expect_failure in
0:yes) col=$red res=XPASS recheck=yes gcopy=yes;;
0:*) col=$grn res=PASS recheck=no gcopy=no;;
77:*) col=$blu res=SKIP recheck=no gcopy=yes;;
77:*) col=$blu res=SKIP recheck=no gcopy=$collect_skipped_logs;;
99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;;
*:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;;
*:*) col=$red res=FAIL recheck=yes gcopy=yes;;

BIN
src/libckpool.a Normal file

Binary file not shown.

View File

@ -18,13 +18,14 @@
#endif
#include <sys/epoll.h>
#include <sys/file.h>
#include <sys/prctl.h>
//#include <sys/prctl.h>
#include <sys/stat.h>
#include <netdb.h>
#include <unistd.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <pthread_np.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
@ -41,6 +42,15 @@
#define UNIX_PATH_MAX 108
#endif
#define strdupa(s) \
({ \
const char *__old = (s); \
size_t __len = strlen(__old) + 1; \
char *__new = (char *) alloca(__len); \
(char *) memcpy(__new, __old, __len); \
})
/* We use a weak function as a simple printf within the library that can be
* overridden by however the outside executable wishes to do its logging. */
void __attribute__((weak)) logmsg(int __maybe_unused loglevel, const char *fmt, ...)
@ -62,7 +72,7 @@ void rename_proc(const char *name)
snprintf(buf, 15, "ckp@%s", name);
buf[15] = '\0';
prctl(PR_SET_NAME, buf, 0, 0, 0);
pthread_set_name_np(pthread_self(), buf);
}
void create_pthread(pthread_t *thread, void *(*start_routine)(void *), void *arg)
@ -477,7 +487,7 @@ bool extract_sockaddr(char *url, char **sockaddr_url, char **sockaddr_port)
url_len -= 2;
url_begin++;
}
if (url_len < 1) {
LOGWARNING("Null length URL passed to extract_sockaddr");
return false;
@ -633,10 +643,10 @@ void keep_sockalive(int fd)
const int tcp_keepintvl = 30;
setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (const void *)&tcp_one, sizeof(tcp_one));
setsockopt(fd, SOL_TCP, TCP_NODELAY, (const void *)&tcp_one, sizeof(tcp_one));
setsockopt(fd, SOL_TCP, TCP_KEEPCNT, &tcp_one, sizeof(tcp_one));
setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &tcp_keepidle, sizeof(tcp_keepidle));
setsockopt(fd, SOL_TCP, TCP_KEEPINTVL, &tcp_keepintvl, sizeof(tcp_keepintvl));
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (const void *)&tcp_one, sizeof(tcp_one));
setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &tcp_one, sizeof(tcp_one));
setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &tcp_keepidle, sizeof(tcp_keepidle));
setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, &tcp_keepintvl, sizeof(tcp_keepintvl));
}
void nolinger_socket(int fd)
@ -660,7 +670,7 @@ void block_socket(int fd)
fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
}
void _close(int *fd, const char *file, const char *func, const int line)
void ckp_close(int *fd, const char *file, const char *func, const int line)
{
int sockd;
@ -1328,7 +1338,7 @@ char *json_array_string(json_t *val, unsigned int entry)
const char *buf = __json_array_string(val, entry);
if (buf)
return strdup(buf);
return strdupa(buf);
return NULL;
}
@ -1409,11 +1419,14 @@ void realloc_strcat(char **ptr, const char *s)
LOGWARNING("Passed empty string to realloc_strcat");
return;
}
if (!*ptr)
if (!*ptr) {
old = 0;
else
len = new + 1;
}
else {
old = strlen(*ptr);
len = old + new + 1;
len = old + new + 1;
}
len = round_up_page(len);
while (42) {
new_ptr = realloc(*ptr, len);
@ -1426,16 +1439,19 @@ void realloc_strcat(char **ptr, const char *s)
}
*ptr = new_ptr;
ofs = *ptr + old;
sprintf(ofs, "%s", s);
strcpy(ofs, s);
}
void trail_slash(char **buf)
{
int ofs;
size_t ofs;
ofs = strlen(*buf) - 1;
if (memcmp(*buf + ofs, "/", 1))
realloc_strcat(buf, "/");
if (!*buf)
return;
ofs = strlen(*buf);
if (ofs && (*buf)[ofs - 1] != '/')
realloc_strcat(buf, "/");
}
void *_ckalloc(size_t len, const char *file, const char *func, const int line)

View File

@ -509,9 +509,9 @@ void keep_sockalive(int fd);
void nolinger_socket(int fd);
void noblock_socket(int fd);
void block_socket(int fd);
void _close(int *fd, const char *file, const char *func, const int line);
#define _Close(FD) _close(FD, __FILE__, __func__, __LINE__)
#define Close(FD) _close(&FD, __FILE__, __func__, __LINE__)
void ckp_close(int *fd, const char *file, const char *func, const int line);
#define _Close(FD) ckp_close(FD, __FILE__, __func__, __LINE__)
#define Close(FD) ckp_close(&FD, __FILE__, __func__, __LINE__)
int bind_socket(char *url, char *port);
int connect_socket(char *url, char *port);
int round_trip(char *url);

BIN
src/notifier Executable file

Binary file not shown.

View File

@ -19,6 +19,7 @@
#include <math.h>
#include <string.h>
#include <unistd.h>
#include <libgen.h>
#ifdef HAVE_ZMQ_H
#include <zmq.h>
@ -40,6 +41,15 @@ static const char *scriptsig_header = "01000000010000000000000000000000000000000
static uchar scriptsig_header_bin[41];
static const double nonces = 4294967296;
# define strdupa(s) \
({ \
const char *__old = (s); \
size_t __len = strlen(__old) + 1; \
char *__new = (char *) alloca(__len); \
(char *) memcpy(__new, __old, __len); \
})
/* Add unaccounted shares when they arrive, remove them with each update of
* rolling stats. */
struct pool_stats {
@ -4941,7 +4951,7 @@ static json_t *parse_subscribe(stratum_instance_t *client, const int64_t client_
buf = json_string_value(json_array_get(params_val, 0));
if (buf && strlen(buf))
client->useragent = strdup(buf);
client->useragent = strdupa(buf);
else
client->useragent = ckzalloc(1); // Set to ""
if (arr_size > 1) {
@ -5150,7 +5160,7 @@ static void read_userstats(ckpool_t *ckp, sdata_t *sdata, int tvsec_diff)
int lastshare;
size_t index;
username = basename(dir->d_name);
username = basename(dir->d_name);
if (!strcmp(username, "/") || !strcmp(username, ".") || !strcmp(username, ".."))
continue;
@ -5299,7 +5309,7 @@ static worker_instance_t *__create_worker(user_instance_t *user, const char *wor
{
worker_instance_t *worker = ckzalloc(sizeof(worker_instance_t));
worker->workername = strdup(workername);
worker->workername = strdupa(workername);
worker->user_instance = user;
DL_APPEND(user->worker_instances, worker);
worker->start_time = time(NULL);

94
start Executable file
View File

@ -0,0 +1,94 @@
#!/usr/bin/env zsh
# Mempool.Space CKSolo Pool Start Script - PortlandHODL
#
# Options for base CKSolo config [No Failover / Proxy]
# $1 - NETWORK
# $2 - Payout Address
# $3 - Port
# Initialize variables
DAEMON=$1
NETWORK=${DAEMON} # Context Alias
COINBASE_PAYOUT_ADDRESS=$2
# Check that the NETWORK provided is correct
# 'bitcoin' is mainnet and needs an mainnet address
if [ "$NETWORK" = "bitcoin" ] || [ "$NETWORK" = "testnet3" ] || [ "$NETWORK" = "testnet4" ]; then
echo "Setting up Mempool.space CKPool with NETWORK $NETWORK"
if [ "$NETWORK" = "bitcoin" ]; then
COINBASE_PAYOUT_ADDRESS="1wizSAYSbuyXbt9d8JV8ytm5acqq2TorC"
elif [ "$NETWORK" = "testnet3" ]; then
COINBASE_PAYOUT_ADDRESS="tb1qjfplwf7a2dpjj04cx96rysqeastvycc0j50cch"
elif [ "$NETWORK" = "testnet4" ]; then
COINBASE_PAYOUT_ADDRESS="tb1qjfplwf7a2dpjj04cx96rysqeastvycc0j50cch"
else
echo "Network setting unsupported for magic coinbase payout address replacement"
fi
else
echo "Invalid network selected: $NETWORK, please use bitcoin, testnet3, testnet4"
exit 1
fi
echo "Starting Mempool.space CKSolo using ${NETWORK} network with payout address i${COINBASE_PAYOUT_ADDRESS}"
# Fetch Bitcoin node credentials from the Bitcoin.conf file
DAEMON_CONF="/bitcoin/${DAEMON}.conf"
echo "[*] Getting RPC credentials from ${DAEMON_CONF}"
RPC_USER=$(grep 'rpcuser=' "${DAEMON_CONF}"|cut -d = -f2|head -1)
RPC_PASS=$(grep 'rpcpassword=' "${DAEMON_CONF}"|cut -d = -f2|head -1)
# Create ckpool config file
CONFIG_DIR="${HOME}/.ckpool/${NETWORK}"
CONFIG_FILE="${CONFIG_DIR}/ckpool.conf"
mkdir -p "${CONFIG_DIR}"
cat > "${CONFIG_FILE}" << EOF
{
"btcd" : [
{
"url" : "127.0.0.1:8332",
"auth" : "${RPC_USER}",
"pass" : "${RPC_PASS}",
"notify" : true
}
],
"btcaddress" : "${COINBASE_PAYOUT_ADDRESS}",
"btcsig" : "/@wiz/",
"blockpoll" : 100,
"nonce1length" : 4,
"nonce2length" : 8,
"update_interval" : 30,
"version_mask" : "1fffe000",
"serverurl" : [
"127.0.0.1:3333"
],
"mindiff" : 1,
"startdiff" : 42,
"maxdiff" : 0,
"logdir" : "logs"
}
EOF
echo "[*] Created config file at ${CONFIG_FILE}"
# run in loop in case of crash
until false
do
# reset CWD
cd "${CONFIG_DIR}"
# disable making core files
ulimit -c 0
echo "[*] Starting ckpool..."
# Run ckpool with the config
ckpool "${CONFIG_FILE}"
# Wait a bit before restarting
echo "[*] ckpool exited, restarting in 1 second..."
sleep 1
done

1282
tags Normal file

File diff suppressed because it is too large Load Diff