Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
6d89379a25
  1. 1
      iguana/iguana777.h
  2. 10
      iguana/iguana_bundles.c
  3. 28
      iguana/iguana_ramchain.c
  4. 58
      iguana/iguana_unspents.c
  5. 2
      iguana/main.c

1
iguana/iguana777.h

@ -473,6 +473,7 @@ struct iguana_info
portable_mutex_t scripts_mutex[2]; FILE *scriptsfp[2]; void *scriptsptr[2]; long scriptsfilesize[2]; portable_mutex_t scripts_mutex[2]; FILE *scriptsfp[2]; void *scriptsptr[2]; long scriptsfilesize[2];
//struct scriptinfo *scriptstable[2]; //struct scriptinfo *scriptstable[2];
struct iguana_bundle *bundles[IGUANA_MAXBUNDLES],*current,*lastpending; struct iguana_bundle *bundles[IGUANA_MAXBUNDLES],*current,*lastpending;
struct iguana_ramchain RTramchain;
int32_t numremain,numpendings,zcount,recvcount,bcount,pcount,lastbundle,numsaved,pendbalances,numverified; int32_t numremain,numpendings,zcount,recvcount,bcount,pcount,lastbundle,numsaved,pendbalances,numverified;
uint32_t recvtime,hdrstime,backstoptime,lastbundletime,numreqsent,numbundlesQ,lastbundleitime,lastdisp; uint32_t recvtime,hdrstime,backstoptime,lastbundletime,numreqsent,numbundlesQ,lastbundleitime,lastdisp;
double backstopmillis; bits256 backstophash2; int64_t spaceused; double backstopmillis; bits256 backstophash2; int64_t spaceused;

10
iguana/iguana_bundles.c

@ -542,7 +542,7 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int
iguana_blockQ("kicka",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("kickb",coin,bp,i,block->RO.hash2,0); } else iguana_blockQ("kickb",coin,bp,i,block->RO.hash2,now > block->issued+lag*3);
flag++; flag++;
} //else printf("%d ",now - block->issued); } //else printf("%d ",now - block->issued);
} }
@ -564,21 +564,19 @@ 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("kickc",coin,bp,i,block->RO.hash2,bp == coin->current); iguana_blockQ("kickc",coin,bp,i,block->RO.hash2,bp == coin->current || now > block->issued+lag*3);
bp->issued[i] = block->issued = now; bp->issued[i] = block->issued = now;
counter++; counter++;
if ( --max <= 0 ) if ( --max <= 0 )
break; break;
} }
//else if ( block->fpipbits != 0 && ((bp->hdrsi == 0 && i == 0) || bits256_nonz(block->RO.prev_block) != 0) )
// n++;
} }
} }
else if ( bits256_nonz(bp->hashes[i]) != 0 && now > bp->issued[i]+lag ) else if ( bits256_nonz(bp->hashes[i]) != 0 && now > bp->issued[i]+lag )
{ {
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("kickd",coin,bp,i,bp->hashes[i],bp == coin->current); iguana_blockQ("kickd",coin,bp,i,bp->hashes[i],bp == coin->current || now > bp->issued[i]+lag*3);
bp->issued[i] = now; bp->issued[i] = now;
counter++; counter++;
} }
@ -1042,7 +1040,7 @@ void iguana_bundlestats(struct iguana_info *coin,char *str)
coin->spaceused = spaceused; coin->spaceused = spaceused;
coin->numverified = numv; coin->numverified = numv;
char str4[65],str5[65]; char str4[65],str5[65];
sprintf(str,"%s u.%d b.%d v.%d/%d (%d 1st.%d) to %d N[%d] Q.%d h.%d r.%d c.%s s.%d d.%d E.%d:%d est.%d %s %d:%02d:%02d %03.3f peers.%d/%d Q.(%d %d) L.%d [%d:%d] M.%d %s",coin->symbol,numutxo,numbalances,numv,coin->pendbalances,firstgap!=0?firstgap->numsaved:-1,firstgap!=0?firstgap->hdrsi:-1,coin->lastpending!=0?coin->lastpending->hdrsi:0,count,coin->numbundlesQ,numhashes,coin->blocksrecv,mbstr(str4,spaceused),numsaved,done,numemit,coin->numreqsent,coin->MAXBUNDLES,mbstr(str2,estsize),(int32_t)difft.x/3600,(int32_t)(difft.x/60)%60,(int32_t)difft.x%60,difft.millis,p,coin->MAXPEERS,queue_size(&coin->priorityQ),queue_size(&coin->blocksQ),coin->longestchain,coin->blocks.hwmchain.height/coin->chain->bundlesize,coin->blocks.hwmchain.height%coin->chain->bundlesize,coin->blocks.hwmchain.height,bits256_str(str5,coin->blocks.hwmchain.RO.hash2)); sprintf(str,"%s u.%d b.%d v.%d/%d (%d/%d 1st.%d) to %d N[%d] Q.%d h.%d r.%d c.%s s.%d d.%d E.%d:%d est.%d %s %d:%02d:%02d %03.3f peers.%d/%d Q.(%d %d) L.%d [%d:%d] M.%d %s",coin->symbol,numutxo,numbalances,numv,coin->pendbalances,firstgap!=0?firstgap->numsaved:-1,firstgap!=0?firstgap->numhashes:-1,firstgap!=0?firstgap->hdrsi:-1,coin->lastpending!=0?coin->lastpending->hdrsi:0,count,coin->numbundlesQ,numhashes,coin->blocksrecv,mbstr(str4,spaceused),numsaved,done,numemit,coin->numreqsent,coin->MAXBUNDLES,mbstr(str2,estsize),(int32_t)difft.x/3600,(int32_t)(difft.x/60)%60,(int32_t)difft.x%60,difft.millis,p,coin->MAXPEERS,queue_size(&coin->priorityQ),queue_size(&coin->blocksQ),coin->longestchain,coin->blocks.hwmchain.height/coin->chain->bundlesize,coin->blocks.hwmchain.height%coin->chain->bundlesize,coin->blocks.hwmchain.height,bits256_str(str5,coin->blocks.hwmchain.RO.hash2));
//sprintf(str+strlen(str),"%s.%-2d %s time %.2f files.%d Q.%d %d\n",coin->symbol,flag,str,(double)(time(NULL)-coin->starttime)/60.,coin->peers.numfiles,queue_size(&coin->priorityQ),queue_size(&coin->blocksQ)); //sprintf(str+strlen(str),"%s.%-2d %s time %.2f files.%d Q.%d %d\n",coin->symbol,flag,str,(double)(time(NULL)-coin->starttime)/60.,coin->peers.numfiles,queue_size(&coin->priorityQ),queue_size(&coin->blocksQ));
if ( time(NULL) > coin->lastdisp+10 ) if ( time(NULL) > coin->lastdisp+10 )
{ {

28
iguana/iguana_ramchain.c

@ -2279,17 +2279,27 @@ struct iguana_ramchain *iguana_bundleload(struct iguana_info *coin,struct iguana
} }
/*{ int64_t iguana_ramchainopen(struct iguana_info *coin,struct iguana_ramchain *ramchain,struct OS_memspace *mem,struct OS_memspace *hashmem,int32_t bundleheight,bits256 hash2)
RAMCHAIN_DESTDECLARE; RAMCHAIN_DECLARE; {
if ( iguana_ramchain_alloc(coin,dest,mem,&HASHMEM,numtxids,numunspents,numspends,numpkinds,numexternaltxids,scriptspace+sigspace,bp->bundleheight+starti,bp_n) == 0 ) RAMCHAIN_DECLARE; int32_t i,numblocks = 0; uint32_t numtxids,numunspents,numspends,numpkinds,numexternaltxids,scriptspace; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata;
mem->alignflag = sizeof(uint32_t);
hashmem->alignflag = sizeof(uint32_t);
scriptspace = numexternaltxids = numtxids = coin->chain->bundlesize * 2;
numunspents = numspends = numpkinds = numtxids * 2;
for (i=0; i<coin->bundlescount; i++)
if ( (bp= coin->bundles[i]) != 0 && (rdata= bp->ramchain.H.data) != 0 )
{
}
if ( iguana_ramchain_init(ramchain,mem,hashmem,1,numtxids,numunspents,numspends,numpkinds,numexternaltxids,scriptspace,1,numblocks) > 0 )
{ {
iguana_ramchain_link(dest,bp->hashes[starti],bp->hashes[endi],bp->hdrsi,bp->bundleheight,0,bp->n,firsti,0); iguana_ramchain_link(ramchain,hash2,hash2,bundleheight/coin->chain->bundlesize,bundleheight,0,0,1,0);
dest->expanded = 1; ramchain->expanded = 1;
dest->H.scriptoffset = 1; ramchain->H.scriptoffset = 1;
_iguana_ramchain_setptrs(RAMCHAIN_DESTPTRS,dest->H.data); _iguana_ramchain_setptrs(RAMCHAIN_PTRS,ramchain->H.data);
iguana_ramchain_extras(coin,dest,&HASHMEM,0); iguana_ramchain_extras(coin,ramchain,hashmem,0);
} }
}*/ return(rdata->allocsize);
}
// helper threads: NUM_HELPERS // helper threads: NUM_HELPERS
int32_t iguana_bundlesaveHT(struct iguana_info *coin,struct OS_memspace *mem,struct OS_memspace *memB,struct iguana_bundle *bp,uint32_t starttime) // helper thread int32_t iguana_bundlesaveHT(struct iguana_info *coin,struct OS_memspace *mem,struct OS_memspace *memB,struct iguana_bundle *bp,uint32_t starttime) // helper thread

58
iguana/iguana_unspents.c

@ -108,15 +108,20 @@ int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struc
} }
else else
{ {
utxo = &Uextras[unspentind]; if ( 1 )
if ( utxo->spentflag == 0 ) flag = iguana_utxoupdate(coin,spentbp->hdrsi,unspentind,pkind,u->value,bp->hdrsi,spendind,height);
else
{ {
utxo->prevunspentind = A2[pkind].lastind; utxo = &Uextras[unspentind];
utxo->spentflag = 1; if ( utxo->spentflag == 0 )
utxo->height = height; {
A2[pkind].total += u->value; utxo->prevunspentind = A2[pkind].lastind;
A2[pkind].lastind = unspentind; utxo->spentflag = 1;
flag = 0; utxo->height = height;
A2[pkind].total += u->value;
A2[pkind].lastind = unspentind;
flag = 0;
}
} }
} }
} }
@ -616,15 +621,6 @@ int32_t iguana_balancegen(struct iguana_info *coin,struct iguana_bundle *bp,int3
return(-errs); return(-errs);
} }
void iguana_realtime_update(struct iguana_info *coin)
{
struct iguana_bundle *bp;
if ( (bp= coin->current) != 0 && bp->hdrsi == coin->longestchain/coin->chain->bundlesize && bp->hdrsi == coin->balanceswritten )
{
}
}
void iguana_purgevolatiles(struct iguana_info *coin,struct iguana_ramchain *ramchain) void iguana_purgevolatiles(struct iguana_info *coin,struct iguana_ramchain *ramchain)
{ {
if ( ramchain->allocatedA != 0 && ramchain->A != 0 ) if ( ramchain->allocatedA != 0 && ramchain->A != 0 )
@ -723,14 +719,13 @@ void iguana_allocvolatile(struct iguana_info *coin,struct iguana_ramchain *ramch
void iguana_truncatebalances(struct iguana_info *coin) void iguana_truncatebalances(struct iguana_info *coin)
{ {
int32_t i; struct iguana_bundle *bp; struct iguana_ramchain *ramchain; int32_t i; struct iguana_bundle *bp;
for (i=0; i<coin->balanceswritten; i++) for (i=0; i<coin->balanceswritten; i++)
{ {
if ( (bp= coin->bundles[i]) != 0 ) if ( (bp= coin->bundles[i]) != 0 )
{ {
bp->balancefinish = 0; bp->balancefinish = 0;
ramchain = &bp->ramchain; iguana_purgevolatiles(coin,&bp->ramchain);
iguana_purgevolatiles(coin,ramchain);
} }
} }
coin->balanceswritten = 0; coin->balanceswritten = 0;
@ -816,6 +811,28 @@ int32_t iguana_volatileinit(struct iguana_info *coin)
return(coin->balanceswritten); return(coin->balanceswritten);
} }
void iguana_RTramchainfree(struct iguana_info *coin)
{
}
void iguana_RTramchainalloc(struct iguana_info *coin)
{
if ( coin->RTramchain.H.data == 0 )
{
}
}
void iguana_realtime_update(struct iguana_info *coin)
{
struct iguana_bundle *bp;
if ( (bp= coin->current) != 0 && bp->hdrsi == coin->longestchain/coin->chain->bundlesize && bp->hdrsi == coin->balanceswritten )
{
iguana_RTramchainalloc(coin);
}
}
int32_t iguana_balanceflush(struct iguana_info *coin,int32_t refhdrsi,int32_t purgedist) int32_t iguana_balanceflush(struct iguana_info *coin,int32_t refhdrsi,int32_t purgedist)
{ {
int32_t hdrsi,numpkinds,iter,numhdrsi,numunspents,err; struct iguana_bundle *bp; int32_t hdrsi,numpkinds,iter,numhdrsi,numunspents,err; struct iguana_bundle *bp;
@ -935,6 +952,7 @@ int32_t iguana_balanceflush(struct iguana_info *coin,int32_t refhdrsi,int32_t pu
char str[65]; printf("BALANCES WRITTEN for %d bundles %s\n",coin->balanceswritten,bits256_str(str,coin->balancehash)); char str[65]; printf("BALANCES WRITTEN for %d bundles %s\n",coin->balanceswritten,bits256_str(str,coin->balancehash));
coin->balanceswritten = iguana_volatileinit(coin); coin->balanceswritten = iguana_volatileinit(coin);
iguana_utxoupdate(coin,-1,0,0,0,-1,0,-1); // free hashtables iguana_utxoupdate(coin,-1,0,0,0,-1,0,-1); // free hashtables
iguana_RTramchainfree(coin);
return(coin->balanceswritten); return(coin->balanceswritten);
} }

2
iguana/main.c

@ -1128,7 +1128,7 @@ void iguana_main(void *arg)
sleep(1); sleep(1);
char *str; char *str;
//iguana_launchcoin(MYINFO.rpcsymbol,cJSON_Parse("{}")); //iguana_launchcoin(MYINFO.rpcsymbol,cJSON_Parse("{}"));
if ( 1 && (str= SuperNET_JSON(&MYINFO,cJSON_Parse("{\"startpend\":3333,\"endpend\":3333,\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":129,\"maxpeers\":256,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":4,\"poll\":1}"),0)) != 0 ) if ( 1 && (str= SuperNET_JSON(&MYINFO,cJSON_Parse("{\"startpend\":128,\"endpend\":128,\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":129,\"maxpeers\":128,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":4,\"poll\":1}"),0)) != 0 )
{ {
free(str); free(str);
if ( 0 && (str= SuperNET_JSON(&MYINFO,cJSON_Parse("{\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":1024,\"maxpeers\":256,\"newcoin\":\"BTCD\",\"active\":1}"),0)) != 0 ) if ( 0 && (str= SuperNET_JSON(&MYINFO,cJSON_Parse("{\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":1024,\"maxpeers\":256,\"newcoin\":\"BTCD\",\"active\":1}"),0)) != 0 )

Loading…
Cancel
Save