Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
b27923803e
  1. 2
      iguana/iguana777.c
  2. 2
      iguana/iguana777.h
  3. 30
      iguana/iguana_bundles.c
  4. 4
      iguana/iguana_rpc.c
  5. 26
      iguana/iguana_unspents.c

2
iguana/iguana777.c

@ -498,7 +498,7 @@ void iguana_helper(void *arg)
{
coin = ptr->coin;
if ( (bp= ptr->bp) != 0 && coin != 0 && coin->active != 0 )
iguana_convert(coin,bp);//,&bp->ramchain);
iguana_convert(coin,bp,0);//,&bp->ramchain);
myfree(ptr,ptr->allocsize);
}
n = queue_size(&validateQ);

2
iguana/iguana777.h

@ -849,7 +849,7 @@ struct iguana_block *iguana_bundleblock(struct iguana_info *coin,bits256 *hash2p
void *iguana_ramchainfile(struct iguana_info *coin,struct iguana_ramchain *dest,struct iguana_ramchain *R,struct iguana_bundle *bp,int32_t bundlei,struct iguana_block *block);
int32_t iguana_bundlehashadd(struct iguana_info *coin,struct iguana_bundle *bp,int32_t bundlei,struct iguana_block *block);
void iguana_convertQ(struct iguana_info *coin,struct iguana_bundle *bp);
void iguana_convert(struct iguana_info *coin,struct iguana_bundle *bp);//,struct iguana_ramchain *ramchain);
void iguana_convert(struct iguana_info *coin,struct iguana_bundle *bp,int32_t RTflag);//,struct iguana_ramchain *ramchain);
int32_t iguana_bundleissuemissing(struct iguana_info *coin,struct iguana_bundle *bp,int32_t priority,double mult);
//int32_t iguana_blocksmissing(struct iguana_info *coin,int32_t *nonzp,uint8_t missings[IGUANA_MAXBUNDLESIZE/8+1],bits256 hashes[],double mult,struct iguana_bundle *bp,int32_t capacity);
FILE *myfopen(char *fname,char *mode);

30
iguana/iguana_bundles.c

@ -513,7 +513,7 @@ int32_t iguana_bundleissuemissing(struct iguana_info *coin,struct iguana_bundle
printf("priority.%d [%d] durations %.2f counts[%d %d] \n",priority,bp->hdrsi,aveduration,(int32_t)bp->durationscount,bp->duplicatescount);
} else aveduration = IGUANA_DEFAULTLAG;
lag = aveduration * mult;
if ( lag < 60 )
if ( lag < 60 && coin->enableCACHE == 0 )
{
if ( bp != coin->current )
lag = 60;
@ -522,7 +522,11 @@ int32_t iguana_bundleissuemissing(struct iguana_info *coin,struct iguana_bundle
}
if ( (num= coin->peers.numranked) != 0 )
{
max = num;//log2(num * num) + 1;
max = log2(num * num) + 1;
if ( max < IGUANA_MINPEERS )
max = IGUANA_MINPEERS;
if ( max > num )
max = num;
now = (uint32_t)time(NULL);
lasti = firsti = -1;
for (i=nonz=0; i<bp->n; i++)
@ -533,7 +537,7 @@ int32_t iguana_bundleissuemissing(struct iguana_info *coin,struct iguana_bundle
if ( firsti < 0 )
firsti = i;
lasti = i;
if ( (bp->issued[i] == 0 || bp->issued[i] > 1) && now > bp->issued[i]+lag )
if ( bp->numsaved > bp->n-10 || ((bp->issued[i] == 0 || bp->issued[i] > 1) && now > bp->issued[i]+lag) )
{
iguana_bundleblock(coin,&hash2,bp,i);
if ( bits256_nonz(hash2) != 0 )
@ -555,9 +559,9 @@ int32_t iguana_bundleissuemissing(struct iguana_info *coin,struct iguana_bundle
}
}
}
if ( firsti >= 0 && (firsti == lasti || bp == coin->current) )
if ( firsti >= 0 && (coin->enableCACHE != 0 || nonz < 10 || bp == coin->current) )
{
printf("[%d] first missing.%d of %d\n",bp->hdrsi,firsti,nonz);
//printf("[%d] first missing.%d of %d\n",bp->hdrsi,firsti,nonz);
iguana_bundleblock(coin,&hash2,bp,firsti);
if ( bits256_nonz(hash2) != 0 )
{
@ -632,13 +636,13 @@ int32_t iguana_bundlehdr(struct iguana_info *coin,struct iguana_bundle *bp,int32
bp->hdrtime = (uint32_t)time(NULL);
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1);
}
if ( coin->enableCACHE != 0 && bp->hdrsi == coin->bundlescount-1 && bits256_nonz(bp->nextbundlehash2) == 0 )
if ( coin->enableCACHE != 0 && (bp == coin->current || bp->hdrsi == coin->bundlescount-1) && bits256_nonz(bp->nextbundlehash2) == 0 )
{
iguana_bundleissuemissing(coin,bp,1,.1);
/*if ( bp == coin->current )
{
mult = 1.;
printf("iguana_bundlehdr.[%d] %d %s\n",bp->hdrsi,bp->numspec,bits256_str(str,bp->hashes[0]));
iguana_bundleissuemissing(coin,bp,1,mult);
}*/
}
return(counter);
@ -737,7 +741,7 @@ int32_t iguana_bundlefinish(struct iguana_info *coin,struct iguana_bundle *bp)
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 && time(NULL) > bp->emitfinish+3 )
if ( bp->hdrsi < coin->blocks.hwmchain.height/coin->chain->bundlesize && i >= bp->hdrsi-(IGUANA_NUMHELPERS>>1) && time(NULL) > bp->emitfinish+3 )
{
//printf("[%d] vs %d i.%d vs %d emitted.%ld (%d %d %d) s.%u f.%u\n",bp->hdrsi,coin->blocks.hwmchain.height/coin->chain->bundlesize,i,bp->hdrsi-IGUANA_NUMHELPERS/2,time(NULL) - bp->emitfinish,bp->hdrsi < coin->blocks.hwmchain.height/coin->chain->bundlesize,i >= bp->hdrsi-IGUANA_NUMHELPERS, time(NULL) > bp->emitfinish,bp->startutxo,bp->utxofinish);
if ( bp->startutxo == 0 )
@ -934,13 +938,13 @@ void iguana_bundlemissings(struct iguana_info *coin,struct iguana_bundle *bp,uin
{
if ( coin->current != 0 )
mult = bp->hdrsi - coin->current->hdrsi;
if ( mult < 5 )
mult = 5;
else if ( mult > 13 )
mult = 13;
if ( mult < 4 )
mult = 4;
else if ( mult > 7 )
mult = 7;
if ( (n= iguana_bundleissuemissing(coin,bp,1,mult)) > 0 )
{
printf("bundle.[%d] n.%d issued.%d lag.%d\n",bp->hdrsi,n,bp->numissued,now-bp->missingstime);
//printf("bundle.[%d] n.%d issued.%d lag.%d\n",bp->hdrsi,n,bp->numissued,now-bp->missingstime);
bp->numissued += n;
bp->missingstime = (uint32_t)time(NULL);
}

4
iguana/iguana_rpc.c

@ -652,11 +652,11 @@ char *iguana_bitcoinRPC(struct supernet_info *myinfo,char *method,cJSON *json,ch
}
else if ( n > 0 )
{
printf("n.%d (%s)\n",n,jstr(array,0));
//printf("n.%d (%s)\n",n,jstr(array,0));
for (i=n-1; i>=0; i--)
{
params[i] = cJSON_DetachItemFromArray(array,i);//;
printf("add params[%d] of %d <- (%s) %p.(%p %p)\n",i,n,jprint(params[i],0),params[i],params[i]->next,params[i]->prev);
//printf("add params[%d] of %d <- (%s) %p.(%p %p)\n",i,n,jprint(params[i],0),params[i],params[i]->next,params[i]->prev);
}
}
retstr = iguana_bitcoinrpc(myinfo,port,coin,method,params,n,json,remoteaddr,array);

26
iguana/iguana_unspents.c

@ -955,7 +955,7 @@ int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp,st
{
if ( bp->tmpspends != ramchain->Xspendinds )
{
printf("spendvectors: unexpected tmpspends? [%d] numtmpspends.%d vs emit.%d\n",bp->hdrsi,bp->numtmpspends,emit);
printf("spendvectors: unexpected tmpspends? or RT [%d] numtmpspends.%d vs emit.%d\n",bp->hdrsi,bp->numtmpspends,emit);
bp->tmpspends = myrealloc('x',bp->tmpspends,sizeof(*ptr)*bp->numtmpspends,sizeof(*ptr)*(bp->numtmpspends+emit));
memcpy(&bp->tmpspends[bp->numtmpspends],ptr,sizeof(*ptr)*emit);
bp->numtmpspends += emit;
@ -965,6 +965,7 @@ int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp,st
{
bp->tmpspends = myrealloc('x',ptr,sizeof(*ptr)*n,sizeof(*ptr)*emit);
bp->numtmpspends = emit;
printf("ALLOC tmpspends.[%d]\n",bp->hdrsi);
ptr = 0;
}
} else errs = -iguana_spendvectorsave(coin,bp,ramchain,ptr!=0?ptr:bp->tmpspends,emit,n);
@ -1629,7 +1630,7 @@ int32_t iguana_spendvectorconvs(struct iguana_info *coin,struct iguana_bundle *s
}
spentbp->converted = 1;
spent_hdrsi = spentbp->hdrsi;
ramchain = (spentbp == coin->current) ? &coin->RTramchain : &spentbp->ramchain;
ramchain = &spentbp->ramchain;
numpkinds = ramchain->H.data->numpkinds;
iguana_ramchain_prefetch(coin,ramchain,0);
spentU = (void *)(long)((long)ramchain->H.data + ramchain->H.data->Uoffset);
@ -1659,14 +1660,14 @@ int32_t iguana_spendvectorconvs(struct iguana_info *coin,struct iguana_bundle *s
}
}
}
}
} else printf("iguana_spendvectorconvs: [%d] null bp.%p or null tmpspends\n",i,bp);
}
spentbp->converted = (uint32_t)time(NULL);
//printf("spendvectorconvs.[%d] converted.%d\n",refbp->hdrsi,converted);
return(converted);
}
void iguana_convert(struct iguana_info *coin,struct iguana_bundle *bp)
void iguana_convert(struct iguana_info *coin,struct iguana_bundle *bp,int32_t RTflag)
{
static int64_t total,depth;
int32_t i,n,m,converted; int64_t total_tmpspends; double startmillis = OS_milliseconds();
@ -1688,7 +1689,7 @@ void iguana_convert(struct iguana_info *coin,struct iguana_bundle *bp)
}
total += converted;
printf("[%4d] millis %7.3f converted.%-7d balance calc.%-4d of %4d | total.%llu of %llu depth.%d\n",bp->hdrsi,OS_milliseconds()-startmillis,converted,m,n,(long long)total,(long long)total_tmpspends,(int32_t)depth);
if ( m == n-1 )
if ( RTflag == 0 && m == n-1 )
{
if ( iguana_spendvectorsaves(coin) == 0 )
{
@ -1866,13 +1867,13 @@ void iguana_RThdrs(struct iguana_info *coin,struct iguana_bundle *bp,int32_t num
}
}
void iguana_RTspendvectors(struct iguana_info *coin,struct iguana_bundle *bp,struct iguana_ramchain *dest)
void iguana_RTspendvectors(struct iguana_info *coin,struct iguana_bundle *bp)
{
struct iguana_ramchain R; struct iguana_ramchaindata RDATA;
iguana_rdataset(&R,&RDATA,dest);
bp->ramchain = *dest;
iguana_ramchain_prefetch(coin,dest,0);
if ( iguana_spendvectors(coin,bp,dest,coin->RTstarti,coin->RTheight%bp->n,0) < 0 )
bp->ramchain = coin->RTramchain;
iguana_rdataset(&R,&RDATA,&coin->RTramchain);
iguana_ramchain_prefetch(coin,&coin->RTramchain,0);
if ( iguana_spendvectors(coin,bp,&coin->RTramchain,coin->RTstarti,coin->RTheight%bp->n,0) < 0 )
{
printf("RTutxo error -> RTramchainfree\n");
iguana_RTramchainfree(coin);
@ -1882,7 +1883,8 @@ void iguana_RTspendvectors(struct iguana_info *coin,struct iguana_bundle *bp,str
{
coin->RTstarti = (coin->RTheight % bp->n);
printf("spendvectors calculated to %d\n",coin->RTheight);
iguana_convert(coin,bp);//,dest);
bp->converted = 0;
iguana_convert(coin,bp,1);
printf("spendvectors converted to %d\n",coin->RTheight);
}
}
@ -1982,7 +1984,7 @@ int32_t iguana_realtime_update(struct iguana_info *coin)
{
printf("RTgenesis verified\n");
coin->RTgenesis = (uint32_t)time(NULL);
iguana_RTspendvectors(coin,bp,&coin->RTramchain);
iguana_RTspendvectors(coin,bp);
} else printf("RTgenesis failed to verify n.%d vs %d\n",n,coin->RTheight);
}
if ( dest != 0 && flag != 0 )

Loading…
Cancel
Save