Implement progress and error callback reporting every 9999 attempts
This commit is contained in:
BIN
event_miner
BIN
event_miner
Binary file not shown.
@@ -263,19 +263,33 @@ static void solution_found_callback(cJSON* solution, void* user_data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void progress_report_callback(int thread_id, uint64_t attempts, void* user_data) {
|
static void progress_report_callback(int thread_id, uint64_t attempts, void* user_data) {
|
||||||
// Progress callback - placeholder for future implementation
|
main_context_t* main_ctx = (main_context_t*)user_data;
|
||||||
// For now, do nothing as requested
|
|
||||||
(void)thread_id; // Suppress unused parameter warning
|
// Only report if solution not yet found
|
||||||
(void)attempts; // Suppress unused parameter warning
|
if (!main_ctx->solution_found && !main_ctx->timeout_reached) {
|
||||||
(void)user_data; // Suppress unused parameter warning
|
printf("[Thread %d] Progress: %llu attempts completed\n",
|
||||||
|
thread_id, (unsigned long long)attempts);
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void error_report_callback(int thread_id, int error_code, void* user_data) {
|
static void error_report_callback(int thread_id, int error_code, void* user_data) {
|
||||||
// Error callback for debugging - placeholder for future implementation
|
const char* error_msg;
|
||||||
// For now, do nothing but could be used for debugging thread issues
|
|
||||||
(void)thread_id; // Suppress unused parameter warning
|
switch (error_code) {
|
||||||
(void)error_code; // Suppress unused parameter warning
|
case -1:
|
||||||
(void)user_data; // Suppress unused parameter warning
|
error_msg = "JSON serialization failed";
|
||||||
|
break;
|
||||||
|
case -2:
|
||||||
|
error_msg = "Event parsing failed";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
error_msg = "Unknown error";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "[Thread %d] Error %d: %s\n", thread_id, error_code, error_msg);
|
||||||
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verbose PoW callback - receives progress from nostr_add_proof_of_work
|
// Verbose PoW callback - receives progress from nostr_add_proof_of_work
|
||||||
@@ -350,7 +364,7 @@ static void* miner_thread(void* arg) {
|
|||||||
|
|
||||||
int result = nostr_add_proof_of_work(local_event, ctx->private_key,
|
int result = nostr_add_proof_of_work(local_event, ctx->private_key,
|
||||||
ctx->target_difficulty, 1000000, // max_attempts
|
ctx->target_difficulty, 1000000, // max_attempts
|
||||||
1000, // progress_report_interval
|
10000, // progress_report_interval
|
||||||
30, // timestamp_update_interval (seconds)
|
30, // timestamp_update_interval (seconds)
|
||||||
progress_cb, ctx);
|
progress_cb, ctx);
|
||||||
|
|
||||||
@@ -364,8 +378,8 @@ static void* miner_thread(void* arg) {
|
|||||||
break; // Exit after reporting solution
|
break; // Exit after reporting solution
|
||||||
}
|
}
|
||||||
|
|
||||||
// Progress reporting (currently disabled but ready for future use)
|
// Progress reporting every 9999 attempts
|
||||||
if (ctx->progress_callback && attempts % 10000 == 0) {
|
if (ctx->progress_callback && attempts % 9999 == 0) {
|
||||||
ctx->progress_callback(ctx->thread_id, attempts, ctx->user_data);
|
ctx->progress_callback(ctx->thread_id, attempts, ctx->user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user