From 14d995d1baeaab5ea2008c6aa1af99683a164ca5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 23 Mar 2016 21:10:36 -0300 Subject: [PATCH] test --- iguana/iguana777.c | 10 +++++----- iguana/iguana_unspents.c | 35 +++++++++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index a7a3c0d4a..53868133f 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -533,19 +533,19 @@ struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers, sprintf(dirname,"%s/%s",GLOBALTMPDIR,symbol), OS_ensure_directory(dirname); coin->initialheight = initialheight; coin->mapflags = mapflags; - mult = (strcmp("BTC",coin->symbol) != 0) ? 64 : 1; + mult = (strcmp("BTC",coin->symbol) != 0) ? 512 : 1; maxval = (strcmp("BTC",coin->symbol) != 0) ? 2048 : 64; if ( (coin->startPEND= juint(json,"startpend")) == 0 ) coin->startPEND = IGUANA_MAXPENDBUNDLES * mult; - if ( coin->startPEND > 1024 ) - coin->startPEND = 1024; + if ( coin->startPEND > 2048 ) + coin->startPEND = 2048; else if ( coin->startPEND < 2 ) coin->startPEND = 2; coin->MAXBUNDLES = coin->startPEND; if ( (coin->endPEND= juint(json,"endpend")) == 0 ) coin->endPEND = IGUANA_MINPENDBUNDLES * mult; - if ( coin->endPEND > 1024 ) - coin->endPEND = 1024; + if ( coin->endPEND > 2048 ) + coin->endPEND = 2048; else if ( coin->endPEND < 2 ) coin->endPEND = 2; coin->enableCACHE = (strcmp("BTC",coin->symbol) != 0); diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index fa37aab50..4e6f88ba2 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -16,13 +16,35 @@ #include "iguana777.h" #include "exchanges/bitcoin.h" -int32_t iguana_utxoupdate(struct iguana_info *coin,uint16_t spent_hdris,uint32_t spent_unspentind,uint32_t spent_pkind,uint64_t spent_value,int32_t hdrsi,uint32_t spendind,uint32_t height) +int32_t iguana_utxoupdate(struct iguana_info *coin,uint16_t spent_hdrsi,uint32_t spent_unspentind,uint32_t spent_pkind,uint64_t spent_value,int32_t hdrsi,uint32_t spendind,uint32_t height) { - struct iguana_hhutxo *hhutxo; struct iguana_hhaccount *hhacct; - uint8_t buf[sizeof(spent_hdris) + sizeof(uint32_t)]; + struct iguana_hhutxo *hhutxo,*tmputxo; struct iguana_hhaccount *hhacct,*tmpacct; + uint8_t buf[sizeof(spent_hdrsi) + sizeof(uint32_t)]; printf("unexpected utxoupdate\n"); exit(-1); - memcpy(&buf[sizeof(uint32_t)],(void *)&spent_hdris,sizeof(spent_hdris)); + if ( spent_hdrsi < 0 ) + { + if ( coin->utxotable != 0 ) + { + HASH_ITER(hh,coin->utxotable,hhutxo,tmputxo) + { + HASH_DEL(coin->utxotable,hhutxo); + free(hhutxo); + } + coin->utxotable = 0; + } + if ( coin->accountstable != 0 ) + { + HASH_ITER(hh,coin->accountstable,hhacct,tmpacct) + { + HASH_DEL(coin->accountstable,hhacct); + free(hhacct); + } + coin->accountstable = 0; + } + return(0); + } + memcpy(&buf[sizeof(uint32_t)],(void *)&spent_hdrsi,sizeof(spent_hdrsi)); memcpy(buf,(void *)&spent_unspentind,sizeof(spent_unspentind)); HASH_FIND(hh,coin->utxotable,buf,sizeof(buf),hhutxo); if ( hhutxo != 0 && hhutxo->u.spentflag != 0 ) @@ -310,7 +332,7 @@ int32_t iguana_utxogen(struct iguana_info *coin,struct iguana_bundle *bp) { if ( (spentbp= iguana_spent(coin,&prevhash,&unspentind,ramchain,bp->hdrsi,s)) != 0 ) { - if ( now > spentbp->lastprefetch+30 )//|| (spentbp->dirty % 100000) == 0 ) + if ( now > spentbp->lastprefetch+600 || (spentbp->dirty % 100000) == 0 ) { //printf("u current.%d prefetch.[%d] lag.%u\n",spentbp == bp,spentbp->hdrsi,now - spentbp->lastprefetch); iguana_ramchain_prefetch(coin,&spentbp->ramchain); @@ -466,7 +488,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,struct iguana_bundle *bp,int3 now = (uint32_t)time(NULL); if ( spentbp != 0 && unspentind > 0 && unspentind < spentbp->ramchain.H.data->numunspents ) { - if ( now > spentbp->lastprefetch+30 )//|| (spentbp->dirty % 100000) == 0 ) + if ( now > spentbp->lastprefetch+600 || (spentbp->dirty % 100000) == 0 ) { //printf("current.%d prefetch.[%d] lag.%u\n",spentbp == bp,spentbp->hdrsi,now - spentbp->lastprefetch); iguana_ramchain_prefetch(coin,&spentbp->ramchain); @@ -743,6 +765,7 @@ int32_t iguana_balanceflush(struct iguana_info *coin,int32_t refhdrsi,int32_t pu } coin->balancehash = balancehash; coin->balanceswritten = numhdrsi; + iguana_utxoupdate(coin,-1,0,0,0,-1,0,-1); // free hashtables for (hdrsi=0; hdrsibundles[hdrsi]) == 0 || iguana_mapvolatiles(coin,&bp->ramchain) != 0 ) printf("error mapping bundle.[%d]\n",hdrsi);