Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
c29dcc1c04
  1. 2
      iguana/iguana_blocks.c
  2. 12
      iguana/iguana_realtime.c
  3. 43
      iguana/iguana_unspents.c

2
iguana/iguana_blocks.c

@ -677,9 +677,7 @@ struct iguana_block *_iguana_chainlink(struct supernet_info *myinfo,struct iguan
process_iguanablock(block->serdata,CHAINPARMS); process_iguanablock(block->serdata,CHAINPARMS);
}*/ }*/
iguana_blockzcopy(coin->chain->zcash,(void *)&coin->blocks.hwmchain,block); iguana_blockzcopy(coin->chain->zcash,(void *)&coin->blocks.hwmchain,block);
portable_mutex_lock(&coin->RTmutex);
iguana_RTnewblock(myinfo,coin,block); iguana_RTnewblock(myinfo,coin,block);
portable_mutex_unlock(&coin->RTmutex);
return(block); return(block);
} }
} }

12
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); printf("iguana_RTnewblock illegal blockheight.%d\n",block->height);
return; 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 ) if ( block->height > coin->lastRTheight )
{ {
n = (block->height - coin->RTheight) + 1; 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 ( (subblock= iguana_RTblock(coin,block->height)) != 0 && subblock != block )
{ {
if ( iguana_RTblocksub(myinfo,coin,subblock) < 0 || iguana_RTblockadd(myinfo,coin,block) < 0 ) if ( iguana_RTblocksub(myinfo,coin,subblock) < 0 || iguana_RTblockadd(myinfo,coin,block) < 0 )
{
portable_mutex_unlock(&coin->RTmutex);
return; return;
}
printf("%s == RTnewblock RTheight %d prev %d\n",coin->symbol,coin->RTheight,coin->lastRTheight); 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 ) if ( iguana_RTblocksub(myinfo,coin,iguana_RTblock(coin,coin->lastRTheight--)) < 0 )
{ {
coin->RTheight = coin->lastRTheight+1; coin->RTheight = coin->lastRTheight+1;
portable_mutex_unlock(&coin->RTmutex);
return; return;
} }
} }
coin->RTheight = coin->lastRTheight+1; coin->RTheight = coin->lastRTheight+1;
if ( iguana_RTblockadd(myinfo,coin,block) < 0 ) if ( iguana_RTblockadd(myinfo,coin,block) < 0 )
{
portable_mutex_unlock(&coin->RTmutex);
return; return;
}
coin->lastRTheight = block->height; coin->lastRTheight = block->height;
coin->RTheight = coin->lastRTheight+1; coin->RTheight = coin->lastRTheight+1;
} }
} }
portable_mutex_unlock(&coin->RTmutex);
//block = iguana_blockfind("next",coin,iguana_blockhash(coin,block->height+1));
} }
} }

43
iguana/iguana_unspents.c

@ -1245,9 +1245,21 @@ int32_t iguana_utxoaddr_validate(struct supernet_info *myinfo,struct iguana_info
return(errs); 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) 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; hdrsi<coin->bundlescount-1; hdrsi++) for (hdrsi=0; hdrsi<coin->bundlescount-1; hdrsi++)
{ {
if ( (bp= coin->bundles[hdrsi]) != 0 && bp->bundleheight < maxheight ) 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); 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); 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 ) if ( errs == 0 && coin->histbalance > 0 && height > 0 )
{ return(iguana_RTstart(myinfo,coin,height));
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);
}
} }
printf("utxoaddr_gen.%d\n",maxheight); printf("utxoaddr_gen.%d\n",maxheight);
iguana_utxoaddr_purge(coin); iguana_utxoaddr_purge(coin);
@ -1398,20 +1398,7 @@ continue;
OS_removefile(fname,0); OS_removefile(fname,0);
OS_removefile(fname2,0); OS_removefile(fname2,0);
} }
else else return(iguana_RTstart(myinfo,coin,height));
{
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);
}
} }
} }
free(counts); free(counts);

Loading…
Cancel
Save