diff --git a/.YespowerARM.c.swp b/.YespowerARM.c.swp new file mode 100644 index 0000000..4710d94 Binary files /dev/null and b/.YespowerARM.c.swp differ diff --git a/YespowerARM.c b/YespowerARM.c index a4e6711..9f26712 100644 --- a/YespowerARM.c +++ b/YespowerARM.c @@ -8,62 +8,63 @@ #include #include -int get_dynamic_block_version() { -#ifdef TARGET_RASPBERRY - #define BLOCK_VERSION BLOCK_VERSION_RASPBERRY -#elif defined(TARGET_NOARM) - #define BLOCK_VERSION BLOCK_VERSION_NOARM -#else - #define BLOCK_VERSION BLOCK_VERSION_DEFAULT -#endif -} +//#ifdef TARGET_RASPBERRY_PI +// #define BLOCK_VERSION BLOCK_VERSION_RASPBERRY +//#elif defined(TARGET_NOARM) +// #define BLOCK_VERSION BLOCK_VERSION_NOARM +//#else +// #define BLOCK_VERSION BLOCK_VERSION_DEFAULT +//#endif -/* Auswahl der Yespower-Parameter basierend auf nVersion */ +/* Auswahl der Yespower-Parameter basierend auf der Zielplattform */ const yespower_params_t *select_yespower_params(void) { - int nVersion = get_dynamic_block_version(); - - if ((nVersion & BLOCK_VERSION_RASPBERRY) == BLOCK_VERSION_RASPBERRY) { + #ifdef TARGET_RASPBERRY static const yespower_params_t params_raspberry = { .version = YESPOWER_1_0, - .N = 2048, + .N = 2048, // Angepasster Wert für bessere Performance .r = 8, .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 ¶ms_raspberry; - } else if ((nVersion & BLOCK_VERSION_NOARM) == BLOCK_VERSION_NOARM) { + + #elif defined(TARGET_NOARM) static const yespower_params_t params_noarm = { .version = YESPOWER_1_0, .N = 4096, .r = 16, .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 ¶ms_noarm; - } else { + + #else static const yespower_params_t params_default = { .version = YESPOWER_1_0, .N = 4096, .r = 16, - .pers = (const uint8_t *)"Fallback", - .perslen = 8 + .pers = (const uint8_t *)"Default", + .perslen = 7 // "Default" hat 7 Zeichen }; + printf("Default Parameters: N=%d, r=%d\n", params_default.N, params_default.r); return ¶ms_default; - } + #endif } /* Berechnung des Yespower-Hashes */ -int yespower_hash(const char *input, char *output, int32_t nVersion) { - const yespower_params_t *params = select_yespower_params_by_version(nVersion); +int yespower_hash(const char *input, char *output) { + const yespower_params_t *params = select_yespower_params(); return yespower_tls((const uint8_t *)input, 80, params, (yespower_binary_t *)output); } /* 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) { - const yespower_params_t *params = select_yespower_params_by_version(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(); // Dynamische Parameter-Auswahl union { - uint8_t u8[80]; // 80 Bytes Blockheader + uint8_t u8[80]; // 20 * 4 bytes uint32_t u32[20]; } data; @@ -72,50 +73,38 @@ int scanhash_arm_yespower(int thr_id, uint32_t *pdata, const uint32_t *ptarget, uint32_t u32[8]; } hash; - uint32_t n = pdata[19] - 1; // Start Nonce - const uint32_t Htarg = ptarget[7]; // Zielwert (kleiner ist besser) + uint32_t n = pdata[19] - 1; + const uint32_t Htarg = ptarget[7]; int i; - // Debug-Ausgabe: Parameter - printf("Debug: Using Yespower parameters - N: %d, r: %d, pers: %s\n", params->N, params->r, params->pers); + unsigned long hash_count = 0; - // Blockdaten in Big-Endian formatieren - for (i = 0; i < 20; 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); // Nonce inkrementieren + be32enc(&data.u32[19], ++n); - if (yespower_tls(data.u8, 80, params, &hash.yb)) { - abort(); // Fehlerbehandlung + if (yespower_tls(data.u8, 80, params, &hash.yb)) + 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) { - for (i = 0; i < 8; i++) { - hash.u32[i] = le32dec(&hash.u32[i]); // Konvertiere zu Little-Endian - } + for (i = 0; i < 8; i++) + hash.u32[i] = le32dec(&hash.u32[i]); if (fulltest(hash.u32, ptarget)) { - // Debug-Ausgabe: Erfolg - printf("Debug: Valid block found! Nonce: %u\n", n); *hashes_done = n - pdata[19] + 1; pdata[19] = n; - return 1; // Gültiger Block gefunden + return 1; } } } 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; pdata[19] = n; - return 0; // Kein gültiger Block gefunden -} \ No newline at end of file + return 0; +} diff --git a/cpu-miner.c b/cpu-miner.c index eaf92b8..69a4a2c 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -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); } -void some_function() { - int version = get_dynamic_block_version(); +//void some_function() { +// int version = get_dynamic_block_version(); // Weiterer Code... -} +//} static void *miner_thread(void *userdata) { @@ -1307,9 +1307,9 @@ static void *miner_thread(void *userdata) case ALGO_ARM_YESPOWER_1_0_1: 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: /* should never happen */ diff --git a/miner.h b/miner.h index 562fb11..98c1b08 100644 --- a/miner.h +++ b/miner.h @@ -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, 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 { int id; diff --git a/version.h b/version.h index bf0301c..ad87ea9 100644 --- a/version.h +++ b/version.h @@ -17,6 +17,6 @@ #define BLOCK_VERSION BLOCK_VERSION_DEFAULT #endif -int get_dynamic_block_version(); +//int get_dynamic_block_version(); #endif // VERSION_H