Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
5291bc4f36
  1. 8
      iguana/iguana777.c
  2. 7
      iguana/iguana_bundles.c
  3. 14
      iguana/iguana_init.c
  4. 31
      iguana/iguana_recv.c
  5. 40
      iguana/iguana_unspents.c

8
iguana/iguana777.c

@ -477,11 +477,9 @@ void iguana_helper(void *arg)
if ( retval > 0 )
{
printf("GENERATED UTXO.%d for ht.%d duration %d seconds\n",bp->hdrsi,bp->bundleheight,(uint32_t)time(NULL)-bp->startutxo);
bp->utxofinish = (uint32_t)time(NULL);
bp->balancefinish = 0;
}
if ( bp->balancefinish == 0 )
iguana_balancesQ(coin,bp);
} else printf("null retval from iguana_spendvectors.[%d]\n",bp->hdrsi);
bp->utxofinish = (uint32_t)time(NULL);
iguana_balancesQ(coin,bp);
} else printf("UTXO gen.[%d] utxo error\n",bp->hdrsi);
}
else if ( coin->active != 0 )

7
iguana/iguana_bundles.c

@ -751,18 +751,19 @@ int32_t iguana_bundlefinish(struct iguana_info *coin,struct iguana_bundle *bp)
{
struct iguana_bundle *prevbp; int32_t i;
#ifdef IGUANA_SERIALIZE_SPENDVECTORGEN
if ( (prevbp= coin->current) != 0 && prevbp->hdrsi < (coin->longestchain / coin->chain->bundlesize)-0*coin->MAXBUNDLES )
if ( (prevbp= coin->current) != 0 && prevbp->hdrsi < (coin->longestchain / coin->chain->bundlesize)-coin->MAXBUNDLES )
return(0);
#endif
for (i=0; i<bp->hdrsi; i++)
if ( (prevbp= coin->bundles[i]) == 0 || prevbp->emitfinish <= 1 || (prevbp->utxofinish == 0 && prevbp->tmpspends == 0) )
break;
if ( bp->hdrsi < coin->blocks.hwmchain.height/coin->chain->bundlesize && i >= bp->hdrsi-IGUANA_NUMHELPERS/2 && time(NULL) > bp->emitfinish+10 )//&& coin->emitbusy <= 4 )
//printf("[%d] vs %d i.%d vs %d\n",bp->hdrsi,coin->blocks.hwmchain.height/coin->chain->bundlesize,i,bp->hdrsi-IGUANA_NUMHELPERS/2);
if ( bp->hdrsi < coin->blocks.hwmchain.height/coin->chain->bundlesize && i >= bp->hdrsi-IGUANA_NUMHELPERS && time(NULL) > bp->emitfinish+10 )
{
if ( bp->startutxo == 0 )
{
bp->startutxo = (uint32_t)time(NULL);
//printf("spendvectorQ.%d\n",bp->hdrsi);
//printf("spendvectorsQ.%d\n",bp->hdrsi);
iguana_spendvectorsQ(coin,bp);
}
else if ( bp->utxofinish != 0 )

14
iguana/iguana_init.c

@ -302,6 +302,20 @@ void iguana_parseline(struct iguana_info *coin,int32_t iter,FILE *fp)
}
if ( iter == 1 )
{
for (i=0; i<coin->bundlescount-1; i++)
{
if ( coin->bundles[i] == 0 || coin->bundles[i]->utxofinish <= 1 )
break;
}
if ( i < coin->bundlescount-1 )
{
printf("spendvectors.[%d] missing, will regen all of them\n",i);
for (i=0; i<coin->bundlescount-1; i++)
{
//iguana_purgevolatiles(coin,&coin->bundles[i]->ramchain);
coin->bundles[i]->startutxo = coin->bundles[i]->utxofinish = 0;
}
}
if ( coin->balanceswritten > 0 )
coin->balanceswritten = iguana_volatileinit(coin);
if ( coin->balanceswritten > 0 )

31
iguana/iguana_recv.c

@ -1426,18 +1426,31 @@ int32_t iguana_processrecv(struct iguana_info *coin) // single threaded
{
int32_t newhwm = 0,hwmheight,flag = 0; char str[2000];
hwmheight = coin->blocks.hwmchain.height;
flag += iguana_processrecvQ(coin,&newhwm);
flag += iguana_reqblocks(coin);
flag += iguana_reqhdrs(coin);
coin->RTramchain_busy = 1;
if ( time(NULL) > coin->laststats )
if ( coin->RTheight != 0 )
{
flag += (iguana_realtime_update(coin) > 0);
iguana_bundlestats(coin,str,IGUANA_DEFAULTLAG);
coin->laststats = (uint32_t)time(NULL);
if ( time(NULL) > coin->laststats+2 )
{
flag += iguana_processrecvQ(coin,&newhwm);
flag += iguana_reqblocks(coin);
flag += iguana_reqhdrs(coin);
iguana_bundlestats(coin,str,IGUANA_DEFAULTLAG);
coin->laststats = (uint32_t)time(NULL);
}
//if ( coin->RTheight < coin->longestchain-3 )
}
else
{
flag += iguana_processrecvQ(coin,&newhwm);
flag += iguana_reqblocks(coin);
flag += iguana_reqhdrs(coin);
if ( time(NULL) > coin->laststats+1 )
{
iguana_bundlestats(coin,str,IGUANA_DEFAULTLAG);
flag += (iguana_realtime_update(coin) > 0);
coin->laststats = (uint32_t)time(NULL);
}
}
else if ( coin->RTheight < coin->longestchain-3 )
flag += (iguana_realtime_update(coin) > 0);
coin->RTramchain_busy = (coin->RTgenesis == 0 || queue_size(&balancesQ) != 0);
iguana_jsonQ();
if ( hwmheight != coin->blocks.hwmchain.height )

40
iguana/iguana_unspents.c

@ -728,6 +728,8 @@ uint32_t iguana_spendvectorconv(struct iguana_info *coin,struct iguana_spendvect
int32_t iguana_spendvectorsave(struct iguana_info *coin,struct iguana_bundle *bp,struct iguana_ramchain *ramchain,struct iguana_spendvector *ptr,int32_t emit,int32_t n)
{
int32_t i,retval = -1; FILE *fp; char fname[1024],str[65]; long fsize; bits256 zero,sha256;
if ( ptr == bp->ramchain.Xspendinds )
return(0);
memset(zero.bytes,0,sizeof(zero));
for (i=0; i<emit; i++)
if ( iguana_spendvectorconv(coin,&ptr[i],bp) == 0 )
@ -769,7 +771,7 @@ int32_t iguana_spendvectorsave(struct iguana_info *coin,struct iguana_bundle *bp
int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp)
{
static uint64_t total,emitted;
int32_t spendind,n,txidind,errs=0,emit=0,i,j,k; double startmillis;
int32_t spendind,n=0,txidind,errs=0,emit=0,i,j,k; double startmillis;
uint32_t spent_unspentind,spent_pkind,now,starttime; struct iguana_ramchaindata *rdata;
struct iguana_bundle *spentbp; struct iguana_blockRO *B; char str[65];
bits256 prevhash; struct iguana_unspent *u,*spentU; struct iguana_txid *T;
@ -777,14 +779,21 @@ int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp)
ramchain = &bp->ramchain;
//printf("iguana_spendvectors.[%d] gen.%d ramchain data.%p\n",bp->hdrsi,bp->bundleheight,ramchain->H.data);
if ( (rdata= ramchain->H.data) == 0 || (n= rdata->numspends) < 1 )
{
printf("iguana_spendvectors: no rdata.%p %d\n",rdata,n);
return(0);
}
B = (void *)(long)((long)rdata + rdata->Boffset);
S = (void *)(long)((long)rdata + rdata->Soffset);
T = (void *)(long)((long)rdata + rdata->Toffset);
if ( ramchain->Xspendinds != 0 )
{
bp->tmpspends = ramchain->Xspendinds;
bp->numtmpspends = ramchain->numXspends;
bp->utxofinish = (uint32_t)time(NULL);
bp->balancefinish = 0;
//printf("iguana_spendvectors: already have Xspendinds[%d]\n",ramchain->numXspends);
return(0);
return(ramchain->numXspends);
}
ptr = mycalloc('x',sizeof(*ptr),n);
total += n;
@ -906,10 +915,16 @@ int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp)
if ( coin->balanceswritten <= 1 )
{
if ( bp->tmpspends != 0 )
printf("unexpected tmpspends? [%d] numtmpspends.%d vs emit.%d\n",bp->hdrsi,bp->numtmpspends,emit);
bp->tmpspends = myrealloc('x',ptr,sizeof(*ptr)*n,sizeof(*ptr)*emit);
bp->numtmpspends = emit;
ptr = 0;
{
if ( bp->tmpspends != ramchain->Xspendinds )
printf("unexpected tmpspends? [%d] numtmpspends.%d vs emit.%d\n",bp->hdrsi,bp->numtmpspends,emit);
}
else
{
bp->tmpspends = myrealloc('x',ptr,sizeof(*ptr)*n,sizeof(*ptr)*emit);
bp->numtmpspends = emit;
ptr = 0;
}
} else errs = -iguana_spendvectorsave(coin,bp,ramchain,ptr!=0?ptr:bp->tmpspends,emit,n);
}
if ( ptr != 0 )
@ -1657,7 +1672,7 @@ int32_t iguana_balancenormal(struct iguana_info *coin,struct iguana_bundle *bp,i
{
printf("TRIGGER FLUSH %d vs %d\n",bp->hdrsi,coin->blocks.hwmchain.height/coin->chain->bundlesize);
sleep(1);
if ( time(NULL) > coin->startutc+60 && bp->hdrsi >= coin->blocks.hwmchain.height/coin->chain->bundlesize-1 )
if ( time(NULL) > coin->startutc+10 && bp->hdrsi >= coin->blocks.hwmchain.height/coin->chain->bundlesize-1 )
{
if ( iguana_balanceflush(coin,bp->hdrsi,3) > 0 )
printf("balanceswritten.%d flushed bp->hdrsi %d vs %d coin->longestchain/coin->chain->bundlesize\n",coin->balanceswritten,bp->hdrsi,coin->longestchain/coin->chain->bundlesize);
@ -1695,7 +1710,8 @@ int32_t iguana_spendvectorsaves(struct iguana_info *coin)
}
else if ( iguana_spendvectorsave(coin,bp,&bp->ramchain,bp->tmpspends,bp->numtmpspends,bp->ramchain.H.data->numspends) == 0 )
{
myfree(bp->tmpspends,sizeof(*bp->tmpspends) * bp->numtmpspends);
if ( bp->tmpspends != bp->ramchain.Xspendinds )
myfree(bp->tmpspends,sizeof(*bp->tmpspends) * bp->numtmpspends);
bp->numtmpspends = 0;
bp->tmpspends = 0;
}
@ -1735,7 +1751,10 @@ int32_t iguana_spendvectorconvs(struct iguana_info *coin,struct iguana_bundle *s
if ( vec->hdrsi == spent_hdrsi )
{
if ( vec->tmpflag == 0 )
printf("unexpected null tmpflag [%d] j.%d spentbp.[%d]\n",bp->hdrsi,j,spentbp->hdrsi);
{
if ( bp->tmpspends != bp->ramchain.Xspendinds )
printf("unexpected null tmpflag [%d] j.%d spentbp.[%d]\n",bp->hdrsi,j,spentbp->hdrsi);
}
else
{
if ( _iguana_spendvectorconv(vec,&spentU[vec->unspentind],numpkinds) != 0 )
@ -1803,7 +1822,10 @@ int32_t iguana_balancecalc(struct iguana_info *coin,struct iguana_bundle *bp,int
break;
}
if ( i == coin->bundlescount-1 && bp->tmpspends != 0 && bp->ramchain.H.data != 0 && (n= bp->ramchain.H.data->numspends) != 0 && bp->converted == 0 )
{
iguana_convertQ(coin,bp);
retval = 0;
}
else
{
for (i=0; i<coin->bundlescount-1; i++)

Loading…
Cancel
Save