diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 6a24e13de..5f21629a4 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -484,7 +484,7 @@ struct iguana_info { char name[64],symbol[8],statusstr[512],scriptsfname[2][512]; struct iguana_peers peers; struct iguana_peer internaladdr; - uint32_t fastfind; FILE *fastfps[0x100]; uint8_t *fast[0x100]; long fastsizes[0x100]; + uint32_t fastfind; FILE *fastfps[0x100]; uint8_t *fast[0x100]; int32_t *fasttables[0x100]; long fastsizes[0x100]; uint64_t instance_nonce,myservices,totalsize,totalrecv,totalpackets,sleeptime; int64_t mining,totalfees,TMPallocated,MAXRECVCACHE,MAXMEM,PREFETCHLAG,estsize,activebundles; int32_t MAXPEERS,MAXPENDINGREQUESTS,MAXBUNDLES,MAXSTUCKTIME,active,closestbundle,numemitted,lastsweep,numemit,startutc,newramchain,numcached,cachefreed,helperdepth,startPEND,endPEND,enableCACHE,RELAYNODE,VALIDATENODE,origbalanceswritten,balanceswritten,RTheight,RTdatabad; diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 160df1bc0..3b80e0895 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -197,7 +197,7 @@ void iguana_volatilesalloc(struct iguana_info *coin,struct iguana_ramchain *ramc void iguana_volatilespurge(struct iguana_info *coin,struct iguana_ramchain *ramchain) { - if ( ramchain != 0 ) + if ( ramchain != 0 && (coin->current == 0 || coin->current->bundleheight != ramchain->height) ) { printf("volatilespurge.[%d]\n",ramchain->height/coin->chain->bundlesize); if ( ramchain->allocatedA2 != 0 && ramchain->A2 != 0 && ramchain->A2 != ramchain->debitsfileptr ) @@ -738,7 +738,8 @@ int32_t iguana_txidfastfind(struct iguana_info *coin,int32_t *heightp,bits256 tx { memcpy(&num,sorted,sizeof(num)); memcpy(&tablesize,&sorted[sizeof(num)],sizeof(tablesize)); - hashtable = (int32_t *)((long)sorted + (1 + num)*16); + if ( (hashtable= coin->fasttables[txid.bytes[31]]) == 0 ) + hashtable = (int32_t *)((long)sorted + (1 + num)*16); val = (txid.uints[4] % tablesize); for (j=0; jfastsizes[i] ) { hashtable = (int32_t *)((long)sorted + (1 + num)*16); + coin->fasttables[i] = calloc(tablesize,sizeof(*hashtable)); + memcpy(coin->fasttables[i],hashtable,tablesize * sizeof(*hashtable)); } else { @@ -886,6 +889,7 @@ uint32_t iguana_fastfindinit(struct iguana_info *coin) for (j=0; jfast[i],coin->fastsizes[i]); + free(coin->fasttables[i]); coin->fast[i] = 0; coin->fastsizes[i] = 0; } @@ -1005,16 +1009,16 @@ struct iguana_bundle *iguana_fastexternalspent(struct iguana_info *coin,bits256 { if ( ind < rdata->numexternaltxids ) { - char str[65]; //double duration,startmillis = OS_milliseconds(); + char str[65]; double duration,startmillis = OS_milliseconds(); X = (void *)(long)((long)rdata + rdata->Xoffset); *prevhashp = prev_hash = X[ind]; if ( (firstvout= iguana_txidfastfind(coin,&height,prev_hash,spent_hdrsi-1)) >= 0 ) { - /*duration = (OS_milliseconds() - startmillis); - if ( ((uint64_t)coin->txidfind_num % 100000) == 1 ) + duration = (OS_milliseconds() - startmillis); + if ( ((uint64_t)coin->txidfind_num % 100) == 1 ) printf("[%d] iguana_fasttxidfind.[%.0f] ave %.2f micros, total %.2f seconds | duration %.3f millis\n",spent_hdrsi,coin->txidfind_num,(coin->txidfind_totalmillis*1000.)/coin->txidfind_num,coin->txidfind_totalmillis/1000.,duration); coin->txidfind_totalmillis += duration; - coin->txidfind_num += 1.;*/ + coin->txidfind_num += 1.; *unspentindp = firstvout + prev_vout; hdrsi = height / coin->chain->bundlesize;