Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
03dcd33e90
  1. 19
      iguana/iguana777.c
  2. 2
      iguana/iguana_blocks.c
  3. 37
      iguana/iguana_bundles.c
  4. 13
      iguana/iguana_init.c
  5. 4
      iguana/iguana_peers.c
  6. 2
      iguana/iguana_ramchain.c
  7. 9
      iguana/iguana_recv.c
  8. 2
      iguana/iguana_unspents.c

19
iguana/iguana777.c

@ -97,7 +97,7 @@ void iguana_recvalloc(struct iguana_info *coin,int32_t numitems)
{
//coin->blocks.ptrs = myrealloc('W',coin->blocks.ptrs,coin->blocks.ptrs==0?0:coin->blocks.maxbits * sizeof(*coin->blocks.ptrs),numitems * sizeof(*coin->blocks.ptrs));
coin->blocks.RO = myrealloc('W',coin->blocks.RO,coin->blocks.RO==0?0:coin->blocks.maxbits * sizeof(*coin->blocks.RO),numitems * sizeof(*coin->blocks.RO));
printf("realloc waitingbits.%d -> %d\n",coin->blocks.maxbits,numitems);
//printf("realloc waitingbits.%d -> %d\n",coin->blocks.maxbits,numitems);
coin->blocks.maxbits = numitems;
}
@ -208,7 +208,7 @@ void *iguana_kviAddriterator(struct iguana_info *coin,struct iguanakv *kv,struct
uint32_t iguana_updatemetrics(struct iguana_info *coin)
{
char fname[512],tmpfname[512],oldfname[512]; int32_t i; struct iguana_peer *addr; FILE *fp;
char fname[512],tmpfname[512],oldfname[512],ipaddr[64]; int32_t i,j; struct iguana_peer *addr,*tmpaddr; FILE *fp;
iguana_peermetrics(coin);
sprintf(fname,"confs/%s_peers.txt",coin->symbol), OS_compatible_path(fname);
sprintf(oldfname,"confs/%s_oldpeers.txt",coin->symbol), OS_compatible_path(oldfname);
@ -216,8 +216,21 @@ uint32_t iguana_updatemetrics(struct iguana_info *coin)
if ( (fp= fopen(tmpfname,"w")) != 0 )
{
for (i=0; i<coin->peers.numranked; i++)
{
if ( (addr= coin->peers.ranked[i]) != 0 && addr->relayflag != 0 && strcmp(addr->ipaddr,"127.0.0.1") != 0 )
fprintf(fp,"%s\n",addr->ipaddr);
{
for (j=0; j<coin->peers.numranked; j++)
{
if ( i != 0 && (tmpaddr= coin->peers.ranked[j]) != 0 && (uint32_t)addr->ipbits == (uint32_t)tmpaddr->ipbits )
break;
}
if ( j == coin->peers.numranked )
{
expand_ipbits(ipaddr,(uint32_t)addr->ipbits);
fprintf(fp,"%s\n",ipaddr);
}
}
}
if ( ftell(fp) > OS_filesize(fname) )
{
printf("new peers.txt %ld vs (%s) %ld\n",ftell(fp),fname,(long)OS_filesize(fname));

2
iguana/iguana_blocks.c

@ -341,7 +341,7 @@ struct iguana_block *_iguana_chainlink(struct iguana_info *coin,struct iguana_bl
bp = iguana_bundlecreate(coin,&bundlei,block->height,block->RO.hash2,zero,0);
if ( bp != 0 && bp->hdrsi == coin->bundlescount-1 )
{
printf("created last bundle ht.%d\n",bp->bundleheight);
//printf("created last bundle ht.%d\n",bp->bundleheight);
iguana_blockreq(coin,block->height,1);
}
}

37
iguana/iguana_bundles.c

@ -284,7 +284,7 @@ struct iguana_bundle *iguana_bundlecreate(struct iguana_info *coin,int32_t *bund
}
bp = mycalloc('b',1,sizeof(*bp));
bp->n = coin->chain->bundlesize;
bp->hdrsi = coin->bundlescount;
bp->hdrsi = bundleheight / coin->chain->bundlesize;
bp->bundleheight = bundleheight;
bp->allhash = allhash;
iguana_hash2set(coin,"create",bp,0,bundlehash2);
@ -292,9 +292,9 @@ struct iguana_bundle *iguana_bundlecreate(struct iguana_info *coin,int32_t *bund
{
bp->coin = coin;
bp->avetime = coin->avetime * 2.;
coin->bundles[coin->bundlescount] = bp;
if ( coin->bundlescount > 0 )
coin->bundles[coin->bundlescount-1]->nextbp = bp;
coin->bundles[bp->hdrsi] = bp;
if ( bp->hdrsi > 0 && coin->bundles[bp->hdrsi-1] != 0 )
coin->bundles[bp->hdrsi-1]->nextbp = bp;
*bundleip = 0;
bits256_str(str,bundlehash2);
sprintf(dirname,"%s/%s/%d",GLOBALTMPDIR,coin->symbol,bp->bundleheight), OS_ensure_directory(dirname);
@ -305,7 +305,8 @@ struct iguana_bundle *iguana_bundlecreate(struct iguana_info *coin,int32_t *bund
iguana_blockQ("bundlecreate",coin,bp,0,bundlehash2,1);
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(str),1);
}
coin->bundlescount++;
if ( bp->hdrsi >= coin->bundlescount )
coin->bundlescount = (bp->hdrsi + 1);
}
else
{
@ -586,9 +587,9 @@ int32_t iguana_bundlehdr(struct iguana_info *coin,struct iguana_bundle *bp,int32
int32_t iguana_bundlefinish(struct iguana_info *coin,struct iguana_bundle *bp)
{
struct iguana_bundle *prevbp;
if ( bp->hdrsi == 0 || ((prevbp= coin->bundles[bp->hdrsi-1]) != 0 && coin->current != 0 && coin->current->hdrsi >= prevbp->hdrsi && prevbp->emitfinish > coin->startutc && time(NULL) > prevbp->emitfinish+3) )
//printf("postfinish.%d startutxo.%u prevbp.%p current.%p\n",bp->hdrsi,bp->startutxo,coin->bundles[bp->hdrsi-1],coin->current);
if ( bp->hdrsi == 0 || ((prevbp= coin->bundles[bp->hdrsi-1]) != 0 && coin->current != 0 && coin->current->hdrsi >= prevbp->hdrsi && prevbp->emitfinish > 1 && time(NULL) > prevbp->emitfinish+3) )
{
//printf("postfinish.%d startutxo.%u prevbp.%p current.%p\n",bp->hdrsi,bp->startutxo,coin->bundles[bp->hdrsi-1],coin->current);
if ( bp->startutxo == 0 )
{
bp->startutxo = (uint32_t)time(NULL);
@ -599,8 +600,9 @@ int32_t iguana_bundlefinish(struct iguana_info *coin,struct iguana_bundle *bp)
}
else printf("UTXO gen.[%d] error\n",bp->hdrsi);
}
if ( bp->utxofinish != 0 && bp->balancefinish == 0 && (bp->hdrsi == 0 || (prevbp != 0 && prevbp->balancefinish != 0)) )
if ( bp->utxofinish != 0 && bp->balancefinish == 0 && (bp->hdrsi == 0 || (prevbp != 0 && prevbp->utxofinish != 0)) )
{
printf("start balances.%d\n",bp->bundleheight);
iguana_balancesQ(coin,bp);
return(-1);
}
@ -713,10 +715,15 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct iguana_bundle *bp,int
lasti = lastbp == 0 ? coin->bundlescount-1 : lastbp->hdrsi;
coin->numbundlesQ--;
iguana_bundlecalcs(coin,bp);
//printf("ITERATE.%d bundle.%d h.%d n.%d r.%d s.%d F.%d T.%d counter.%d\n",bp->rank,bp->bundleheight/coin->chain->bundlesize,bp->numhashes,bp->n,bp->numrecv,bp->numsaved,bp->emitfinish,timelimit,counter);
bp->nexttime = (uint32_t)time(NULL) + 1;
if ( bp->numhashes < bp->n && bp->bundleheight < coin->longestchain-coin->chain->bundlesize )
iguana_bundlehdr(coin,bp,starti);
else if ( bp->emitfinish > coin->startutc && (retval= iguana_bundlefinish(coin,bp)) < 0 )
else if ( bp->emitfinish > 1 && (retval= iguana_bundlefinish(coin,bp)) < 0 )
{
printf("terminate bundleiters.%d\n",bp->bundleheight);
return(0);
}
else if ( bp->emitfinish == 0 && bp->numsaved >= bp->n )
{
if ( iguana_bundleready(coin,bp) == bp->n )
@ -737,10 +744,10 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct iguana_bundle *bp,int
else if ( max < 10 )
max = 10;*/
counter = iguana_bundleissue(coin,bp,max,timelimit);
if ( counter > 0 )
if ( 0 && counter > 0 )
printf("ITERATE.%d max.%d bundle.%d h.%d n.%d r.%d s.%d F.%d T.%d counter.%d\n",bp->rank,max,bp->bundleheight/coin->chain->bundlesize,bp->numhashes,bp->n,bp->numrecv,bp->numsaved,bp->emitfinish,timelimit,counter);
}
bp->nexttime = (uint32_t)time(NULL) + 1;
} else if ( bp->emitfinish > 1 )
bp->nexttime = (uint32_t)time(NULL) - 1;
iguana_bundleQ(coin,bp,1000);
return(retval);
}
@ -789,7 +796,7 @@ void iguana_bundlestats(struct iguana_info *coin,char *str)
numsaved += bp->numsaved;
if ( bp->validated != 0 )
numv++;
if ( bp->emitfinish > coin->startutc )
if ( bp->emitfinish > 1 )
{
done++;
numemit++;
@ -856,8 +863,8 @@ void iguana_bundlestats(struct iguana_info *coin,char *str)
if ( (rand() % 100) == 0 )
myallocated(0,0);
lastdisp = (uint32_t)time(NULL);
if ( firstgap != 0 && firstgap->queued == 0 )
iguana_bundleQ(coin,firstgap,1000);
//if ( firstgap != 0 && firstgap->queued == 0 )
// iguana_bundleQ(coin,firstgap,1000);
}
strcpy(coin->statusstr,str);
coin->estsize = estsize;

13
iguana/iguana_init.c

@ -228,13 +228,13 @@ void iguana_parseline(struct iguana_info *coin,int32_t iter,FILE *fp)
{
addr = &coin->peers.active[m++];
iguana_initpeer(coin,addr,(uint32_t)calc_ipbits("127.0.0.1"));
printf("call initpeer.(%s)\n",addr->ipaddr);
//printf("call initpeer.(%s)\n",addr->ipaddr);
iguana_launch(coin,"connection",iguana_startconnection,addr,IGUANA_CONNTHREAD);
}
#ifndef IGUANA_DISABLEPEERS
addr = &coin->peers.active[m++];
iguana_initpeer(coin,addr,(uint32_t)calc_ipbits(line));
printf("call initpeer.(%s)\n",addr->ipaddr);
//printf("call initpeer.(%s)\n",addr->ipaddr);
iguana_launch(coin,"connection",iguana_startconnection,addr,IGUANA_CONNTHREAD);
#endif
}
@ -266,13 +266,17 @@ void iguana_parseline(struct iguana_info *coin,int32_t iter,FILE *fp)
if ( (bp= iguana_bundlecreate(coin,&bundlei,height,hash2,allhash,0)) != 0 )
{
bp->bundleheight = height;
if ( height == 0 && coin->current == 0 )
coin->current = coin->bundles[0] = bp;
lastbundle = hash2;
if ( (block= iguana_blockfind(coin,hash2)) != 0 )
block->mainchain = 1, block->height = height;
if ( iguana_bundleload(coin,&bp->ramchain,bp,2) != 0 )
{
bp->emitfinish = (uint32_t)time(NULL) + 1;
//printf("LOADED bundle.%d\n",bp->bundleheight);
if ( coin->current != 0 && coin->current->hdrsi+1 == bp->hdrsi )
coin->current = bp;
//printf("LOADED bundle.%d %p current %p\n",bp->bundleheight,bp,coin->current);
//if ( bp->hdrsi == 0 || coin->bundles[bp->hdrsi-1]->emitfinish != 0 )
{
//bp->startutxo = (uint32_t)time(NULL);
@ -307,10 +311,13 @@ void iguana_parseline(struct iguana_info *coin,int32_t iter,FILE *fp)
for (i=0; i<coin->bundlescount; i++)
if ( coin->bundles[i] == 0 )
break;
printf("INIT bundles i.%d\n",i);
if ( i > 0 )
{
//iguana_spentsfile(coin,i);
}
char buf[1024];
iguana_bundlestats(coin,buf);
}
}

4
iguana/iguana_peers.c

@ -604,7 +604,7 @@ void iguana_startconnection(void *arg)
if ( addr->usock < 0 || coin->peers.shuttingdown != 0 )
{
strcpy(ipaddr,addr->ipaddr);
printf("refused PEER KILLED. slot.%d for %s:%d usock.%d\n",addr->addrind,ipaddr,coin->chain->portp2p,addr->usock);
//printf("refused PEER KILLED. slot.%d for %s:%d usock.%d\n",addr->addrind,ipaddr,coin->chain->portp2p,addr->usock);
iguana_iAkill(coin,addr,1);
}
else
@ -969,7 +969,7 @@ void iguana_dedicatedloop(struct iguana_info *coin,struct iguana_peer *addr)
else addr->vinsfp = fopen(fname,"wb+");
//addr->pubkey = GENESIS_PUBKEY;
vcalc_sha256(0,addr->iphash.bytes,(uint8_t *)&ipbits,sizeof(ipbits));
char str[65]; printf("start dedicatedloop.%s addrind.%d %s\n",addr->ipaddr,addr->addrind,bits256_str(str,addr->iphash));
//char str[65]; printf("start dedicatedloop.%s addrind.%d %s\n",addr->ipaddr,addr->addrind,bits256_str(str,addr->iphash));
addr->maxfilehash2 = IGUANA_MAXFILEITEMS;
bufsize = IGUANA_MAXPACKETSIZE;
buf = mycalloc('r',1,bufsize);

2
iguana/iguana_ramchain.c

@ -1325,7 +1325,7 @@ void iguana_ramchain_extras(struct iguana_info *coin,struct iguana_ramchain *ram
//if ( ramchain->Uextras == 0 )
ramchain->Uextras = myaligned_alloc(sizeof(*ramchain->Uextras) * ramchain->H.data->numunspents);
}
printf("ALLOC RAMCHAIN A.%p Uextras.%p | extraflag.%d hashmem.%p\n",ramchain->A,ramchain->Uextras,extraflag,ramchain->hashmem);
//printf("ALLOC RAMCHAIN A.%p Uextras.%p | extraflag.%d hashmem.%p\n",ramchain->A,ramchain->Uextras,extraflag,ramchain->hashmem);
}
//printf("hashmem.%p A allocated.%p numpkinds.%d %ld\n",hashmem,ramchain->A,ramchain->H.data->numpkinds,sizeof(struct iguana_account)*ramchain->H.data->numpkinds);
//ramchain->P2 = (hashmem != 0) ? iguana_memalloc(hashmem,sizeof(struct iguana_pkextra) * ramchain->H.data->numpkinds,1) : mycalloc('2',ramchain->H.data->numpkinds,sizeof(struct iguana_pkextra));

9
iguana/iguana_recv.c

@ -397,7 +397,8 @@ uint32_t iguana_allhashcmp(struct iguana_info *coin,struct iguana_bundle *bp,bit
coin->allhashes++;
// if ( bp->hdrsi == 0 )
printf("ALLHASHES FOUND! %d allhashes.%d\n",bp->bundleheight,coin->allhashes);
iguana_bundleQ(coin,bp,bp->n*5 + (rand() % 500));
if ( bp->queued == 0 )
iguana_bundleQ(coin,bp,bp->n*5 + (rand() % 500));
return(bp->queued);
}
}
@ -476,7 +477,8 @@ struct iguana_bundle *iguana_bundleset(struct iguana_info *coin,struct iguana_bl
{
printf("AUTOCREATE.%d\n",prevbp->bundleheight + coin->chain->bundlesize);
bp = iguana_bundlecreate(coin,bundleip,prevbp->bundleheight + coin->chain->bundlesize,hash2,zero,0);
iguana_bundleQ(coin,bp,1000);
if ( bp->queued == 0 )
iguana_bundleQ(coin,bp,1000);
}
if ( prevbundlei < coin->chain->bundlesize-1 )
{
@ -589,7 +591,8 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct iguana_info *coin,struct
{
char str2[65];
printf("EXTEND last bundle %s/%s ht.%d\n",bits256_str(str,bp->hashes[0]),bits256_str(str2,blockhashes[coin->chain->bundlesize]),bp->bundleheight);
iguana_bundleQ(coin,bp,1000);
if ( bp->queued == 0 )
iguana_bundleQ(coin,bp,1000);
}
}
else if ( iguana_allhashcmp(coin,bp,blockhashes,num) > 0 )

2
iguana/iguana_unspents.c

@ -253,7 +253,7 @@ int32_t iguana_utxogen(struct iguana_info *coin,struct iguana_bundle *bp)
numtxid = 1;
if ( ramchain->Xspendinds != 0 )
{
//printf("iguana_utxogen: already have Xspendinds[%d]\n",ramchain->numXspends);
printf("iguana_utxogen: already have Xspendinds[%d]\n",ramchain->numXspends);
return(0);
}
ptr = mycalloc('x',sizeof(*ptr),n);

Loading…
Cancel
Save