Fixed duplicate output issue in main function

This commit is contained in:
Your Name
2025-08-17 12:40:14 -04:00
parent 5047023489
commit d556523fa5
3 changed files with 7 additions and 13 deletions

View File

@@ -1 +1 @@
0.1.33
0.1.34

Binary file not shown.

View File

@@ -589,7 +589,7 @@ static int mine_event(mining_context_t* ctx) {
// Handle results - OUTPUT IMMEDIATELY when solution is found
if (main_ctx.solution_found && main_ctx.result_event) {
// Transfer ownership and output result immediately
// Transfer ownership for cleanup
ctx->result_event = main_ctx.result_event;
result = 1; // Success
@@ -753,20 +753,14 @@ int main(int argc, char* argv[]) {
// Start mining
int mining_result = mine_event(&ctx);
if (mining_result == 1 && ctx.result_event) {
// Success - output mined event
char* output_json = cJSON_Print(ctx.result_event);
if (output_json) {
printf("%s\n", output_json);
free(output_json);
} else {
fprintf(stderr, "Error: Failed to serialize result event\n");
exit_code = 1;
}
if (mining_result == 1) {
// Success - result already output by mine_event()
exit_code = 0;
} else if (mining_result == -1) {
printf("timeout\n");
// Timeout - timeout message already output by mine_event()
exit_code = 1;
} else {
// Error
fprintf(stderr, "Error: Mining failed\n");
exit_code = 1;
}