angepasst an nversion

This commit is contained in:
w12
2025-01-07 16:03:22 +01:00
parent addca77148
commit 16e4a45175
7 changed files with 7707 additions and 131 deletions

View File

@@ -1,5 +1,6 @@
AUTOMAKE_OPTIONS = subdir-objects
# Bedingte Optionen für Jansson
if WANT_JANSSON
JANSSON_INCLUDES = @JANSSON_CFLAGS@
else
@@ -14,25 +15,21 @@ bin_PROGRAMS = nolambocoin-miner
dist_man_MANS = nolambocoin-miner.1
nolambocoin-miner_SOURCES = \
elist.h miner.h compat.h \
cpu-miner.c util.c \
sha2.c \
nolambocoin_miner_SOURCES = \
cpu-miner.c util.c sha2.c \
yespower-1.0.1/sha256.c yespower-1.0.1/yespower-opt.c \
YespowerSugar.c \
YespowerIso.c \
YespowerNull.c \
YespowerUrx.c \
YespowerLitb.c \
YespowerIots.c \
YespowerItc.c \
YespowerYtn.c \
yespower-1.0.1-power2b/sha256-p2b.c yespower-1.0.1-power2b/yespower-opt-p2b.c yespower-1.0.1-power2b/blake2b.c \
YespowerMbc.c \
YespowerARM.c \
version.h
YespowerSugar.c YespowerIso.c YespowerNull.c \
YespowerUrx.c YespowerLitb.c YespowerIots.c \
YespowerItc.c YespowerYtn.c \
yespower-1.0.1-power2b/sha256-p2b.c yespower-1.0.1-power2b/yespower-opt-p2b.c \
yespower-1.0.1-power2b/blake2b.c YespowerMbc.c \
YespowerARM.c
AM_CPPFLAGS = $(JANSSON_INCLUDES) -I$(top_srcdir)/compat/jansson @PTHREAD_CFLAGS@
# Entferne Header-Dateien aus SOURCES und definiere sie separat
include_HEADERS = \
elist.h miner.h compat.h
AM_CPPFLAGS = $(JANSSON_INCLUDES) -I$(top_srcdir)/compat/jansson $(PTHREAD_CFLAGS)
# Allgemeine Compiler-Flags basierend auf den Conditionals setzen
if TARGET_RASPBERRY_PI
@@ -55,9 +52,9 @@ if TARGET_WINDOWS
AM_CPPFLAGS += -DTARGET_WINDOWS
endif
nolambocoin-miner_LDFLAGS = @PTHREAD_LIBS@
nolambocoin-miner_LDADD = @CURL_LIBS@ @JANSSON_LIBS@ @PTHREAD_LIBS@ @WS2_LIBS@
nolambocoin_miner_LDFLAGS = $(PTHREAD_LIBS)
nolambocoin_miner_LDADD = @CURL_LIBS@ @JANSSON_LIBS@ $(PTHREAD_LIBS) @WS2_LIBS@
if TARGET_WINDOWS
nolambocoin-miner_LDADD += @WS2_LIBS@
endif
nolambocoin_miner_LDADD += @WS2_LIBS@
endif

View File

@@ -10,10 +10,8 @@
#ifdef TARGET_RASPBERRY_PI
#define BLOCK_VERSION BLOCK_VERSION_RASPBERRY
#elif defined(TARGET_ARM_SERVER)
#define BLOCK_VERSION BLOCK_VERSION_ARM_SERVER
#elif defined(TARGET_X86_64)
#define BLOCK_VERSION BLOCK_VERSION_X86_64
#elif defined(TARGET_NOARM)
#define BLOCK_VERSION BLOCK_VERSION_NOARM
#else
#define BLOCK_VERSION BLOCK_VERSION_DEFAULT
#endif
@@ -23,42 +21,22 @@ const yespower_params_t *select_yespower_params(void) {
#ifdef TARGET_RASPBERRY_PI
static const yespower_params_t params_rpi = {
.version = YESPOWER_1_0,
.N = 1024, // Angepasster Wert für bessere Performance
.N = 2048, // Angepasster Wert für bessere Performance
.r = 8,
.pers = (const uint8_t *)"Raspberry",
.perslen = 9 // "Raspberry" hat 10 Zeichen
.perslen = 10 // "Raspberry" hat 10 Zeichen
};
return &params_rpi;
#elif defined(TARGET_ARM_SERVER)
static const yespower_params_t params_arm_server = {
#elif defined(TARGET_NOARM)
static const yespower_params_t params_noarm = {
.version = YESPOWER_1_0,
.N = 4096,
.r = 16,
.pers = (const uint8_t *)"ARMServer",
.perslen = 9 // "ARMServer" hat 9 Zeichen
.pers = (const uint8_t *)"NoARM",
.perslen = 5 // "NoARM" hat 5 Zeichen
};
return &params_arm_server;
#elif defined(TARGET_X86_64)
static const yespower_params_t params_x86_64 = {
.version = YESPOWER_1_0,
.N = 4096,
.r = 16,
.pers = (const uint8_t *)"Default",
.perslen = 7 // "Default" hat 7 Zeichen
};
return &params_x86_64;
#elif defined(TARGET_WINDOWS)
static const yespower_params_t params_windows = {
.version = YESPOWER_1_0,
.N = 4096,
.r = 16,
.pers = (const uint8_t *)"Windows",
.perslen = 7 // "Windows" hat 7 Zeichen
};
return &params_windows;
return &params_noarm;
#else
static const yespower_params_t params_default = {
@@ -79,34 +57,45 @@ int yespower_hash(const char *input, char *output) {
}
/* Scanhash-Funktion für ARM-Architektur mit Yespower */
int scanhash_arm_yespower(int thr_id, uint32_t *data, const uint32_t *target, uint32_t max_nonce, unsigned long *hashes_done) {
uint32_t nonce = data[19]; // Nonce ist das 20. Element der Daten
unsigned char hash[32]; // Speicher für den berechneten Hash
int result = 0; // Rückgabewert
*hashes_done = 0; // Initialisierung der Hashanzahl
int scanhash_arm_yespower(int thr_id, uint32_t *pdata, const uint32_t *ptarget, uint32_t max_nonce, unsigned long *hashes_done) {
const yespower_params_t *params = select_yespower_params(); // Dynamische Parameter-Auswahl
// Wähle die Yespower-Parameter basierend auf Kompilierungszeit-Makros
const yespower_params_t *params = select_yespower_params();
union {
uint8_t u8[80]; // 20 * 4 bytes
uint32_t u32[20];
} data;
for (; nonce < max_nonce; nonce++) {
data[19] = nonce; // Aktualisiere die Nonce
union {
yespower_binary_t yb;
uint32_t u32[8];
} hash;
// Berechne den Hash mit Yespower
if (yespower_tls((const uint8_t *)data, 80, params, (yespower_binary_t *)hash) != 0) {
fprintf(stderr, "Thread %d: Fehler bei der Yespower-Berechnung.\n", thr_id);
break;
uint32_t n = pdata[19] - 1;
const uint32_t Htarg = ptarget[7];
int i;
// Kodierung der Daten in Big-Endian
for (i = 0; i < 20; i++)
be32enc(&data.u32[i], pdata[i]);
do {
be32enc(&data.u32[19], ++n);
if (yespower_tls(data.u8, 80, params, &hash.yb))
abort();
if (le32dec(&hash.u32[7]) <= Htarg) {
for (i = 0; i < 8; i++)
hash.u32[i] = le32dec(&hash.u32[i]);
if (fulltest(hash.u32, ptarget)) {
*hashes_done = n - pdata[19] + 1;
pdata[19] = n;
return 1;
}
}
} while (n < max_nonce && !work_restart[thr_id].restart);
// Prüfe, ob der berechnete Hash kleiner als das Ziel ist
if (memcmp(hash, target, 32) <= 0) {
printf("Thread %d: Gültiger Hash gefunden! Nonce: %u\n", thr_id, nonce);
result = 1;
break;
}
(*hashes_done)++;
}
data[19] = nonce; // Stelle die Nonce wieder her
return result;
*hashes_done = n - pdata[19] + 1;
pdata[19] = n;
return 0;
}

View File

@@ -2,6 +2,7 @@
make distclean || echo clean
rm -f config.status
sudo chmod +x autogen.sh
# BUILD
./autogen.sh
./configure CFLAGS="-Wall -O2 -fomit-frame-pointer"

View File

@@ -1,16 +1,27 @@
AC_INIT([nolambocoin-miner], [1.0])
AC_INIT([nolambocoin], [1.0])
AC_PREREQ([2.59c])
AC_CONFIG_SRCDIR([cpu-miner.c])
AM_INIT_AUTOMAKE([foreign])
AC_CONFIG_HEADERS([cpuminer-config.h])
dnl Make sure anyone changing configure.ac/Makefile.am has a clue
AM_MAINTAINER_MODE
EXTERNAL_CFLAGS="$CFLAGS"
dnl Checks for programs
# Check for jansson
PKG_CHECK_MODULES([JANSSON], [jansson], [], [AC_MSG_ERROR([jansson is required but not installed.])])
AM_CONDITIONAL([WANT_JANSSON], [true])
AC_SUBST([JANSSON_CFLAGS])
AC_SUBST([JANSSON_LIBS])
# Check for libcurl
PKG_CHECK_MODULES([CURL], [libcurl], [], [AC_MSG_ERROR([libcurl is required but not installed.])])
AC_SUBST([CURL_CFLAGS])
AC_SUBST([CURL_LIBS])
# Checks for programs
AC_PROG_CC
AC_PROG_GCC_TRADITIONAL
AM_PROG_CC_C_O
@@ -18,12 +29,12 @@ AM_PROG_AS
AC_PROG_RANLIB
if test -n "$EXTERNAL_CFLAGS"; then
CFLAGS="$EXTERNAL_CFLAGS"
CFLAGS="$EXTERNAL_CFLAGS"
else
CFLAGS='-Wall -O2 -fomit-frame-pointer'
CFLAGS='-Wall -O2 -fomit-frame-pointer'
fi
dnl Checks for header files
# Checks for header files
AC_CHECK_HEADERS([sys/endian.h sys/param.h syslog.h sys/sysctl.h])
AC_CHECK_DECLS([be32dec, le32dec, be32enc, le32enc], [],
@@ -38,54 +49,26 @@ AC_CHECK_DECLS([be32dec, le32dec, be32enc, le32enc], [],
AC_FUNC_ALLOCA
AC_CHECK_FUNCS([getopt_long])
dnl Pthread Flags
AC_CHECK_LIB([pthread], [pthread_create],
[PTHREAD_LIBS="-lpthread"],
[AC_MSG_ERROR([pthread library not found.])])
AC_SUBST([PTHREAD_LIBS])
AC_CHECK_FLAGS([-pthread],
[PTHREAD_CFLAGS="-pthread"],
[PTHREAD_CFLAGS=""])
AC_SUBST([PTHREAD_CFLAGS])
dnl WS2 Libraries (Windows)
# Define WS2_LIBS for Windows (set to empty for non-Windows platforms)
WS2_LIBS=""
have_win32=false
# Conditional builds for all platforms
case $target in
*-*-mingw*)
have_win32=true
case "$target_os" in
mingw*|cygwin*)
WS2_LIBS="-lws2_32"
;;
esac
AC_SUBST([WS2_LIBS])
dnl Checks for libcurl
PKG_CHECK_MODULES([CURL], [libcurl], [], [AC_MSG_ERROR([libcurl is required but not installed.])])
AC_SUBST([CURL_CFLAGS])
AC_SUBST([CURL_LIBS])
dnl Checks for jansson
PKG_CHECK_MODULES([JANSSON], [jansson], [], [AC_MSG_ERROR([jansson is required but not installed.])])
AC_SUBST([JANSSON_CFLAGS])
AC_SUBST([JANSSON_LIBS])
dnl Platform Detection
AC_MSG_CHECKING([for target platform])
# Platform detection
UNAME_S=`uname -s`
UNAME_M=`uname -m`
AC_MSG_CHECKING([for target platform])
AC_MSG_RESULT([$UNAME_S $UNAME_M])
case "$UNAME_S" in
Linux*)
case "$UNAME_M" in
armv7l*|armv8*|aarch64*)
# Allgemeine Raspberry Pi Erkennung ohne spezifische Modelle
if grep -q "Raspberry Pi" /proc/device-tree/model 2>/dev/null; then
AC_DEFINE([TARGET_RASPBERRY_PI], [1], [Define to 1 if compiling for Raspberry Pi])
AM_CONDITIONAL([TARGET_RASPBERRY_PI], [true])
@@ -141,14 +124,9 @@ case "$UNAME_S" in
;;
esac
AM_CONDITIONAL([WANT_JANSSON], [true])
AC_SUBST(JANSSON_CFLAGS)
AC_SUBST(JANSSON_LIBS)
AC_SUBST(CURL_CFLAGS)
AC_SUBST(CURL_LIBS)
AC_SUBST(PTHREAD_CFLAGS)
AC_SUBST(PTHREAD_LIBS)
AC_SUBST(WS2_LIBS)
AC_OUTPUT
AC_CONFIG_FILES([
Makefile
compat/Makefile
compat/jansson/Makefile
])
AC_OUTPUT

7383
configure~ Normal file

File diff suppressed because it is too large Load Diff

229
sugarmaker.1 Normal file
View File

@@ -0,0 +1,229 @@
.TH SUGARMAKER 1 "2020-03-23" "sugarmaker 2.5.0-sugar4"
.SH NAME
sugarmaker \- CPU miner for YespowerSugar
.SH SYNOPSIS
.B sugarmaker
[\fIOPTION\fR]...
.SH DESCRIPTION
.B sugarmaker
is a multi-threaded CPU miner for YespowerSugar and other cryptocurrencies.
It supports the getwork and getblocktemplate (BIP 22) methods,
as well as the Stratum mining protocol.
.PP
In its normal mode of operation, \fBsugarmaker\fR connects to a mining server
(specified with the \fB\-o\fR option), receives work from it and starts hashing.
As soon as a solution is found, it is submitted to the same mining server,
which can accept or reject it.
When using getwork or getblocktemplate,
\fBsugarmaker\fR can take advantage of long polling, if the server supports it;
in any case, fresh work is fetched as needed.
When using the Stratum protocol this is not possible,
and the server is responsible for sending fresh work at least every minute;
if it fails to do so,
\fBsugarmaker\fR may drop the connection and try reconnecting again.
.PP
By default, \fBsugarmaker\fR writes all its messages to standard error.
On systems that have a syslog, the \fB\-\-syslog\fR option can be used
to write to it instead.
.PP
On start, the nice value of all miner threads is set to 19.
On Linux, the scheduling policy is also changed to SCHED_IDLE,
or to SCHED_BATCH if that fails.
On multiprocessor systems, \fBsugarmaker\fR
automatically sets the CPU affinity of miner threads
if the number of threads is a multiple of the number of processors.
.SH EXAMPLES
To connect to a Sugarchain mining pool that provides a Stratum server
at example.com on port 3333, authenticating as worker "foo" with password "bar":
.PP
.nf
.RS
sugarmaker \-o stratum+tcp://1pool.sugarchain.org:3333 \-O foo:bar
.RE
.fi
.PP
To mine to a local Sugarchain testnet instance running on port 44229,
authenticating with username "rpcuser" and password "rpcpass":
.PP
.nf
.RS
sugarmaker \-o http://127.0.0.1:44229 \-O rpcuser:rpcpass \\
\-\-coinbase\-addr=tugar1qkvl32hmzvgtwpu7v70k5u0kcv9s4uqy4twjge8
.RE
.fi
.PP
To connect to a Litecoin P2Pool node running on my.server on port 9327,
mining in the background and having output sent to the syslog facility,
omitting the per-thread hashmeter output:
.PP
.nf
.RS
sugarmaker \-BSq \-o http://my.server:9327
.RE
.fi
.SH OPTIONS
.TP
\fB\-a\fR, \fB\-\-algo\fR=\fIALGORITHM\fR
Set the hashing algorithm to use.
Default is YespowerSugar.
Possible values are:
.RS 11
.TP 10
.B YespowerSugar
Yespower(N=2048, R=32) (used by Sugarchain)
.RE
.TP
\fB\-\-benchmark\fR
Run in offline benchmark mode.
.TP
\fB\-B\fR, \fB\-\-background\fR
Run in the background as a daemon.
.TP
\fB\-\-cert\fR=\fIFILE\fR
Set an SSL certificate to use with the mining server.
Only supported when using the HTTPS protocol.
.TP
\fB\-\-coinbase\-addr\fR=\fIADDRESS\fR
Set a payout address for solo mining.
This is only used in getblocktemplate mode,
and only if the server does not provide a coinbase transaction.
It can be either a base-58 address, or a bech32 address (BIP 173).
.TP
\fB\-\-coinbase\-sig\fR=\fITEXT\fR
Set a string to be included in the coinbase (if allowed by the server).
This is only used in getblocktemplate mode.
.TP
\fB\-c\fR, \fB\-\-config\fR=\fIFILE\fR
Load options from a configuration file.
\fIFILE\fR must contain a JSON object
mapping long options to their arguments (as strings),
or to \fBtrue\fR if no argument is required.
Sample configuration file:
.nf
{
"url": "stratum+tcp://1pool.sugarchain.org:3333",
"userpass": "foo:bar",
"retry-pause": "10",
"quiet": true
}
.fi
.TP
\fB\-D\fR, \fB\-\-debug\fR
Enable debug output.
.TP
\fB\-h\fR, \fB\-\-help\fR
Print a help message and exit.
.TP
\fB\-\-no\-gbt\fR
Do not use the getblocktemplate RPC method.
.TP
\fB\-\-no\-getwork\fR
Do not use the getwork RPC method.
.TP
\fB\-\-no\-longpoll\fR
Do not use long polling.
.TP
\fB\-\-no\-redirect\fR
Ignore requests from the server to switch to a different URL.
.TP
\fB\-\-no\-stratum\fR
Do not switch to Stratum, even if the server advertises support for it.
.TP
\fB\-o\fR, \fB\-\-url\fR=[\fISCHEME\fR://][\fIUSERNAME\fR[:\fIPASSWORD\fR]@]\fIHOST\fR:\fIPORT\fR[/\fIPATH\fR]
Set the URL of the mining server to connect to.
Supported schemes are \fBhttp\fR, \fBhttps\fR, \fBstratum+tcp\fR
and \fBstratum+tcps\fR.
If no scheme is specified, http is assumed.
Specifying a \fIPATH\fR is only supported for HTTP and HTTPS.
Specifying credentials has the same effect as using the \fB\-O\fR option.
By default, on HTTP and HTTPS,
the miner tries to use the getblocktemplate RPC method,
and falls back to using getwork if getblocktemplate is unavailable.
This behavior can be modified by using the \fB\-\-no\-gbt\fR
and \fB\-\-no\-getwork\fR options.
.TP
\fB\-O\fR, \fB\-\-userpass\fR=\fIUSERNAME\fR:\fIPASSWORD\fR
Set the credentials to use for connecting to the mining server.
Any value previously set with \fB\-u\fR or \fB\-p\fR is discarded.
.TP
\fB\-p\fR, \fB\-\-pass\fR=\fIPASSWORD\fR
Set the password to use for connecting to the mining server.
Any password previously set with \fB\-O\fR is discarded.
.TP
\fB\-P\fR, \fB\-\-protocol\-dump\fR
Enable output of all protocol-level activities.
.TP
\fB\-q\fR, \fB\-\-quiet\fR
Disable per-thread hashmeter output.
.TP
\fB\-r\fR, \fB\-\-retries\fR=\fIN\fR
Set the maximum number of times to retry if a network call fails.
If not specified, the miner will retry indefinitely.
.TP
\fB\-R\fR, \fB\-\-retry\-pause\fR=\fISECONDS\fR
Set how long to wait between retries. Default is 30 seconds.
.TP
\fB\-s\fR, \fB\-\-scantime\fR=\fISECONDS\fR
Set an upper bound on the time the miner can go without fetching fresh work.
This setting has no effect in Stratum mode or when long polling is activated.
Default is 5 seconds.
.TP
\fB\-S\fR, \fB\-\-syslog\fR
Log to the syslog facility instead of standard error.
.TP
\fB\-t\fR, \fB\-\-threads\fR=\fIN\fR
Set the number of miner threads.
If not specified, the miner will try to detect the number of available processors
and use that.
.TP
\fB\-T\fR, \fB\-\-timeout\fR=\fISECONDS\fR
Set a timeout for long polling.
.TP
\fB\-u\fR, \fB\-\-user\fR=\fIUSERNAME\fR
Set the username to use for connecting to the mining server.
Any username previously set with \fB\-O\fR is discarded.
.TP
\fB\-V\fR, \fB\-\-version\fR
Display version information and quit.
.TP
\fB\-x\fR, \fB\-\-proxy\fR=[\fISCHEME\fR://][\fIUSERNAME\fR:\fIPASSWORD\fR@]\fIHOST\fR:\fIPORT\fR
Connect to the mining server through a proxy.
Supported schemes are: \fBhttp\fR, \fBsocks4\fR, \fBsocks5\fR.
Since libcurl 7.18.0, the following are also supported:
\fBsocks4a\fR, \fBsocks5h\fR (SOCKS5 with remote name resolving).
If no scheme is specified, the proxy is treated as an HTTP proxy.
.SH ENVIRONMENT
The following environment variables can be specified in lower case or upper case;
the lower-case version has precedence. \fBhttp_proxy\fR is an exception
as it is only available in lower case.
.PP
.RS
.TP
\fBhttp_proxy\fR [\fISCHEME\fR://]\fIHOST\fR:\fIPORT\fR
Sets the proxy server to use for HTTP.
.TP
\fBHTTPS_PROXY\fR [\fISCHEME\fR://]\fIHOST\fR:\fIPORT\fR
Sets the proxy server to use for HTTPS.
.TP
\fBALL_PROXY\fR [\fISCHEME\fR://]\fIHOST\fR:\fIPORT\fR
Sets the proxy server to use if no protocol-specific proxy is set.
.RE
.PP
Using an environment variable to set the proxy has the same effect as
using the \fB\-x\fR option.
.SH AUTHOR
Most of the code in the current version of sugarmaker was written by,
.PP
.RS
.TP
Jeff Garzik <jeff@garzik.org>
.TP
Pooler <pooler@litecoinpool.org>
.TP
Alexander Peslyak <solar@openwall.com>
.TP
Kanon <60179867+decryp2kanon@users.noreply.github.com>
.RE
.PP

View File

@@ -3,7 +3,6 @@
#pragma once
// Definiere Blockversionskonstanten
#define BLOCK_VERSION_RASPBERRY 0x01
#define BLOCK_VERSION_ARM_SERVER 0x02
#define BLOCK_VERSION_X86_64 0x03
#define BLOCK_VERSION_DEFAULT 0x00
#define BLOCK_VERSION_RASPBERRY 0x10000000
#define BLOCK_VERSION_NOARM 0x20000000
#define BLOCK_VERSION_DEFAULT 0x00000000