geändert
Some checks failed
Build CPU miner / build (push) Has been cancelled

This commit is contained in:
w12
2025-01-09 20:51:43 +01:00
parent cb2b90c376
commit 7cbc6044a6
5 changed files with 51 additions and 62 deletions

BIN
.YespowerARM.c.swp Normal file

Binary file not shown.

View File

@@ -8,62 +8,63 @@
#include <string.h> #include <string.h>
#include <inttypes.h> #include <inttypes.h>
int get_dynamic_block_version() { //#ifdef TARGET_RASPBERRY_PI
#ifdef TARGET_RASPBERRY // #define BLOCK_VERSION BLOCK_VERSION_RASPBERRY
#define BLOCK_VERSION BLOCK_VERSION_RASPBERRY //#elif defined(TARGET_NOARM)
#elif defined(TARGET_NOARM) // #define BLOCK_VERSION BLOCK_VERSION_NOARM
#define BLOCK_VERSION BLOCK_VERSION_NOARM //#else
#else // #define BLOCK_VERSION BLOCK_VERSION_DEFAULT
#define BLOCK_VERSION BLOCK_VERSION_DEFAULT //#endif
#endif
}
/* Auswahl der Yespower-Parameter basierend auf nVersion */ /* Auswahl der Yespower-Parameter basierend auf der Zielplattform */
const yespower_params_t *select_yespower_params(void) { const yespower_params_t *select_yespower_params(void) {
int nVersion = get_dynamic_block_version(); #ifdef TARGET_RASPBERRY
if ((nVersion & BLOCK_VERSION_RASPBERRY) == BLOCK_VERSION_RASPBERRY) {
static const yespower_params_t params_raspberry = { static const yespower_params_t params_raspberry = {
.version = YESPOWER_1_0, .version = YESPOWER_1_0,
.N = 2048, .N = 2048, // Angepasster Wert für bessere Performance
.r = 8, .r = 8,
.pers = (const uint8_t *)"Raspberry", .pers = (const uint8_t *)"Raspberry",
.perslen = 9 .perslen = 10 // "Raspberry" hat 10 Zeichen
}; };
//printf("Raspberry Pi Parameters: N=%d, r=%d\n", params_raspberry.N, params_raspberry.r);
return &params_raspberry; return &params_raspberry;
} else if ((nVersion & BLOCK_VERSION_NOARM) == BLOCK_VERSION_NOARM) {
#elif defined(TARGET_NOARM)
static const yespower_params_t params_noarm = { static const yespower_params_t params_noarm = {
.version = YESPOWER_1_0, .version = YESPOWER_1_0,
.N = 4096, .N = 4096,
.r = 16, .r = 16,
.pers = (const uint8_t *)"NoARM", .pers = (const uint8_t *)"NoARM",
.perslen = 5 .perslen = 5 // "NoARM" hat 5 Zeichen
}; };
printf("NoARM Parameters: N=%d, r=%d\n", params_noarm.N, params_noarm.r);
return &params_noarm; return &params_noarm;
} else {
#else
static const yespower_params_t params_default = { static const yespower_params_t params_default = {
.version = YESPOWER_1_0, .version = YESPOWER_1_0,
.N = 4096, .N = 4096,
.r = 16, .r = 16,
.pers = (const uint8_t *)"Fallback", .pers = (const uint8_t *)"Default",
.perslen = 8 .perslen = 7 // "Default" hat 7 Zeichen
}; };
printf("Default Parameters: N=%d, r=%d\n", params_default.N, params_default.r);
return &params_default; return &params_default;
} #endif
} }
/* Berechnung des Yespower-Hashes */ /* Berechnung des Yespower-Hashes */
int yespower_hash(const char *input, char *output, int32_t nVersion) { int yespower_hash(const char *input, char *output) {
const yespower_params_t *params = select_yespower_params_by_version(nVersion); const yespower_params_t *params = select_yespower_params();
return yespower_tls((const uint8_t *)input, 80, params, (yespower_binary_t *)output); return yespower_tls((const uint8_t *)input, 80, params, (yespower_binary_t *)output);
} }
/* Scanhash-Funktion für ARM-Architektur mit Yespower */ /* Scanhash-Funktion für ARM-Architektur mit Yespower */
int scanhash_arm_yespower(int thr_id, uint32_t *pdata, const uint32_t *ptarget, uint32_t max_nonce, unsigned long *hashes_done, int32_t nVersion) { 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_by_version(nVersion); const yespower_params_t *params = select_yespower_params(); // Dynamische Parameter-Auswahl
union { union {
uint8_t u8[80]; // 80 Bytes Blockheader uint8_t u8[80]; // 20 * 4 bytes
uint32_t u32[20]; uint32_t u32[20];
} data; } data;
@@ -72,50 +73,38 @@ int scanhash_arm_yespower(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
uint32_t u32[8]; uint32_t u32[8];
} hash; } hash;
uint32_t n = pdata[19] - 1; // Start Nonce uint32_t n = pdata[19] - 1;
const uint32_t Htarg = ptarget[7]; // Zielwert (kleiner ist besser) const uint32_t Htarg = ptarget[7];
int i; int i;
// Debug-Ausgabe: Parameter unsigned long hash_count = 0;
printf("Debug: Using Yespower parameters - N: %d, r: %d, pers: %s\n", params->N, params->r, params->pers);
// Blockdaten in Big-Endian formatieren // Kodierung der Daten in Big-Endian
for (i = 0; i < 20; i++) { for (i = 0; i < 20; i++)
be32enc(&data.u32[i], pdata[i]); be32enc(&data.u32[i], pdata[i]);
}
do { do {
be32enc(&data.u32[19], ++n); // Nonce inkrementieren be32enc(&data.u32[19], ++n);
if (yespower_tls(data.u8, 80, params, &hash.yb)) { if (yespower_tls(data.u8, 80, params, &hash.yb))
abort(); // Fehlerbehandlung abort();
hash_count++;
if (hash_count % 450 == 0) {
printf("Hash #%lu: %08x\n", hash_count, le32dec(&hash.u32[7]));
} }
// Debug-Ausgabe: Nonce und Hash
printf("Debug: Nonce: %u, Hash: %08x%08x%08x%08x%08x%08x%08x%08x\n",
n,
hash.u32[0], hash.u32[1], hash.u32[2], hash.u32[3],
hash.u32[4], hash.u32[5], hash.u32[6], hash.u32[7]);
// Überprüfung des Hash-Werts
if (le32dec(&hash.u32[7]) <= Htarg) { if (le32dec(&hash.u32[7]) <= Htarg) {
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++)
hash.u32[i] = le32dec(&hash.u32[i]); // Konvertiere zu Little-Endian hash.u32[i] = le32dec(&hash.u32[i]);
}
if (fulltest(hash.u32, ptarget)) { if (fulltest(hash.u32, ptarget)) {
// Debug-Ausgabe: Erfolg
printf("Debug: Valid block found! Nonce: %u\n", n);
*hashes_done = n - pdata[19] + 1; *hashes_done = n - pdata[19] + 1;
pdata[19] = n; pdata[19] = n;
return 1; // Gültiger Block gefunden return 1;
} }
} }
} while (n < max_nonce && !work_restart[thr_id].restart); } while (n < max_nonce && !work_restart[thr_id].restart);
// Debug-Ausgabe: Kein Block gefunden
printf("Debug: No valid block found. Last Nonce: %u\n", n);
*hashes_done = n - pdata[19] + 1; *hashes_done = n - pdata[19] + 1;
pdata[19] = n; pdata[19] = n;
return 0; // Kein gültiger Block gefunden return 0;
} }

View File

@@ -1125,10 +1125,10 @@ static void stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
diff_to_target(work->target, sctx->job.diff / 65536.0); diff_to_target(work->target, sctx->job.diff / 65536.0);
} }
void some_function() { //void some_function() {
int version = get_dynamic_block_version(); // int version = get_dynamic_block_version();
// Weiterer Code... // Weiterer Code...
} //}
static void *miner_thread(void *userdata) static void *miner_thread(void *userdata)
{ {
@@ -1307,9 +1307,9 @@ static void *miner_thread(void *userdata)
case ALGO_ARM_YESPOWER_1_0_1: case ALGO_ARM_YESPOWER_1_0_1:
rc = scanhash_arm_yespower( rc = scanhash_arm_yespower(
thr_id, work.data, work.target, max_nonce, &hashes_done, get_dynamic_block_version() thr_id, work.data, work.target, max_nonce, &hashes_done
); );
break; break;
default: default:
/* should never happen */ /* should never happen */

View File

@@ -177,7 +177,7 @@ extern int scanhash_mbc_yespower(int thr_id, uint32_t *pdata,
extern int scanhash_arm_yespower(int thr_id, uint32_t *pdata, extern int scanhash_arm_yespower(int thr_id, uint32_t *pdata,
const uint32_t *ptarget, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done, int nVersion); uint32_t max_nonce, unsigned long *hashes_done);
struct thr_info { struct thr_info {
int id; int id;

View File

@@ -17,6 +17,6 @@
#define BLOCK_VERSION BLOCK_VERSION_DEFAULT #define BLOCK_VERSION BLOCK_VERSION_DEFAULT
#endif #endif
int get_dynamic_block_version(); //int get_dynamic_block_version();
#endif // VERSION_H #endif // VERSION_H