Browse Source

Fix difficulty recalculation when a prefix match is found.

Bump to version 0.8
master
samr7 14 years ago
parent
commit
f40a553fed
  1. 16
      vanitygen.c
  2. 1
      winglue.c

16
vanitygen.c

@ -40,7 +40,7 @@
#include "winglue.c" #include "winglue.c"
#endif #endif
const char *version = "0.6"; const char *version = "0.8";
const int debug = 0; const int debug = 0;
int verbose = 0; int verbose = 0;
@ -1063,6 +1063,7 @@ vg_prefix_t *
vg_prefix_add(avl_root_t *rootp, const char *pattern, BIGNUM *low, BIGNUM *high) vg_prefix_add(avl_root_t *rootp, const char *pattern, BIGNUM *low, BIGNUM *high)
{ {
vg_prefix_t *vp, *vp2; vg_prefix_t *vp, *vp2;
assert(BN_cmp(low, high) < 0);
vp = (vg_prefix_t *) malloc(sizeof(*vp)); vp = (vg_prefix_t *) malloc(sizeof(*vp));
if (vp) { if (vp) {
avl_item_init(&vp->vp_item); avl_item_init(&vp->vp_item);
@ -1259,7 +1260,7 @@ vg_prefix_context_next_difficulty(vg_prefix_context_t *vcpp,
{ {
char *dbuf; char *dbuf;
BN_set_word(bntmp, 0); BN_clear(bntmp);
BN_set_bit(bntmp, 192); BN_set_bit(bntmp, 192);
BN_div(bntmp2, NULL, bntmp, &vcpp->vcp_difficulty, bnctx); BN_div(bntmp2, NULL, bntmp, &vcpp->vcp_difficulty, bnctx);
@ -1425,7 +1426,6 @@ generate_address_prefix(vg_prefix_context_t *vcpp)
BN_CTX *bnctx; BN_CTX *bnctx;
BIGNUM bntarg; BIGNUM bntarg;
BIGNUM bnbase; BIGNUM bnbase;
BIGNUM bndifficulty;
BIGNUM bntmp, bntmp2; BIGNUM bntmp, bntmp2;
EC_KEY *pkey = NULL; EC_KEY *pkey = NULL;
@ -1440,7 +1440,6 @@ generate_address_prefix(vg_prefix_context_t *vcpp)
BN_init(&bntarg); BN_init(&bntarg);
BN_init(&bnbase); BN_init(&bnbase);
BN_init(&bndifficulty);
BN_init(&bntmp); BN_init(&bntmp);
BN_init(&bntmp2); BN_init(&bntmp2);
@ -1532,8 +1531,8 @@ generate_address_prefix(vg_prefix_context_t *vcpp)
/* Subtract the range from the difficulty */ /* Subtract the range from the difficulty */
vg_prefix_range_sum(vp, &bntarg, &bntmp, &bntmp2); vg_prefix_range_sum(vp, &bntarg, &bntmp, &bntmp2);
BN_sub(&bntmp, &bndifficulty, &bntarg); BN_sub(&bntmp, &vcpp->vcp_difficulty, &bntarg);
BN_copy(&bndifficulty, &bntmp2); BN_copy(&vcpp->vcp_difficulty, &bntmp);
vg_prefix_delete(&vcpp->vcp_avlroot, vp); vg_prefix_delete(&vcpp->vcp_avlroot, vp);
vcpp->vcp_npfx--; vcpp->vcp_npfx--;
@ -1558,7 +1557,6 @@ generate_address_prefix(vg_prefix_context_t *vcpp)
pthread_mutex_unlock(&vcpp->vcp_lock); pthread_mutex_unlock(&vcpp->vcp_lock);
BN_clear_free(&bntarg); BN_clear_free(&bntarg);
BN_clear_free(&bnbase); BN_clear_free(&bnbase);
BN_clear_free(&bndifficulty);
BN_clear_free(&bntmp); BN_clear_free(&bntmp);
BN_clear_free(&bntmp2); BN_clear_free(&bntmp2);
BN_CTX_free(bnctx); BN_CTX_free(bnctx);
@ -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) { while (--nthreads) {
if (pthread_create(&thread, NULL, func, arg)) if (pthread_create(&thread, NULL, func, arg))
return 0; return 0;

1
winglue.c

@ -42,7 +42,6 @@ count_processors(void)
if (i & 1) if (i & 1)
count++; count++;
} }
count++;
break; break;
default: default:
break; break;

Loading…
Cancel
Save