diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 2a78c1e42..4276af618 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -437,7 +437,7 @@ void iguana_update_balances(struct iguana_info *coin) //iguana_ramchain_prefetch(coin,&bp->ramchain,3); if ( iguana_balancegen(coin,0,bp,0,bp->bundleheight + coin->chain->bundlesize-1,0) == 0 ) bp->balancefinish = (uint32_t)time(NULL); - } + } else printf("null bp.[%d]\n",hdrsi); } if ( max != coin->origbalanceswritten ) { diff --git a/iguana/iguana_accept.c b/iguana/iguana_accept.c index 7bbd4c0d6..c595522d6 100755 --- a/iguana/iguana_accept.c +++ b/iguana/iguana_accept.c @@ -326,7 +326,7 @@ int32_t iguana_peerhdrrequest(struct supernet_info *myinfo,struct iguana_info *c } else printf("cant find block at ht.%d\n",height+i); } } - if ( flag != 0 ) + if ( flag != 0 && strcmp("BTCD",coin->symbol) != 0 ) retval = iguana_queue_send(addr,0,serialized,"headers",len); //printf("hdrs request retval.%d len.%d\n",retval,len); } //else printf("couldnt find header\n"); diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 90c0557df..9d77cf614 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -648,7 +648,7 @@ void _iguana_processmsg(struct iguana_info *coin,int32_t usock,struct iguana_pee { int32_t i; for (i=0; iipaddr,len); + printf(" %s invalid header.%s received from (%s) len.%d\n",coin->symbol,H.command,addr->ipaddr,len); } //addr->dead = 1; } diff --git a/iguana/iguana_spendvectors.c b/iguana/iguana_spendvectors.c index 074ddc68f..67860cf7e 100755 --- a/iguana/iguana_spendvectors.c +++ b/iguana/iguana_spendvectors.c @@ -449,7 +449,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct ig struct iguana_spendvector *spend; struct iguana_unspent *spentU,*u; struct iguana_spendvector *Xspendinds; struct iguana_txid *T; struct iguana_blockRO *B; struct iguana_bundle *spentbp; int32_t spent_hdrsi,spendind,n,numXspends,errs=0,emit=0; struct iguana_spend *S,*s; - if ( starti != 0 || endheight != coin->chain->bundlesize-1 ) + if ( (starti % coin->chain->bundlesize) != 0 || (endheight % coin->chain->bundlesize) != coin->chain->bundlesize-1 ) ramchain = &coin->RTramchain; else ramchain = &bp->ramchain; if ( (rdata= ramchain->H.data) == 0 || (n= rdata->numspends) < 1 ) @@ -471,7 +471,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct ig txidind = B[starti].firsttxidind; spendind = B[starti].firstvin; emit = startemit; - if ( 0 && (coin->RTheight == 0 || bp->bundleheight+bp->n < coin->RTheight) ) + //if ( 0 && (coin->RTheight == 0 || bp->bundleheight+bp->n < coin->RTheight) ) fprintf(stderr,"BALANCEGEN.[%d] %p[%d] starti.%d s%d <-> endi.%d s%d startemit.%d\n",bp->hdrsi,Xspendinds,numXspends,starti,spendind,endi,B[endi].firstvin+B[endi].numvins,startemit); for (i=starti; i<=endi; i++) { @@ -540,7 +540,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct ig { if ( 0 && bp == coin->current ) printf("[%d] spendind.%u -> [%d] u%d\n",bp->hdrsi,spendind,spent_hdrsi,spent_unspentind); - if ( iguana_volatileupdate(coin,incremental,(spentbp == coin->current) ? &coin->RTramchain : &spentbp->ramchain,spent_hdrsi,spent_unspentind,spent_pkind,spent_value,spendind,h) < 0 ) + if ( iguana_volatileupdate(coin,incremental,&spentbp->ramchain,spent_hdrsi,spent_unspentind,spent_pkind,spent_value,spendind,h) < 0 ) //(spentbp == coin->current) ? &coin->RTramchain : errs++; } else //if ( Xspendinds != 0 ) diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 6c1f475fb..fa7cd0b78 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -877,7 +877,9 @@ int64_t iguana_bundle_unspents(struct iguana_info *coin,struct iguana_bundle *bp P = RAMCHAIN_PTR(rdata,Poffset); for (unspentind=1; unspentindnumunspents; unspentind++) { - if ( U2[unspentind].spentflag == 0 && (value= U[unspentind].value) != 0 ) + value = U[unspentind].value; + //printf("[%d] u%d: (p%u %.8f) from.%d lock.%d prev.%u spent.%d\n",bp->hdrsi,unspentind,U[unspentind].pkind,dstr(value),U2[unspentind].fromheight,U2[unspentind].lockedflag,U2[unspentind].prevunspentind,U2[unspentind].spentflag); + if ( U2[unspentind].fromheight == 0 && U2[unspentind].lockedflag == 0 && U2[unspentind].prevunspentind == 0 && U2[unspentind].spentflag == 0 && value != 0 ) { if ( value < 0 ) printf("[%d] u%u negative value %.8f??\n",bp->hdrsi,unspentind,dstr(value)); @@ -894,7 +896,7 @@ int64_t iguana_bundle_unspents(struct iguana_info *coin,struct iguana_bundle *bp } else printf("illegal pkind.%u for unspentind.%u hdrsi.%d\n",pkind,unspentind,bp->hdrsi); } } - } + } // else printf("[%d] u%u spent %.8f\n",bp->hdrsi,unspentind,dstr(value)); } return(balance); } @@ -914,9 +916,13 @@ int64_t iguana_utxoaddr_gen(struct iguana_info *coin,int32_t maketable) } coin->utxoaddrs = 0; } - for (hdrsi=0; hdrsibundlescount; hdrsi++) + for (hdrsi=0; hdrsibundlescount-1; hdrsi++) if ( (bp= coin->bundles[hdrsi]) != 0 && (rdata= bp->ramchain.H.data) != 0 ) + { + iguana_volatilespurge(coin,&bp->ramchain); + iguana_volatilesmap(coin,&bp->ramchain); tablesize += rdata->numpkinds; + } printf("allocate UTXOADDRS[%d]\n",tablesize); coin->utxodatasize = tablesize; coin->utxoaddrind = 0; diff --git a/iguana/iguana_volatiles.c b/iguana/iguana_volatiles.c index f62578f05..1cf1d6210 100755 --- a/iguana/iguana_volatiles.c +++ b/iguana/iguana_volatiles.c @@ -184,7 +184,7 @@ int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struc if ( incremental == 0 ) { if ( spentchain->Uextras == 0 || spentchain->A2 == 0 ) - iguana_volatilesmap(coin,spentchain); + iguana_volatilesalloc(coin,spentchain,1); if ( spentchain->Uextras != 0 && (A2= spentchain->A2) != 0 ) { utxo = &spentchain->Uextras[spent_unspentind]; @@ -219,7 +219,7 @@ int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struc } } portable_mutex_unlock(&coin->RTmutex); - printf("iguana_volatileupdate.%d: [%d] spent.(u%u %.8f pkind.%d) double spend? at ht.%d [%d] spendind.%d (%p %p)\n",incremental,spent_hdrsi,spent_unspentind,dstr(spent_value),spent_pkind,fromheight,fromheight/coin->chain->bundlesize,spendind,spentchain->Uextras,spentchain->A2); + printf("end iguana_volatileupdate.%d: [%d] spent.(u%u %.8f pkind.%d) double spend? at ht.%d [%d] spendind.%d (%p %p)\n",incremental,spent_hdrsi,spent_unspentind,dstr(spent_value),spent_pkind,fromheight,fromheight/coin->chain->bundlesize,spendind,spentchain->Uextras,spentchain->A2); /*if ( coin->current != 0 && fromheight >= coin->current->bundleheight ) coin->RTdatabad = 1; else @@ -339,7 +339,10 @@ int32_t iguana_volatilesmap(struct iguana_info *coin,struct iguana_ramchain *ram return(-1); } if ( ramchain->debitsfileptr != 0 && ramchain->lastspendsfileptr != 0 ) + { + //printf("volatilesmap.[%d] already mapped %p %p\n",ramchain->height,ramchain->debitsfileptr,ramchain->lastspendsfileptr); return(0); + } for (iter=0; iter<2; iter++) { sprintf(fname,"%s/%s%s/accounts/debits.%d",GLOBAL_DBDIR,iter==0?"ro/":"",coin->symbol,ramchain->height); @@ -368,7 +371,19 @@ int32_t iguana_volatilesmap(struct iguana_info *coin,struct iguana_ramchain *ram { ramchain->Uextras = (void *)((long)ramchain->lastspendsfileptr + sizeof(numhdrsi) + 2*sizeof(bits256)); ramchain->from_roU = (iter == 0); - //printf("volatilesmap.[%d] %p %p\n",ramchain->height/coin->chain->bundlesize,ramchain->debitsfileptr,ramchain->lastspendsfileptr); + uint32_t unspentind,nonz=0; struct iguana_unspent *U; struct iguana_utxo *U2; + if ( 1 ) + { + U2 = ramchain->Uextras; + U = RAMCHAIN_PTR(ramchain->H.data,Uoffset); + for (unspentind=1; unspentindH.data->numunspents; unspentind++) + { + if ( U2[unspentind].spentflag != 0 ) + nonz++; + //printf("[%d] u%d: (p%u %.8f) from.%d lock.%d prev.%u spent.%d\n",ramchain->height/coin->chain->bundlesize,unspentind,U[unspentind].pkind,dstr(U[unspentind].value),U2[unspentind].fromheight,U2[unspentind].lockedflag,U2[unspentind].prevunspentind,U2[unspentind].spentflag); + } + } + printf("nonz.%d %s volatilesmap.[%d] %p %p\n",nonz,fname,ramchain->height/coin->chain->bundlesize,ramchain->debitsfileptr,ramchain->lastspendsfileptr); err = 0; } else printf("ramchain map error2 balanceswritten %d vs %d hashes %x %x\n",coin->balanceswritten,numhdrsi,coin->balancehash.uints[0],balancehash.uints[0]); } else printf("ramchain map error3 %s\n",fname);