Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
98c75304d2
  1. 48
      iguana/iguana777.c
  2. 4
      iguana/iguana777.h
  3. 14
      iguana/iguana_bundles.c
  4. 2
      iguana/iguana_peers.c
  5. 4
      iguana/iguana_ramchain.c
  6. 14
      iguana/iguana_recv.c
  7. 4
      iguana/iguana_unspents.c
  8. 65
      iguana/main.c

48
iguana/iguana777.c

@ -252,7 +252,7 @@ void iguana_emitQ(struct iguana_info *coin,struct iguana_bundle *bp)
ptr->bp = bp, ptr->hdrsi = bp->hdrsi; ptr->bp = bp, ptr->hdrsi = bp->hdrsi;
ptr->type = 'E'; ptr->type = 'E';
ptr->starttime = (uint32_t)time(NULL); ptr->starttime = (uint32_t)time(NULL);
printf("%s EMIT.%d[%d] emitfinish.%u\n",coin->symbol,ptr->hdrsi,bp->n,bp->emitfinish); //printf("%s EMIT.%d[%d] emitfinish.%u\n",coin->symbol,ptr->hdrsi,bp->n,bp->emitfinish);
queue_enqueue("emitQ",&emitQ,&ptr->DL,0); queue_enqueue("emitQ",&emitQ,&ptr->DL,0);
} }
@ -432,52 +432,6 @@ void iguana_helper(void *arg)
} }
} }
void iguana_coinflush(struct iguana_info *coin,int32_t forceflag)
{
int32_t hdrsi,blen; struct iguana_bundle *bp; char fname[1024],fname2[1024]; FILE *fp,*fp2=0;
memset(coin->bundlebits,0,sizeof(coin->bundlebits));
for (hdrsi=0; hdrsi<coin->bundlescount; hdrsi++)
if ( (bp= coin->bundles[hdrsi]) != 0 && bp->validated != 0 )
SETBIT(coin->bundlebits,hdrsi);
blen = (int32_t)hconv_bitlen(coin->bundlescount);
for (hdrsi=0; hdrsi<coin->bundlescount; hdrsi++)
{
if ( (bp= coin->bundles[hdrsi]) != 0 && (forceflag != 0 || (bp->dirty != 0 && time(NULL) > bp->dirty+60)) && bp->ramchain.H.data != 0 && bp->ramchain.A != 0 && bp->ramchain.Uextras != 0 )
{
if ( forceflag == 0 )
{
sprintf(fname,"accounts/%s/debits.%d",coin->symbol,bp->bundleheight);
sprintf(fname2,"accounts/%s/lastspends.%d",coin->symbol,bp->bundleheight);
}
else
{
sprintf(fname,"DB/%s/accounts/debits_%d.%d",coin->symbol,coin->bundlescount,bp->bundleheight);
sprintf(fname2,"DB/%s/accounts/lastspends_%d.%d",coin->symbol,coin->bundlescount,bp->bundleheight);
}
//printf("save (%s) and (%s) %p %p\n",fname,fname2,bp,bp->ramchain.H.data);//,bp->ramchain.H.data->numpkinds,bp->ramchain.H.data->numunspents);
if ( (fp= fopen(fname,"wb")) != 0 && (fp2= fopen(fname2,"wb")) != 0 )
{
if ( fwrite(&coin->bundlescount,1,sizeof(coin->bundlescount),fp) == sizeof(coin->bundlescount) && fwrite(&coin->bundlescount,1,sizeof(coin->bundlescount),fp2) == sizeof(coin->bundlescount) && fwrite(coin->bundlebits,1,blen,fp) == blen && fwrite(coin->bundlebits,1,blen,fp2) == blen )
{
if ( fwrite(bp->ramchain.A,sizeof(*bp->ramchain.A),bp->ramchain.H.data->numpkinds,fp) == bp->ramchain.H.data->numpkinds )
{
if ( fwrite(bp->ramchain.Uextras,sizeof(*bp->ramchain.Uextras),bp->ramchain.H.data->numunspents,fp2) == bp->ramchain.H.data->numunspents )
{
bp->dirty = 0;
printf("saved (%s) and (%s)\n",fname,fname2);
}
}
}
fclose(fp), fclose(fp2);
if ( bp->dirty != 0 )
printf("error writing %s\n",fname);
}
else if ( fp != 0 )
fclose(fp);
}
}
}
void iguana_coinloop(void *arg) void iguana_coinloop(void *arg)
{ {
struct iguana_info *coin,**coins = arg; struct iguana_info *coin,**coins = arg;

4
iguana/iguana777.h

@ -452,7 +452,7 @@ struct iguana_info
struct iguana_peers peers; struct iguana_peers peers;
uint64_t instance_nonce,myservices,totalsize,totalrecv,totalpackets,sleeptime; uint64_t instance_nonce,myservices,totalsize,totalrecv,totalpackets,sleeptime;
int64_t mining,totalfees,TMPallocated,MAXRECVCACHE,MAXMEM,estsize,activebundles; int64_t mining,totalfees,TMPallocated,MAXRECVCACHE,MAXMEM,estsize,activebundles;
int32_t MAXPEERS,MAXPENDING,MAXBUNDLES,active,closestbundle,numemitted,lastsweep,startutc,newramchain,numcached,cachefreed,helperdepth,startPEND,endPEND,enableCACHE,RELAYNODE,VALIDATENODE; int32_t MAXPEERS,MAXPENDING,MAXBUNDLES,active,closestbundle,numemitted,lastsweep,startutc,newramchain,numcached,cachefreed,helperdepth,startPEND,endPEND,enableCACHE,RELAYNODE,VALIDATENODE,balanceswritten;
uint32_t longestchain,lastsync,parsetime,numiAddrs,firstblock,lastpossible,bundlescount,savedblocks; uint32_t longestchain,lastsync,parsetime,numiAddrs,firstblock,lastpossible,bundlescount,savedblocks;
struct tai starttime; double startmillis; struct tai starttime; double startmillis;
struct iguana_chain *chain; struct iguana_chain *chain;
@ -788,7 +788,7 @@ int32_t iguana_bloomfind(struct iguana_info *coin,struct iguana_bloom16 *bloom,i
struct iguana_bloominds iguana_bloomset(struct iguana_info *coin,struct iguana_bloom16 *bloom,int32_t incr,struct iguana_bloominds bit); struct iguana_bloominds iguana_bloomset(struct iguana_info *coin,struct iguana_bloom16 *bloom,int32_t incr,struct iguana_bloominds bit);
int32_t iguana_Xspendmap(struct iguana_info *coin,struct iguana_ramchain *ramchain,struct iguana_bundle *bp); int32_t iguana_Xspendmap(struct iguana_info *coin,struct iguana_ramchain *ramchain,struct iguana_bundle *bp);
void iguana_balancesQ(struct iguana_info *coin,struct iguana_bundle *bp); void iguana_balancesQ(struct iguana_info *coin,struct iguana_bundle *bp);
void iguana_coinflush(struct iguana_info *coin,int32_t forceflag); int32_t iguana_balanceflush(struct iguana_info *coin,int32_t refhdrsi);
int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int32_t starti,int32_t max); int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int32_t starti,int32_t max);
void iguana_balancecalc(struct iguana_info *coin,struct iguana_bundle *bp); void iguana_balancecalc(struct iguana_info *coin,struct iguana_bundle *bp);
int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_bundle *bp,int32_t bundlei,bits256 hash2,int32_t iamthreadsafe); int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_bundle *bp,int32_t bundlei,bits256 hash2,int32_t iamthreadsafe);

14
iguana/iguana_bundles.c

@ -496,7 +496,7 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int
{ {
if ( peercounts[i] > threshold && (addr= coin->peers.ranked[i]) != 0 && now > bp->currenttime+lag && addr->dead == 0 ) if ( peercounts[i] > threshold && (addr= coin->peers.ranked[i]) != 0 && now > bp->currenttime+lag && addr->dead == 0 )
{ {
if ( numpeers > 64 || addr->laggard++ > 3 ) if ( numpeers > 64 || addr->laggard++ > 777 )
addr->dead = (uint32_t)time(NULL); addr->dead = (uint32_t)time(NULL);
for (j=0; j<bp->n; j++) for (j=0; j<bp->n; j++)
{ {
@ -532,10 +532,10 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int
if ( priority != 0 ) if ( priority != 0 )
{ {
//printf("[%d:%d] ",bp->hdrsi,i); //printf("[%d:%d] ",bp->hdrsi,i);
iguana_blockQ("kick",coin,bp,i,block->RO.hash2,bp == coin->current && now > block->issued+lag); iguana_blockQ("kicka",coin,bp,i,block->RO.hash2,bp == coin->current && now > block->issued+lag);
if ( bp == coin->current && now > block->issued+lag*3 && (addr= coin->peers.ranked[rand() % numpeers]) != 0 ) if ( bp == coin->current && now > block->issued+lag*3 && (addr= coin->peers.ranked[rand() % numpeers]) != 0 )
iguana_sendblockreqPT(coin,addr,bp,i,block->RO.hash2,0); iguana_sendblockreqPT(coin,addr,bp,i,block->RO.hash2,0);
} else iguana_blockQ("kick",coin,bp,i,block->RO.hash2,0); } else iguana_blockQ("kickb",coin,bp,i,block->RO.hash2,0);
flag++; flag++;
} //else printf("%d ",now - block->issued); } //else printf("%d ",now - block->issued);
} }
@ -557,7 +557,7 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int
block->numrequests++; block->numrequests++;
if ( bp == coin->current ) if ( bp == coin->current )
printf("[%d:%d].%x ",bp->hdrsi,i,block->fpipbits); printf("[%d:%d].%x ",bp->hdrsi,i,block->fpipbits);
iguana_blockQ("kick",coin,bp,i,block->RO.hash2,bp == coin->current); iguana_blockQ("kickc",coin,bp,i,block->RO.hash2,bp == coin->current);
bp->issued[i] = block->issued = now; bp->issued[i] = block->issued = now;
counter++; counter++;
if ( --max <= 0 ) if ( --max <= 0 )
@ -571,7 +571,7 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int
{ {
if ( bp == coin->current ) if ( bp == coin->current )
printf("[%d:%d].%x ",bp->hdrsi,i,block->fpipbits); printf("[%d:%d].%x ",bp->hdrsi,i,block->fpipbits);
iguana_blockQ("kick",coin,bp,i,bp->hashes[i],bp == coin->current); iguana_blockQ("kickd",coin,bp,i,bp->hashes[i],bp == coin->current);
bp->issued[i] = now; bp->issued[i] = now;
counter++; counter++;
} }
@ -579,7 +579,7 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int
{ {
if ( bp == coin->current ) if ( bp == coin->current )
printf("[%d:%d].%x ",bp->hdrsi,i,block->fpipbits); printf("[%d:%d].%x ",bp->hdrsi,i,block->fpipbits);
iguana_blockQ("kick",coin,bp,i,bp->speculative[i],0); iguana_blockQ("kicke",coin,bp,i,bp->speculative[i],0);
bp->issued[i] = now; bp->issued[i] = now;
counter++; counter++;
} }
@ -741,7 +741,7 @@ int64_t iguana_bundlecalcs(struct iguana_info *coin,struct iguana_bundle *bp)
} }
else if ( bp == coin->current ) else if ( bp == coin->current )
{ {
if ( bp->speculative != 0 && bits256_nonz(bp->speculative[bundlei]) != 0 && bits256_nonz(bp->hashes[bundlei]) == 0 && time(NULL) > bp->issued[bundlei]+10 ) if ( bp->speculative != 0 && bits256_nonz(bp->speculative[bundlei]) != 0 && bits256_nonz(bp->hashes[bundlei]) == 0 && time(NULL) > bp->issued[bundlei]+60 )
{ {
//char str[65]; printf(" mismatched [%d:%d] %s block.%p\n",bp->hdrsi,bundlei,bits256_str(str,bp->speculative[bundlei]),block); //char str[65]; printf(" mismatched [%d:%d] %s block.%p\n",bp->hdrsi,bundlei,bits256_str(str,bp->speculative[bundlei]),block);
iguana_blockQ("missing",coin,0,-1,bp->speculative[bundlei],0); iguana_blockQ("missing",coin,0,-1,bp->speculative[bundlei],0);

2
iguana/iguana_peers.c

@ -622,7 +622,7 @@ void iguana_startconnection(void *arg)
n++; n++;
iguana_iAconnected(coin,addr); iguana_iAconnected(coin,addr);
coin->peers.numconnected++; coin->peers.numconnected++;
printf("PEER CONNECTED.%d:%d of max.%d! %s:%d usock.%d\n",coin->peers.numconnected,n,coin->MAXPEERS,addr->ipaddr,coin->chain->portp2p,addr->usock); printf("%s.PEER CONNECTED.%d:%d of max.%d! %s:%d usock.%d\n",coin->symbol,coin->peers.numconnected,n,coin->MAXPEERS,addr->ipaddr,coin->chain->portp2p,addr->usock);
if ( strcmp("127.0.0.1",addr->ipaddr) == 0 ) if ( strcmp("127.0.0.1",addr->ipaddr) == 0 )
coin->peers.localaddr = addr; coin->peers.localaddr = addr;
else if ( coin->peers.numranked == 0 ) else if ( coin->peers.numranked == 0 )

4
iguana/iguana_ramchain.c

@ -2119,7 +2119,7 @@ int32_t iguana_ramchain_expandedsave(struct iguana_info *coin,RAMCHAIN_FUNC,stru
if ( (long)destoffset > (long)srcoffset ) if ( (long)destoffset > (long)srcoffset )
printf("smashed stack? dest.%ld vs src %ld offset.%u stacksize.%u space.%u\n",(long)destoffset,(long)srcoffset,(uint32_t)ramchain->H.scriptoffset,(uint32_t)ramchain->H.stacksize,(uint32_t)ramchain->H.scriptoffset); printf("smashed stack? dest.%ld vs src %ld offset.%u stacksize.%u space.%u\n",(long)destoffset,(long)srcoffset,(uint32_t)ramchain->H.scriptoffset,(uint32_t)ramchain->H.stacksize,(uint32_t)ramchain->H.scriptoffset);
} }
printf("%d SAVE: Koffset.%d scriptoffset.%d stacksize.%d allocsize.%d gap.%ld RO.%d\n",bp->bundleheight,(int32_t)ramchain->H.data->Koffset,ramchain->H.scriptoffset,ramchain->H.stacksize,(int32_t)ramchain->H.data->allocsize,(long)destoffset - (long)srcoffset,ramchain->H.ROflag); //printf("%d SAVE: Koffset.%d scriptoffset.%d stacksize.%d allocsize.%d gap.%ld RO.%d\n",bp->bundleheight,(int32_t)ramchain->H.data->Koffset,ramchain->H.scriptoffset,ramchain->H.stacksize,(int32_t)ramchain->H.data->allocsize,(long)destoffset - (long)srcoffset,ramchain->H.ROflag);
scriptspace = ramchain->H.data->scriptspace; scriptspace = ramchain->H.data->scriptspace;
scriptoffset = ramchain->H.scriptoffset; scriptoffset = ramchain->H.scriptoffset;
stacksize = ramchain->H.stacksize; stacksize = ramchain->H.stacksize;
@ -2181,7 +2181,7 @@ int32_t iguana_ramchain_expandedsave(struct iguana_info *coin,RAMCHAIN_FUNC,stru
} }
int32_t i; for (i=0; i<IGUANA_NUMLHASHES; i++) int32_t i; for (i=0; i<IGUANA_NUMLHASHES; i++)
printf("%08x ",mapchain->H.data->lhashes[i].uints[0]); printf("%08x ",mapchain->H.data->lhashes[i].uints[0]);
printf("%llx ht.%d bundlehashes\n",(long long)mapchain->H.data->sha256.txid,mapchain->height); printf("%llx ht.%d bundlehashes.%s\n",(long long)mapchain->H.data->sha256.txid,mapchain->height,coin->symbol);
iguana_ramchain_free(mapchain,cmpflag); iguana_ramchain_free(mapchain,cmpflag);
} }
iguana_mempurge(hashmem); iguana_mempurge(hashmem);

14
iguana/iguana_recv.c

@ -407,7 +407,7 @@ uint32_t iguana_allhashcmp(struct iguana_info *coin,struct iguana_bundle *bp,bit
prev = block; prev = block;
} }
coin->allhashes++; coin->allhashes++;
// if ( bp->hdrsi == 0 ) if ( bp->hdrsi == 0 )
printf("ALLHASHES FOUND! %d allhashes.%d\n",bp->bundleheight,coin->allhashes); printf("ALLHASHES FOUND! %d allhashes.%d\n",bp->bundleheight,coin->allhashes);
if ( bp->queued == 0 ) if ( bp->queued == 0 )
iguana_bundleQ(coin,bp,bp->n*5 + (rand() % 500)); iguana_bundleQ(coin,bp,bp->n*5 + (rand() % 500));
@ -585,7 +585,7 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct iguana_info *coin,struct
//iguana_blockQ(coin,0,-1,blockhashes[1],0); //iguana_blockQ(coin,0,-1,blockhashes[1],0);
//iguana_blockQ(coin,0,-4,blockhashes[1],1); //iguana_blockQ(coin,0,-4,blockhashes[1],1);
char str[65]; char str[65];
if ( num > 2 ) if ( 0 && num > 2 )
printf("blockhashes[%d] %d of %d %s bp.%d[%d]\n",num,bp==0?-1:bp->hdrsi,coin->bundlescount,bits256_str(str,blockhashes[1]),bp==0?-1:bp->bundleheight,bundlei); printf("blockhashes[%d] %d of %d %s bp.%d[%d]\n",num,bp==0?-1:bp->hdrsi,coin->bundlescount,bits256_str(str,blockhashes[1]),bp==0?-1:bp->bundleheight,bundlei);
if ( bp != 0 ) if ( bp != 0 )
{ {
@ -744,7 +744,7 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana
{ {
if ( bp->bundleheight+bundlei-1 >= coin->blocks.hwmchain.height ) if ( bp->bundleheight+bundlei-1 >= coin->blocks.hwmchain.height )
{ {
printf("prev issue.%s\n",bits256_str(str,prev->RO.hash2)); //printf("prev issue.%s\n",bits256_str(str,prev->RO.hash2));
iguana_blockQ("previssue",coin,bp,bundlei-1,prev->RO.hash2,0); iguana_blockQ("previssue",coin,bp,bundlei-1,prev->RO.hash2,0);
} }
} }
@ -774,7 +774,7 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana
{ {
if ( (prev= iguana_blockfind(coin,block->RO.prev_block)) == 0 ) if ( (prev= iguana_blockfind(coin,block->RO.prev_block)) == 0 )
prev = iguana_blockhashset(coin,-1,block->RO.prev_block,1); prev = iguana_blockhashset(coin,-1,block->RO.prev_block,1);
width = coin->chain->bundlesize; width = sqrt(coin->chain->bundlesize);
while ( prev != 0 && width-- > 0 ) while ( prev != 0 && width-- > 0 )
{ {
if ( prev->mainchain != 0 ) if ( prev->mainchain != 0 )
@ -1112,7 +1112,7 @@ int32_t iguana_reqhdrs(struct iguana_info *coin)
coin->numpendings++; coin->numpendings++;
init_hexbytes_noT(hashstr,bp->hashes[0].bytes,sizeof(bits256)); init_hexbytes_noT(hashstr,bp->hashes[0].bytes,sizeof(bits256));
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr),1); queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr),1);
printf("hdrsi.%d reqHDR.(%s) numhashes.%d\n",bp->hdrsi,hashstr,bp->numhashes); //printf("hdrsi.%d reqHDR.(%s) numhashes.%d\n",bp->hdrsi,hashstr,bp->numhashes);
if ( 1 ) if ( 1 )
{ {
iguana_blockQ("reqhdrs0",coin,bp,0,bp->hashes[0],0); iguana_blockQ("reqhdrs0",coin,bp,0,bp->hashes[0],0);
@ -1184,8 +1184,8 @@ int32_t iguana_blockQ(char *argstr,struct iguana_info *coin,struct iguana_bundle
req->height = height; req->height = height;
req->bundlei = bundlei; req->bundlei = bundlei;
char str2[65]; char str2[65];
if ( 0 && (bundlei % 250) == 0 ) //if ( 0 && (bundlei % 250) == 0 )
printf("%s %s [%d:%d] %d %s %d numranked.%d qsize.%d\n",argstr,str,bp!=0?bp->hdrsi:-1,bundlei,req->height,bits256_str(str2,hash2),coin->blocks.recvblocks,coin->peers.numranked,queue_size(Q)); printf("%s %s %s [%d:%d] %d %s %d numranked.%d qsize.%d\n",coin->symbol,argstr,str,bp!=0?bp->hdrsi:-1,bundlei,req->height,bits256_str(str2,hash2),coin->blocks.recvblocks,coin->peers.numranked,queue_size(Q));
if ( block != 0 ) if ( block != 0 )
{ {
block->numrequests++; block->numrequests++;

4
iguana/iguana_unspents.c

@ -480,8 +480,8 @@ int32_t iguana_balancegen(struct iguana_info *coin,struct iguana_bundle *bp)
errs++; errs++;
} }
printf(">>>>>>>> balances.%d done errs.%d spendind.%d\n",bp->hdrsi,errs,n); printf(">>>>>>>> balances.%d done errs.%d spendind.%d\n",bp->hdrsi,errs,n);
if ( errs == 0 ) //if ( errs == 0 )
bp->validated = (uint32_t)time(NULL); // bp->validated = (uint32_t)time(NULL);
return(-errs); return(-errs);
} }

65
iguana/main.c

@ -323,9 +323,60 @@ void sigalarm_func() { printf("\nSIGALRM\n"); signal(SIGALRM,sigalarm_func); }
void sigcontinue_func() { printf("\nSIGCONT\n"); signal(SIGCONT,sigcontinue_func); } void sigcontinue_func() { printf("\nSIGCONT\n"); signal(SIGCONT,sigcontinue_func); }
#endif #endif
int32_t iguana_balanceflush(struct iguana_info *coin,int32_t refhdrsi)
{
int32_t hdrsi,numpkinds; struct iguana_bundle *bp; char fname[1024],fname2[1024]; struct iguana_utxo *Uptr; struct iguana_account *Aptr;
memset(coin->bundlebits,0,sizeof(coin->bundlebits));
for (hdrsi=0; hdrsi<coin->bundlescount; hdrsi++)
if ( (bp= coin->bundles[hdrsi]) == 0 || bp->balancefinish <= 1 || bp->ramchain.H.data == 0 || bp->ramchain.A == 0 || bp->ramchain.Uextras == 0 )
break;
if ( hdrsi <= coin->balanceswritten || hdrsi < refhdrsi )
return(0);
refhdrsi = hdrsi;
for (hdrsi=0; hdrsi<refhdrsi; hdrsi++)
{
if ( (bp= coin->bundles[hdrsi]) != 0 && bp->ramchain.H.data != 0 && (numpkinds= bp->ramchain.H.data->numpkinds) > 0 && (Aptr= bp->ramchain.A) != 0 && (Uptr= bp->ramchain.Uextras) != 0 )
{
if ( 1 )//forceflag == 0 )
{
sprintf(fname,"accounts/%s/debits.%d",coin->symbol,bp->bundleheight);
sprintf(fname2,"accounts/%s/lastspends.%d",coin->symbol,bp->bundleheight);
}
else
{
sprintf(fname,"DB/%s/accounts/debits_%d.%d",coin->symbol,coin->bundlescount,bp->bundleheight);
sprintf(fname2,"DB/%s/accounts/lastspends_%d.%d",coin->symbol,coin->bundlescount,bp->bundleheight);
}
//printf("save (%s) and (%s) %p %p\n",fname,fname2,bp,bp->ramchain.H.data);//,bp->ramchain.H.data->numpkinds,bp->ramchain.H.data->numunspents);
/* if ( (fp= fopen(fname,"wb")) != 0 && (fp2= fopen(fname2,"wb")) != 0 )
{
if ( fwrite(&coin->bundlescount,1,sizeof(coin->bundlescount),fp) == sizeof(coin->bundlescount) && fwrite(&coin->bundlescount,1,sizeof(coin->bundlescount),fp2) == sizeof(coin->bundlescount) && fwrite(coin->bundlebits,1,blen,fp) == blen && fwrite(coin->bundlebits,1,blen,fp2) == blen )
{
if ( fwrite(bp->ramchain.A,sizeof(*bp->ramchain.A),bp->ramchain.H.data->numpkinds,fp) == bp->ramchain.H.data->numpkinds )
{
if ( fwrite(bp->ramchain.Uextras,sizeof(*bp->ramchain.Uextras),bp->ramchain.H.data->numunspents,fp2) == bp->ramchain.H.data->numunspents )
{
bp->dirty = 0;
printf("saved (%s) and (%s)\n",fname,fname2);
}
}
}
fclose(fp), fclose(fp2);
if ( bp->dirty != 0 )
printf("error writing %s\n",fname);
}
else if ( fp != 0 )
fclose(fp);*/
}
else return(-1);
}
coin->balanceswritten = refhdrsi + 1;
return(coin->balanceswritten);
}
void mainloop(struct supernet_info *myinfo) void mainloop(struct supernet_info *myinfo)
{ {
int32_t i,flag; struct iguana_info *coin; struct iguana_helper *ptr; struct iguana_bundle *bp,*prevbp = 0; int32_t i,j,flag; struct iguana_info *coin; struct iguana_helper *ptr; struct iguana_bundle *bp,*prevbp = 0;
sleep(3); sleep(3);
printf("mainloop\n"); printf("mainloop\n");
while ( 1 ) while ( 1 )
@ -341,11 +392,16 @@ void mainloop(struct supernet_info *myinfo)
{ {
if ( (bp= ptr->bp) != 0 && ptr->coin != 0 && (bp->hdrsi == 0 || (prevbp= coin->bundles[bp->hdrsi-1]) != 0) ) if ( (bp= ptr->bp) != 0 && ptr->coin != 0 && (bp->hdrsi == 0 || (prevbp= coin->bundles[bp->hdrsi-1]) != 0) )
{ {
if ( bp->utxofinish != 0 && bp->balancefinish <= 1 && (bp->hdrsi == 0 || (prevbp != 0 && prevbp->utxofinish > 1 && time(NULL) > prevbp->utxofinish+13)) ) for (j=0; j<bp->hdrsi; j++)
if ( (prevbp= coin->bundles[j]) == 0 || prevbp->emitfinish <= 1 )
break;
if ( bp->utxofinish > 1 && bp->balancefinish <= 1 && bp->hdrsi == j )
{ {
//printf("hdrsi.%d start balances.%d\n",bp->hdrsi,bp->bundleheight); //printf("hdrsi.%d start balances.%d\n",bp->hdrsi,bp->bundleheight);
iguana_balancecalc(ptr->coin,bp); iguana_balancecalc(ptr->coin,bp);
bp->queued = 0; bp->queued = 0;
iguana_balanceflush(ptr->coin,bp->hdrsi);
printf("flushed bp->hdrsi %d vs %d coin->longestchain/coin->chain->bundlesize\n",bp->hdrsi,coin->longestchain/coin->chain->bundlesize);
} }
else else
{ {
@ -353,11 +409,6 @@ void mainloop(struct supernet_info *myinfo)
coin->pendbalances--; coin->pendbalances--;
iguana_balancesQ(coin,bp); iguana_balancesQ(coin,bp);
} }
if ( bp->hdrsi == coin->longestchain/coin->chain->bundlesize )
{
//iguana_coinflush(ptr->coin,1);
printf("flushed bp->hdrsi %d == %d coin->longestchain/coin->chain->bundlesize\n",bp->hdrsi,coin->longestchain/coin->chain->bundlesize);
}
} }
myfree(ptr,ptr->allocsize); myfree(ptr,ptr->allocsize);
} }

Loading…
Cancel
Save