Browse Source

Fix arithmetic problems related to difficulty estimation of multiple

prefixes.
Be more specific when prefixes overlap.
Bump to version 0.6.
master
samr7 14 years ago
parent
commit
03f4e05ebf
  1. 5
      CHANGELOG
  2. 23
      vanitygen.c

5
CHANGELOG

@ -23,3 +23,8 @@ Version 0.5, released July 7 2011:
- Exact prefixes can now be matched case-insensitively with - Exact prefixes can now be matched case-insensitively with
"-i", for SgtSpike "-i", for SgtSpike
- Fixed an integer overflow problem with the status display - Fixed an integer overflow problem with the status display
Version 0.6, released July 8 2011:
- Fix calculation of difficulty for multiple prefixes
- When prefixes overlap, output the discarded prefix as
well as the existing prefix with which it overlaps

23
vanitygen.c

@ -40,7 +40,7 @@
#include "winglue.c" #include "winglue.c"
#endif #endif
const char *version = "0.5"; const char *version = "0.6";
const int debug = 0; const int debug = 0;
int verbose = 0; int verbose = 0;
@ -1062,7 +1062,7 @@ vg_prefix_avl_insert(avl_root_t *rootp, vg_prefix_t *vpnew)
vg_prefix_t * 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; vg_prefix_t *vp, *vp2;
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);
@ -1070,7 +1070,10 @@ vg_prefix_add(avl_root_t *rootp, const char *pattern, BIGNUM *low, BIGNUM *high)
vp->vp_pattern = pattern; vp->vp_pattern = pattern;
vp->vp_low = low; vp->vp_low = low;
vp->vp_high = high; vp->vp_high = high;
if (vg_prefix_avl_insert(rootp, vp) != NULL) { vp2 = vg_prefix_avl_insert(rootp, vp);
if (vp2 != NULL) {
printf("Prefix '%s' ignored, overlaps '%s'\n",
pattern, vp2->vp_pattern);
vg_prefix_free(vp); vg_prefix_free(vp);
vp = NULL; vp = NULL;
} }
@ -1140,6 +1143,7 @@ vg_prefix_range_sum(vg_prefix_t *vp, BIGNUM *result, BIGNUM *tmp1, BIGNUM *tmp2)
BIGNUM *bnptr = result; BIGNUM *bnptr = result;
startp = vp; startp = vp;
BN_clear(result);
do { do {
BN_sub(tmp1, vp->vp_high, vp->vp_low); BN_sub(tmp1, vp->vp_high, vp->vp_low);
if (bnptr == result) { if (bnptr == result) {
@ -1314,10 +1318,6 @@ vg_prefix_context_add_patterns(vg_prefix_context_t *vcpp,
vp = vg_prefix_add_ranges(&vcpp->vcp_avlroot, vp = vg_prefix_add_ranges(&vcpp->vcp_avlroot,
patterns[i], patterns[i],
ranges, NULL); ranges, NULL);
if (!vp)
printf("Could not add prefix '%s': "
"overlapping?\n",
patterns[i]);
} }
} else { } else {
@ -1348,9 +1348,6 @@ vg_prefix_context_add_patterns(vg_prefix_context_t *vcpp,
ranges, ranges,
vp); vp);
if (!vp2) { if (!vp2) {
printf("Could not add prefix '%s': "
"overlapping?\n",
patterns[i]);
fail = 1; fail = 1;
break; break;
} }
@ -1376,9 +1373,9 @@ vg_prefix_context_add_patterns(vg_prefix_context_t *vcpp,
BN_copy(&vcpp->vcp_difficulty, &bntmp2); BN_copy(&vcpp->vcp_difficulty, &bntmp2);
if (verbose) { if (verbose) {
BN_set_word(&bntmp, 0); BN_clear(&bntmp2);
BN_set_bit(&bntmp, 192); BN_set_bit(&bntmp2, 192);
BN_div(&bntmp3, NULL, &bntmp, &bntmp2, bnctx); BN_div(&bntmp3, NULL, &bntmp2, &bntmp, bnctx);
dbuf = BN_bn2dec(&bntmp3); dbuf = BN_bn2dec(&bntmp3);
printf("Prefix difficulty: %20s %s\n", printf("Prefix difficulty: %20s %s\n",

Loading…
Cancel
Save