Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
8d6a7bfa75
  1. 12
      iguana/iguana777.c
  2. 4
      iguana/iguana777.h
  3. 12
      iguana/iguana_bundles.c
  4. 1
      iguana/iguana_init.c
  5. 36
      iguana/iguana_recv.c
  6. 2
      iguana/main.c

12
iguana/iguana777.c

@ -583,8 +583,6 @@ struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers,
coin->MAXRECVCACHE = IGUANA_MAXRECVCACHE;
if ( (coin->MAXPENDING= maxpending) <= 0 )
coin->MAXPENDING = (strcmp(symbol,"BTC") == 0) ? _IGUANA_MAXPENDING : 64*_IGUANA_MAXPENDING;
if ( (coin->MAXBUNDLES= maxbundles) <= 0 )
coin->MAXBUNDLES = (strcmp(symbol,"BTC") == 0) ? IGUANA_MAXPENDBUNDLES : IGUANA_MAXPENDBUNDLES * 64;
coin->myservices = services;
printf("ensure directories\n");
sprintf(dirname,"accounts/%s",symbol), OS_ensure_directory(dirname);
@ -596,6 +594,16 @@ struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers,
sprintf(dirname,"%s/%s",GLOBALTMPDIR,symbol), OS_ensure_directory(dirname);
coin->initialheight = initialheight;
coin->mapflags = mapflags;
if ( (coin->startPEND= juint(json,"startpend")) == 0 )
coin->startPEND = IGUANA_MAXPENDBUNDLES;
else if ( coin->startPEND > 128 )
coin->startPEND = 128;
coin->MAXBUNDLES = coin->startPEND;
if ( (coin->endPEND= juint(json,"endpend")) == 0 )
coin->endPEND = IGUANA_MINPENDBUNDLES;
else if ( coin->endPEND > 128 )
coin->endPEND = 128;
coin->enableCACHE = juint(json,"cache");
coin->MAXMEM = juint(json,"RAM");
if ( coin->MAXMEM == 0 )
coin->MAXMEM = IGUANA_DEFAULTRAM;

4
iguana/iguana777.h

@ -280,7 +280,7 @@ struct iguana_block
double PoW; // NOT consensus safe, for estimation purposes only
int32_t height; uint32_t fpipbits,numrequests,issued; long fpos;
uint16_t hdrsi,bundlei:12,mainchain:1,valid:1,queued:1,txvalid:1,peerid:8;
UT_hash_handle hh; bits256 *blockhashes;
UT_hash_handle hh; bits256 *blockhashes; struct iguana_bundlereq *req;
};// __attribute__((packed));
@ -451,7 +451,7 @@ struct iguana_info
struct iguana_peers peers;
uint64_t instance_nonce,myservices,totalsize,totalrecv,totalpackets,sleeptime;
int64_t mining,totalfees,TMPallocated,MAXRECVCACHE,MAXMEM,estsize,activebundles;
int32_t MAXPEERS,MAXPENDING,MAXBUNDLES,active,closestbundle,numemitted,lastsweep,startutc,newramchain,numcached,cachefreed,helperdepth;
int32_t MAXPEERS,MAXPENDING,MAXBUNDLES,active,closestbundle,numemitted,lastsweep,startutc,newramchain,numcached,cachefreed,helperdepth,startPEND,endPEND,enableCACHE;
uint32_t longestchain,lastsync,parsetime,numiAddrs,firstblock,lastpossible,bundlescount,savedblocks;
struct tai starttime; double startmillis;
struct iguana_chain *chain;

12
iguana/iguana_bundles.c

@ -378,7 +378,7 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int
if ( coin->current != 0 )
starti = coin->current->hdrsi;
else starti = 0;
priority = (bp->hdrsi < starti+8);
priority = 1;//(bp->hdrsi < starti+8);
lag = (bp->hdrsi - starti);
lag *= lag;
if ( (i= sqrt(bp->hdrsi)) < 2 )
@ -516,14 +516,14 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int
//if ( (addr= coin->peers.ranked[rand() % numpeers]) != 0 )
// iguana_sendblockreqPT(coin,addr,bp,i,block->RO.hash2,0);
iguana_blockQ("kick",coin,bp,i,block->RO.hash2,bp == coin->current && now > block->issued+lag*10);
printf("[%d:%d] ",bp->hdrsi,i);
//printf("[%d:%d] ",bp->hdrsi,i);
} else iguana_blockQ("kick",coin,bp,i,block->RO.hash2,0);
flag++;
} //else printf("%d ",now - block->issued);
}
}
if ( flag != 0 && priority != 0 && laggard != 0 )
printf("currentflag.%d ht.%d s.%d finished.%d most.%d laggards.%d maxunfinished.%d\n",bp->currentflag,bp->bundleheight,bp->numsaved,finished,doneval,laggard,maxval);
printf("reissued.%d currentflag.%d ht.%d s.%d finished.%d most.%d laggards.%d maxunfinished.%d\n",flag,bp->currentflag,bp->bundleheight,bp->numsaved,finished,doneval,laggard,maxval);
}
}
if ( bp == coin->current )
@ -591,11 +591,11 @@ int32_t iguana_bundletweak(struct iguana_info *coin,struct iguana_bundle *bp)
coin->current = coin->bundles[bp->hdrsi+1];
if ( (lastbp= coin->lastpending) != 0 && lastbp->hdrsi < coin->bundlescount-1 )
coin->lastpending = coin->bundles[lastbp->hdrsi + 1];
if ( (rand() % 2) == 0 )
if ( (rand() % 3) == 0 )
{
if ( coin->MAXBUNDLES > IGUANA_MINPENDBUNDLES )
if ( coin->MAXBUNDLES > coin->endPEND )
coin->MAXBUNDLES--;
else if ( coin->MAXBUNDLES < IGUANA_MINPENDBUNDLES )
else if ( coin->MAXBUNDLES < coin->endPEND )
coin->MAXBUNDLES++;
}
return(coin->MAXBUNDLES);

1
iguana/iguana_init.c

@ -359,7 +359,6 @@ struct iguana_info *iguana_coinstart(struct iguana_info *coin,int32_t initialhei
#ifndef IGUANA_DEDICATED_THREADS
coin->peers.peersloop = iguana_launch("peersloop",iguana_peersloop,coin,IGUANA_PERMTHREAD);
#endif
coin->MAXBUNDLES = IGUANA_MAXPENDBUNDLES;
printf("started.%s\n",coin->symbol);
return(coin);
}

36
iguana/iguana_recv.c

@ -189,8 +189,10 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i
{
printf("got block that doesnt validate? %s\n",bits256_str(str,origtxdata->block.RO.hash2));
return;
} //else printf("validated prev.%s\n",bits256_str(str,origtxdata->block.RO.prev_block));
copyflag = 1 * (strcmp(coin->symbol,"BTC") != 0);
}
else if ( coin->enableCACHE != 0 )
printf("validated.(%s)\n",bits256_str(str,origtxdata->block.RO.hash2));
copyflag = coin->enableCACHE * (strcmp(coin->symbol,"BTC") != 0);
bp = 0, bundlei = -2;
if ( copyflag != 0 && recvlen != 0 && ((bp= iguana_bundlefind(coin,&bp,&bundlei,origtxdata->block.RO.hash2)) == 0 || (bp->blocks[bundlei] != 0 && bp->blocks[bundlei]->fpipbits == 0)) )
{
@ -691,7 +693,7 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana
}
fprintf(stderr,"%s [%d:%d] block.%x | s.%d r.%d\n",bits256_str(str,origblock->RO.hash2),bp!=0?bp->hdrsi:-1,bundlei,block->fpipbits,numsaved,numrecv);
}
if ( bundlei == 1 && bp != 0 && bp->numhashes < bp->n && strcmp(coin->symbol,"BTC") != 0 )
if ( 0 && bundlei == 1 && bp != 0 && bp->numhashes < bp->n && strcmp(coin->symbol,"BTC") != 0 )
{
printf("reissue hdrs request for [%d]\n",bp->hdrsi);
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1);
@ -708,6 +710,23 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana
queue_enqueue("cacheQ",&coin->cacheQ,&req->DL,0);
return(0);
}
else
{
if ( (block= iguana_blockhashset(coin,-1,origblock->RO.hash2,1)) != 0 )
{
if ( block != origblock )
{
iguana_blockcopy(coin,block,origblock);
coin->numcached++;
if ( block->req == 0 )
{
block->req = req;
req = 0;
} else printf("already have cache entry.(%s)\n",bits256_str(str,origblock->RO.hash2));
//fprintf(stderr,"bundleset block.%p vs origblock.%p prev.%d bits.%x fpos.%ld\n",block,origblock,bits256_nonz(prevhash2),block->fpipbits,block->fpos);
} else printf("got origblock.%s to cache\n",bits256_str(str,origblock->RO.hash2));
}
}
//printf("datalen.%d ipbits.%x\n",datalen,req->ipbits);
} else printf("cant create origblock.%p block.%p bp.%p bundlei.%d\n",origblock,block,bp,bundlei);
return(req);
@ -1027,8 +1046,17 @@ int32_t iguana_blockQ(char *argstr,struct iguana_info *coin,struct iguana_bundle
}
if ( block != 0 )
{
if ( bits256_cmp(coin->APIblockhash,hash2) != 0 && block->fpipbits != 0 && block->fpos >= 0 )
if ( bits256_cmp(coin->APIblockhash,hash2) != 0 && (block->fpipbits != 0 || block->req != 0 || block->queued != 0) )
{
if ( block->fpipbits == 0 && block->queued == 0 && block->req != 0 )
{
block->queued = 1;
queue_enqueue("cacheQ",&coin->cacheQ,&block->req->DL,0);
block->req = 0;
char str2[65]; printf("already have.(%s)\n",bits256_str(str2,block->RO.hash2));
}
return(0);
}
height = block->height;
}
if ( bp != 0 && bp->emitfinish != 0 )

2
iguana/main.c

@ -1117,7 +1117,7 @@ void iguana_main(void *arg)
sleep(1);
char *str;
//iguana_launchcoin(MYINFO.rpcsymbol,cJSON_Parse("{}"));
if ( 1 && (str= SuperNET_JSON(&MYINFO,cJSON_Parse("{\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":128,\"maxpeers\":64,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":1,\"poll\":1}"),0)) != 0 )
if ( 1 && (str= SuperNET_JSON(&MYINFO,cJSON_Parse("{\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":128,\"maxpeers\":64,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":1,\"poll\":1,\"startpend\":1024,\"endpend\":1024,\"cache\":1}"),0)) != 0 )
{
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 )

Loading…
Cancel
Save