Fixed duplicate output issue in main function
This commit is contained in:
BIN
event_miner
BIN
event_miner
Binary file not shown.
@@ -589,7 +589,7 @@ static int mine_event(mining_context_t* ctx) {
|
|||||||
|
|
||||||
// Handle results - OUTPUT IMMEDIATELY when solution is found
|
// Handle results - OUTPUT IMMEDIATELY when solution is found
|
||||||
if (main_ctx.solution_found && main_ctx.result_event) {
|
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;
|
ctx->result_event = main_ctx.result_event;
|
||||||
result = 1; // Success
|
result = 1; // Success
|
||||||
|
|
||||||
@@ -753,20 +753,14 @@ int main(int argc, char* argv[]) {
|
|||||||
// Start mining
|
// Start mining
|
||||||
int mining_result = mine_event(&ctx);
|
int mining_result = mine_event(&ctx);
|
||||||
|
|
||||||
if (mining_result == 1 && ctx.result_event) {
|
if (mining_result == 1) {
|
||||||
// Success - output mined event
|
// Success - result already output by mine_event()
|
||||||
char* output_json = cJSON_Print(ctx.result_event);
|
exit_code = 0;
|
||||||
if (output_json) {
|
|
||||||
printf("%s\n", output_json);
|
|
||||||
free(output_json);
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, "Error: Failed to serialize result event\n");
|
|
||||||
exit_code = 1;
|
|
||||||
}
|
|
||||||
} else if (mining_result == -1) {
|
} else if (mining_result == -1) {
|
||||||
printf("timeout\n");
|
// Timeout - timeout message already output by mine_event()
|
||||||
exit_code = 1;
|
exit_code = 1;
|
||||||
} else {
|
} else {
|
||||||
|
// Error
|
||||||
fprintf(stderr, "Error: Mining failed\n");
|
fprintf(stderr, "Error: Mining failed\n");
|
||||||
exit_code = 1;
|
exit_code = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user