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
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user