Skip to content

Commit

Permalink
Fix difficulty recalculation when a prefix match is found.
Browse files Browse the repository at this point in the history
Bump to version 0.8
  • Loading branch information
samr7 committed Jul 9, 2011
1 parent d40577e commit f40a553
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
16 changes: 9 additions & 7 deletions vanitygen.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include "winglue.c"
#endif

const char *version = "0.6";
const char *version = "0.8";
const int debug = 0;
int verbose = 0;

Expand Down Expand Up @@ -1063,6 +1063,7 @@ vg_prefix_t *
vg_prefix_add(avl_root_t *rootp, const char *pattern, BIGNUM *low, BIGNUM *high)
{
vg_prefix_t *vp, *vp2;
assert(BN_cmp(low, high) < 0);
vp = (vg_prefix_t *) malloc(sizeof(*vp));
if (vp) {
avl_item_init(&vp->vp_item);
Expand Down Expand Up @@ -1259,7 +1260,7 @@ vg_prefix_context_next_difficulty(vg_prefix_context_t *vcpp,
{
char *dbuf;

BN_set_word(bntmp, 0);
BN_clear(bntmp);
BN_set_bit(bntmp, 192);
BN_div(bntmp2, NULL, bntmp, &vcpp->vcp_difficulty, bnctx);

Expand Down Expand Up @@ -1425,7 +1426,6 @@ generate_address_prefix(vg_prefix_context_t *vcpp)
BN_CTX *bnctx;
BIGNUM bntarg;
BIGNUM bnbase;
BIGNUM bndifficulty;
BIGNUM bntmp, bntmp2;

EC_KEY *pkey = NULL;
Expand All @@ -1440,7 +1440,6 @@ generate_address_prefix(vg_prefix_context_t *vcpp)

BN_init(&bntarg);
BN_init(&bnbase);
BN_init(&bndifficulty);
BN_init(&bntmp);
BN_init(&bntmp2);

Expand Down Expand Up @@ -1532,8 +1531,8 @@ generate_address_prefix(vg_prefix_context_t *vcpp)

/* Subtract the range from the difficulty */
vg_prefix_range_sum(vp, &bntarg, &bntmp, &bntmp2);
BN_sub(&bntmp, &bndifficulty, &bntarg);
BN_copy(&bndifficulty, &bntmp2);
BN_sub(&bntmp, &vcpp->vcp_difficulty, &bntarg);
BN_copy(&vcpp->vcp_difficulty, &bntmp);

vg_prefix_delete(&vcpp->vcp_avlroot, vp);
vcpp->vcp_npfx--;
Expand All @@ -1558,7 +1557,6 @@ generate_address_prefix(vg_prefix_context_t *vcpp)
pthread_mutex_unlock(&vcpp->vcp_lock);
BN_clear_free(&bntarg);
BN_clear_free(&bnbase);
BN_clear_free(&bndifficulty);
BN_clear_free(&bntmp);
BN_clear_free(&bntmp2);
BN_CTX_free(bnctx);
Expand Down Expand Up @@ -2004,6 +2002,10 @@ start_threads(void *(*func)(void *), void *arg, int nthreads)
}
}

if (verbose) {
printf("Using %d worker thread(s)\n", nthreads);
}

while (--nthreads) {
if (pthread_create(&thread, NULL, func, arg))
return 0;
Expand Down
1 change: 0 additions & 1 deletion winglue.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ count_processors(void)
if (i & 1)
count++;
}
count++;
break;
default:
break;
Expand Down

0 comments on commit f40a553

Please sign in to comment.