From c29dcc1c04a9837ef77f5c872479a422f2d34135 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 22 Aug 2016 01:14:56 -0300 Subject: [PATCH] test --- iguana/iguana_blocks.c | 2 -- iguana/iguana_realtime.c | 12 ++++++++++- iguana/iguana_unspents.c | 43 ++++++++++++++-------------------------- 3 files changed, 26 insertions(+), 31 deletions(-) diff --git a/iguana/iguana_blocks.c b/iguana/iguana_blocks.c index 09e892b98..0a354f216 100755 --- a/iguana/iguana_blocks.c +++ b/iguana/iguana_blocks.c @@ -677,9 +677,7 @@ struct iguana_block *_iguana_chainlink(struct supernet_info *myinfo,struct iguan process_iguanablock(block->serdata,CHAINPARMS); }*/ iguana_blockzcopy(coin->chain->zcash,(void *)&coin->blocks.hwmchain,block); - portable_mutex_lock(&coin->RTmutex); iguana_RTnewblock(myinfo,coin,block); - portable_mutex_unlock(&coin->RTmutex); return(block); } } diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index e059b343d..a19a8b573 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -986,8 +986,9 @@ void iguana_RTnewblock(struct supernet_info *myinfo,struct iguana_info *coin,str printf("iguana_RTnewblock illegal blockheight.%d\n",block->height); return; } - if ( coin->RTheight > 0 ) + if ( block != 0 && coin->RTheight > 0 && coin->RTheight <= coin->blocks.hwmchain.height ) { + portable_mutex_lock(&coin->RTmutex); if ( block->height > coin->lastRTheight ) { n = (block->height - coin->RTheight) + 1; @@ -1016,7 +1017,10 @@ void iguana_RTnewblock(struct supernet_info *myinfo,struct iguana_info *coin,str if ( (subblock= iguana_RTblock(coin,block->height)) != 0 && subblock != block ) { if ( iguana_RTblocksub(myinfo,coin,subblock) < 0 || iguana_RTblockadd(myinfo,coin,block) < 0 ) + { + portable_mutex_unlock(&coin->RTmutex); return; + } printf("%s == RTnewblock RTheight %d prev %d\n",coin->symbol,coin->RTheight,coin->lastRTheight); } } @@ -1035,16 +1039,22 @@ void iguana_RTnewblock(struct supernet_info *myinfo,struct iguana_info *coin,str if ( iguana_RTblocksub(myinfo,coin,iguana_RTblock(coin,coin->lastRTheight--)) < 0 ) { coin->RTheight = coin->lastRTheight+1; + portable_mutex_unlock(&coin->RTmutex); return; } } coin->RTheight = coin->lastRTheight+1; if ( iguana_RTblockadd(myinfo,coin,block) < 0 ) + { + portable_mutex_unlock(&coin->RTmutex); return; + } coin->lastRTheight = block->height; coin->RTheight = coin->lastRTheight+1; } } + portable_mutex_unlock(&coin->RTmutex); + //block = iguana_blockfind("next",coin,iguana_blockhash(coin,block->height+1)); } } diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index e8a9c81de..9fc501d4b 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -1245,9 +1245,21 @@ int32_t iguana_utxoaddr_validate(struct supernet_info *myinfo,struct iguana_info return(errs); } +int64_t iguana_RTstart(struct supernet_info *myinfo,struct iguana_info *coin,int32_t height) +{ + struct iguana_block *block; + coin->firstRTheight = coin->RTheight = height; + iguana_RTreset(coin); + iguana_RTpurge(coin,coin->firstRTheight); + if ( (block= iguana_blockfind("utxogen",coin,coin->blocks.hwmchain.RO.hash2)) != 0 ) + iguana_RTnewblock(myinfo,coin,block); + basilisk_unspents_update(myinfo,coin); + return(coin->histbalance); +} + int64_t iguana_utxoaddr_gen(struct supernet_info *myinfo,struct iguana_info *coin,int32_t maxheight) { - char fname[1024],fname2[1024],coinaddr[64],str[65],checkaddr[64]; struct iguana_utxoaddr *utxoaddr,UA,*tmp,*last=0; uint16_t hdrsi; uint8_t *table,item[UTXOADDR_ITEMSIZE]; uint32_t *counts,*offsets,offset,n; int32_t total,errs=0,height=0,j,k,ind,tablesize=0; struct iguana_bundle *bp; struct iguana_block *block; struct iguana_ramchaindata *rdata=0; int64_t checkbalance=0,balance = 0; + char fname[1024],fname2[1024],coinaddr[64],str[65],checkaddr[64]; struct iguana_utxoaddr *utxoaddr,UA,*tmp,*last=0; uint16_t hdrsi; uint8_t *table,item[UTXOADDR_ITEMSIZE]; uint32_t *counts,*offsets,offset,n; int32_t total,errs=0,height=0,j,k,ind,tablesize=0; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata=0; int64_t checkbalance=0,balance = 0; for (hdrsi=0; hdrsibundlescount-1; hdrsi++) { if ( (bp= coin->bundles[hdrsi]) != 0 && bp->bundleheight < maxheight ) @@ -1260,19 +1272,7 @@ int64_t iguana_utxoaddr_gen(struct supernet_info *myinfo,struct iguana_info *coi errs = iguana_utxoaddr_validate(myinfo,coin,height); printf("nogen %s HIST BALANCE %s %.8f errs %d\n",fname2,bits256_str(str,coin->utxoaddrhash),dstr(coin->histbalance),errs); if ( errs == 0 && coin->histbalance > 0 && height > 0 ) - { - coin->firstRTheight = coin->RTheight = height; - iguana_RTreset(coin); - iguana_RTpurge(coin,coin->firstRTheight); - if ( (block= iguana_blockfind("utxogen",coin,coin->blocks.hwmchain.RO.hash2)) != 0 ) - { - portable_mutex_lock(&coin->RTmutex); - iguana_RTnewblock(myinfo,coin,block); - portable_mutex_unlock(&coin->RTmutex); - } - basilisk_unspents_update(myinfo,coin); - return(coin->histbalance); - } + return(iguana_RTstart(myinfo,coin,height)); } printf("utxoaddr_gen.%d\n",maxheight); iguana_utxoaddr_purge(coin); @@ -1398,20 +1398,7 @@ continue; OS_removefile(fname,0); OS_removefile(fname2,0); } - else - { - coin->firstRTheight = coin->RTheight = height; - iguana_RTreset(coin); - iguana_RTpurge(coin,coin->firstRTheight); - if ( (block= iguana_blockfind("utxogen",coin,coin->blocks.hwmchain.RO.hash2)) != 0 ) - { - portable_mutex_lock(&coin->RTmutex); - iguana_RTnewblock(myinfo,coin,block); - portable_mutex_unlock(&coin->RTmutex); - } - basilisk_unspents_update(myinfo,coin); - return(coin->histbalance); - } + else return(iguana_RTstart(myinfo,coin,height)); } } free(counts);