Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to stop mining after finding X blocks #192

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ksynb
Copy link

@ksynb ksynb commented May 9, 2020

This can come in handy for testing when needing to only mine a certain amount of blocks without babysitting the console

@@ -1717,6 1726,12 @@ static void parse_arg(int key, char *arg, char *pname)
free(opt_proxy);
opt_proxy = strdup(arg);
break;
case 'X':
v = atoi(arg);
if (v < -1) /* sanity check */

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

atoi returns 0 on failure. You may want to detect that case here.

@@ -682,6 686,11 @@ static void share_result(int result, const char *reason)
s,
result ? "(yay!!!)" : "(booooo)");

if (accepted_count >= opt_max_blocks) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This relies on subtleties of comparing signed and unsigned in C. You may want to make this code more explicit by doing e.g.:

    if (opt_max_blocks > 0 && accepted_count >= opt_max_blocks)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants