Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
bb15d05746
  1. 17
      iguana/iguana777.c
  2. 83
      iguana/iguana_bundles.c
  3. 2
      iguana/iguana_peers.c
  4. 7
      iguana/iguana_ramchain.c
  5. 54
      iguana/iguana_recv.c
  6. 2
      iguana/main.c

17
iguana/iguana777.c

@ -323,8 +323,6 @@ int32_t iguana_helpertask(FILE *fp,struct OS_memspace *mem,struct OS_memspace *m
{ {
if ( (bp= ptr->bp) != 0 ) if ( (bp= ptr->bp) != 0 )
{ {
if ( time(NULL) > bp->nexttime )
return(0);
if ( 0 && ptr->type == 'M' ) if ( 0 && ptr->type == 'M' )
{ {
if ( (nextbp= ptr->nextbp) != 0 ) if ( (nextbp= ptr->nextbp) != 0 )
@ -369,7 +367,7 @@ void iguana_balancecalc(struct iguana_info *coin,struct iguana_bundle *bp)
void iguana_helper(void *arg) void iguana_helper(void *arg)
{ {
FILE *fp = 0; char fname[512],name[64],*helpername = 0; cJSON *argjson=0; int32_t type,flag,idle=0; FILE *fp = 0; char fname[512],name[64],*helpername = 0; cJSON *argjson=0; int32_t type,flag,idle=0;
struct iguana_helper *ptr; struct iguana_info *coin; struct OS_memspace MEM,*MEMB; struct iguana_helper *ptr; struct iguana_info *coin; struct OS_memspace MEM,*MEMB; struct iguana_bundle *bp;
if ( arg != 0 && (argjson= cJSON_Parse(arg)) != 0 ) if ( arg != 0 && (argjson= cJSON_Parse(arg)) != 0 )
helpername = jstr(argjson,"name"); helpername = jstr(argjson,"name");
if ( helpername == 0 ) if ( helpername == 0 )
@ -404,10 +402,15 @@ void iguana_helper(void *arg)
else if ( (ptr= queue_dequeue(&bundlesQ,0)) != 0 ) else if ( (ptr= queue_dequeue(&bundlesQ,0)) != 0 )
{ {
idle = 0; idle = 0;
if ( ptr->bp != 0 && ptr->coin != 0 ) if ( (bp= ptr->bp) != 0 && ptr->coin != 0 )
flag += iguana_bundleiters(ptr->coin,&MEM,MEMB,ptr->bp,ptr->timelimit); {
else printf("helper missing param? %p %p %u\n",ptr->coin,ptr->bp,ptr->timelimit); if ( time(NULL) >= bp->nexttime )
{
//printf("t.%lu vs next.%u\n",time(NULL),bp->nexttime);
flag += iguana_bundleiters(ptr->coin,&MEM,MEMB,bp,ptr->timelimit);
myfree(ptr,ptr->allocsize); myfree(ptr,ptr->allocsize);
} else queue_enqueue("requeue",&bundlesQ,&ptr->DL,0);
} else printf("helper missing param? %p %p %u\n",ptr->coin,bp,ptr->timelimit);
flag++; flag++;
} }
else else
@ -608,7 +611,9 @@ struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers,
coin->endPEND = 1024; coin->endPEND = 1024;
else if ( coin->endPEND < 2 ) else if ( coin->endPEND < 2 )
coin->endPEND = 2; coin->endPEND = 2;
if ( jobj(json,"cache") != 0 )
coin->enableCACHE = juint(json,"cache"); coin->enableCACHE = juint(json,"cache");
else coin->enableCACHE = mult != 0;
coin->MAXMEM = juint(json,"RAM"); coin->MAXMEM = juint(json,"RAM");
if ( coin->MAXMEM == 0 ) if ( coin->MAXMEM == 0 )
coin->MAXMEM = IGUANA_DEFAULTRAM; coin->MAXMEM = IGUANA_DEFAULTRAM;

83
iguana/iguana_bundles.c

@ -153,7 +153,7 @@ int32_t iguana_hash2set(struct iguana_info *coin,char *debugstr,struct iguana_bu
bit = iguana_calcbloom(newhash2); bit = iguana_calcbloom(newhash2);
if ( iguana_bloomfind(coin,&bp->bloom,0,bit) < 0 ) if ( iguana_bloomfind(coin,&bp->bloom,0,bit) < 0 )
{ {
//printf("bloomset (%s) -> [%d:%d]\n",bits256_str(str,newhash2),bp->hdrsi,bundlei); // printf("bloomset (%s) -> [%d:%d]\n",bits256_str(str,newhash2),bp->hdrsi,bundlei);
iguana_bloomset(coin,&bp->bloom,0,bit); iguana_bloomset(coin,&bp->bloom,0,bit);
if ( 0 ) if ( 0 )
{ {
@ -220,6 +220,8 @@ int32_t iguana_bundlehash2add(struct iguana_info *coin,struct iguana_block **blo
block->hdrsi = bp->hdrsi; block->hdrsi = bp->hdrsi;
block->bundlei = bundlei; block->bundlei = bundlei;
bp->hashes[bundlei] = block->RO.hash2; bp->hashes[bundlei] = block->RO.hash2;
if ( bp->speculative != 0 && bundlei < bp->numspec )
bp->speculative[bundlei] = bp->hashes[bundlei];
bp->blocks[bundlei] = block; bp->blocks[bundlei] = block;
otherbp = 0; otherbp = 0;
if ( (otherbp= iguana_bundlefind(coin,&otherbp,&otherbundlei,hash2)) != 0 || (bundlei % (bundlesize-1)) == 0) if ( (otherbp= iguana_bundlefind(coin,&otherbp,&otherbundlei,hash2)) != 0 || (bundlei % (bundlesize-1)) == 0)
@ -566,7 +568,7 @@ int32_t iguana_bundleready(struct iguana_info *coin,struct iguana_bundle *bp)
char str[65]; printf(">>>>>>> ipbits.%x null prevblock error at ht.%d patch.(%s) and reissue\n",block->fpipbits,bp->bundleheight+i,bits256_str(str,block->RO.prev_block)); char str[65]; printf(">>>>>>> ipbits.%x null prevblock error at ht.%d patch.(%s) and reissue\n",block->fpipbits,bp->bundleheight+i,bits256_str(str,block->RO.prev_block));
iguana_blockQ("null retry",coin,bp,i,block->RO.hash2,1); iguana_blockQ("null retry",coin,bp,i,block->RO.hash2,1);
} else ready++; } else ready++;
} else printf("error getting block (%d:%d) %p vs %p\n",bp->hdrsi,i,block,iguana_blockfind(coin,bp->hashes[i])); } else printf("error getting block (%d:%d) %p\n",bp->hdrsi,i,block);
} }
return(ready); return(ready);
} }
@ -576,21 +578,30 @@ int32_t iguana_bundlehdr(struct iguana_info *coin,struct iguana_bundle *bp,int32
int32_t counter=0; int32_t counter=0;
//if ( bp->speculative != 0 ) //if ( bp->speculative != 0 )
// printf("hdr ITERATE bundle.%d vs %d: h.%d n.%d r.%d s.%d finished.%d speculative.%p\n",bp->bundleheight,coin->longestchain-coin->chain->bundlesize,bp->numhashes,bp->n,bp->numrecv,bp->numsaved,bp->emitfinish,bp->speculative); // printf("hdr ITERATE bundle.%d vs %d: h.%d n.%d r.%d s.%d finished.%d speculative.%p\n",bp->bundleheight,coin->longestchain-coin->chain->bundlesize,bp->numhashes,bp->n,bp->numrecv,bp->numsaved,bp->emitfinish,bp->speculative);
int32_t i; struct iguana_block *block; uint32_t now; int32_t i; uint32_t now;
if ( coin->enableCACHE != 0 && bp->speculative == 0 && bp->numhashes < bp->n ) if ( coin->enableCACHE != 0 && bp->speculative == 0 && bp->numhashes < bp->n )
{ {
char str[64]; char str[64];
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1); queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1);
} }
else if ( bp->speculative != 0 ) if ( bp->speculative != 0 )
{ {
now = (uint32_t)time(NULL); now = (uint32_t)time(NULL);
for (i=0; i<bp->numspec; i++) for (i=0; i<bp->numspec; i++)
if ( bits256_nonz(bp->speculative[i]) != 0 && bp->issued[i] > now+10 && ((block= iguana_blockfind(coin,bp->speculative[i])) == 0 || block->req == 0) ) {
if ( bits256_nonz(bp->hashes[i]) == 0 && bits256_nonz(bp->speculative[i]) != 0 )
{
if ( now > bp->issued[i]+10 )
{ {
bp->issued[i] = now; bp->issued[i] = now;
//printf("speculative.[%d:%d]\n",bp->hdrsi,i);
iguana_blockQ("speculative",coin,0,-1,bp->speculative[i],0); iguana_blockQ("speculative",coin,0,-1,bp->speculative[i],0);
} }
break;
}
else if ( bp->blocks[i] == 0 )
break;
}
} }
return(counter); return(counter);
} }
@ -626,7 +637,7 @@ int64_t iguana_bundlecalcs(struct iguana_info *coin,struct iguana_bundle *bp)
{ {
if ( bits256_nonz(bp->hashes[bundlei]) > 0 && (block= bp->blocks[bundlei]) != 0 ) if ( bits256_nonz(bp->hashes[bundlei]) > 0 && (block= bp->blocks[bundlei]) != 0 )
{ {
if ( block == iguana_blockfind(coin,bp->hashes[bundlei]) ) //if ( block == iguana_blockfind(coin,bp->hashes[bundlei]) )
{ {
if ( (checki= iguana_peerfname(coin,&hdrsi,GLOBALTMPDIR,fname,0,bp->hashes[bundlei],bundlei>0?bp->hashes[bundlei-1]:zero,1)) != bundlei || bundlei < 0 || bundlei >= coin->chain->bundlesize ) if ( (checki= iguana_peerfname(coin,&hdrsi,GLOBALTMPDIR,fname,0,bp->hashes[bundlei],bundlei>0?bp->hashes[bundlei-1]:zero,1)) != bundlei || bundlei < 0 || bundlei >= coin->chain->bundlesize )
{ {
@ -670,13 +681,13 @@ int64_t iguana_bundlecalcs(struct iguana_info *coin,struct iguana_bundle *bp)
//block->issued = bp->issued[bundlei] = 0; //block->issued = bp->issued[bundlei] = 0;
}*/ }*/
} }
else if ( 0 ) /*else if ( 0 )
{ {
bp->blocks[bundlei] = iguana_blockfind(coin,bp->hashes[bundlei]); bp->blocks[bundlei] = iguana_blockfind(coin,bp->hashes[bundlei]);
bp->hashes[bundlei] = bp->blocks[bundlei]->RO.hash2; bp->hashes[bundlei] = bp->blocks[bundlei]->RO.hash2;
if ( (block= bp->blocks[bundlei]) != 0 ) if ( (block= bp->blocks[bundlei]) != 0 )
block->fpipbits = block->queued = 0; block->fpipbits = block->queued = 0;
} }*/
numhashes++; numhashes++;
bp->checkedtmp++; bp->checkedtmp++;
} }
@ -718,9 +729,9 @@ int32_t iguana_bundlefinish(struct iguana_info *coin,struct iguana_bundle *bp)
int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,struct OS_memspace *memB,struct iguana_bundle *bp,int32_t timelimit) int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,struct OS_memspace *memB,struct iguana_bundle *bp,int32_t timelimit)
{ {
int32_t range,starti,lasti,retval=0,max,counter = 0; struct iguana_bundle *currentbp,*lastbp; int32_t range,starti,lasti,retval=0,max,counter = 0; struct iguana_bundle *currentbp,*lastbp;
bp->nexttime = (uint32_t)time(NULL) + 1;
if ( coin->started == 0 ) if ( coin->started == 0 )
{ {
bp->nexttime = (uint32_t)time(NULL) + 1;
iguana_bundleQ(coin,bp,1000); iguana_bundleQ(coin,bp,1000);
return(retval); return(retval);
} }
@ -734,11 +745,13 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,stru
lasti = lastbp == 0 ? coin->bundlescount-1 : lastbp->hdrsi; lasti = lastbp == 0 ? coin->bundlescount-1 : lastbp->hdrsi;
coin->numbundlesQ--; coin->numbundlesQ--;
iguana_bundlecalcs(coin,bp); 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); printf("ITERATE.%-4d now.%u numspec.%-4d bundle.%-4d h.%-4d r.%-4d s.%-4d F.%d T.%d counter.%d\n",bp->rank,(uint32_t)time(NULL),bp->numspec,bp->bundleheight/coin->chain->bundlesize,bp->numhashes,bp->numrecv,bp->numsaved,bp->emitfinish,timelimit,counter);
bp->nexttime = (uint32_t)(time(NULL) + (bp->hdrsi - starti) + 1);
if ( bp->numhashes < bp->n && bp->bundleheight < coin->longestchain-coin->chain->bundlesize ) if ( bp->numhashes < bp->n && bp->bundleheight < coin->longestchain-coin->chain->bundlesize )
iguana_bundlehdr(coin,bp,starti); iguana_bundlehdr(coin,bp,starti);
else if ( bp->emitfinish != 0 ) else if ( bp->emitfinish != 0 )
{ {
//bp->nexttime -= 60;
if ( bp->emitfinish > 1 ) if ( bp->emitfinish > 1 )
{ {
if ( (retval= iguana_bundlefinish(coin,bp)) > 0 ) if ( (retval= iguana_bundlefinish(coin,bp)) > 0 )
@ -809,8 +822,9 @@ static int32_t revsortds(double *buf,uint32_t num,int32_t size)
void iguana_bundlestats(struct iguana_info *coin,char *str) void iguana_bundlestats(struct iguana_info *coin,char *str)
{ {
static uint32_t lastdisp; static uint32_t lastdisp;
int32_t i,n,m,numv,count,pending,dispflag,numutxo,numbalances,numrecv,done,numhashes,numcached,numsaved,numemit; int32_t i,n,m,j,numv,count,pending,dispflag,numutxo,numbalances,numrecv,done,numhashes,numcached,numsaved,numemit;
int64_t spaceused=0,estsize = 0; struct iguana_bundle *bp,*lastpending = 0,*firstgap = 0; double *sortbuf; struct iguana_peer *addr; int64_t spaceused=0,estsize = 0; struct iguana_bundle *bp,*lastpending = 0,*firstgap = 0; double *sortbuf; struct iguana_peer *addr; struct iguana_block *block,*prev; uint32_t now;
now = (uint32_t)time(NULL);
dispflag = (rand() % 1000) == 0; dispflag = (rand() % 1000) == 0;
numrecv = numhashes = numcached = numsaved = numemit = done = numutxo = numbalances = 0; numrecv = numhashes = numcached = numsaved = numemit = done = numutxo = numbalances = 0;
count = coin->bundlescount; count = coin->bundlescount;
@ -819,6 +833,47 @@ void iguana_bundlestats(struct iguana_info *coin,char *str)
{ {
if ( (bp= coin->bundles[i]) != 0 ) if ( (bp= coin->bundles[i]) != 0 )
{ {
//if ( iguana_blockfind(coin,bp->hashes[0]) == 0 )
// printf("UNEXPECTED null block for bundlehash.%d\n",bp->hdrsi);
if ( bp->numhashes < bp->n && bp->speculative != 0 )
{
for (j=1; j<bp->numspec&&j<bp->n; j++)
iguana_blockhashset(coin,-1,bp->speculative[j],1);
//char str[65],str2[65];
for (j=1; j<bp->numspec&&j<bp->n; j++)
{
if ( (block= bp->blocks[j]) == 0 )
{
if ( bits256_nonz(bp->hashes[j]) != 0 )
block = iguana_blockfind(coin,bp->hashes[j]);
else if ( bits256_nonz(bp->speculative[j]) != 0 )
block = iguana_blockfind(coin,bp->speculative[j]);
}
else if ( bits256_nonz(block->RO.prev_block) != 0 && block->fpipbits != 0 )
continue;
prev = bp->blocks[j-1];
//printf("[%d:%d] prev.%p nonz.%d speculative.%d block.%p\n",bp->hdrsi,j,bp->blocks[j-1],bits256_nonz(bp->hashes[j]),bits256_nonz(bp->speculative[j]),bp->blocks[j]);
if ( block != 0 && prev != 0 && bp->blocks[j] == 0 )
{
//char str2[65]; printf("[%d:%d] prev.%p nonz.%d speculative.%d prev.%s vs %s ipbits.%x q.%d\n",bp->hdrsi,j,bp->blocks[j-1],bits256_nonz(bp->hashes[j]),bits256_nonz(bp->speculative[j]),bits256_str(str,prev->RO.hash2),bits256_str(str2,block->RO.prev_block),block->fpipbits,block->queued);
if ( block->fpipbits == 0 && block->queued == 0 )
{
if ( block->req != 0 )
{
block->queued = 1;
queue_enqueue("cacheQ",&coin->cacheQ,&block->req->DL,0);
block->req = 0;
printf("submit cached [%d:%d]\n",bp->hdrsi,j);
}
else if ( now > block->issued+10 )
{
block->issued = now;
iguana_blockQ("spec",coin,0,-1,block->RO.hash2,0);
}
}
} // else break;
}
}
bp->rank = 0; bp->rank = 0;
estsize += bp->estsize;//iguana_bundlecalcs(coin,bp,done); estsize += bp->estsize;//iguana_bundlecalcs(coin,bp,done);
//bp->metric = bp->numhashes; //bp->metric = bp->numhashes;
@ -902,8 +957,8 @@ void iguana_bundlestats(struct iguana_info *coin,char *str)
if ( (rand() % 100) == 0 ) if ( (rand() % 100) == 0 )
myallocated(0,0); myallocated(0,0);
lastdisp = (uint32_t)time(NULL); lastdisp = (uint32_t)time(NULL);
//if ( firstgap != 0 && firstgap->queued == 0 ) if ( firstgap != 0 && firstgap->queued == 0 )
// iguana_bundleQ(coin,firstgap,1000); iguana_bundleQ(coin,firstgap,1000);
} }
strcpy(coin->statusstr,str); strcpy(coin->statusstr,str);
coin->estsize = estsize; coin->estsize = estsize;

2
iguana/iguana_peers.c

@ -992,7 +992,7 @@ void iguana_dedicatedloop(struct iguana_info *coin,struct iguana_peer *addr)
{ {
if ( req->datalen != 0 ) if ( req->datalen != 0 )
{ {
char str[65]; printf("CACHE.%p parse[%d] %s %s\n",req,req->recvlen,req->H.command,bits256_str(str,req->block.RO.hash2)); //char str[65]; printf("CACHE.%p parse[%d] %s %s\n",req,req->recvlen,req->H.command,bits256_str(str,req->block.RO.hash2));
iguana_parsebuf(coin,addr,&req->H,req->serialized,req->recvlen); iguana_parsebuf(coin,addr,&req->H,req->serialized,req->recvlen);
} else printf("CACHE error no datalen\n"); } else printf("CACHE error no datalen\n");
coin->cachefreed++; coin->cachefreed++;

7
iguana/iguana_ramchain.c

@ -253,8 +253,15 @@ int32_t iguana_peerfname(struct iguana_info *coin,int32_t *hdrsip,char *dirname,
// printf("illegal ipbits.%d\n",ipbits), getchar(); // printf("illegal ipbits.%d\n",ipbits), getchar();
if ( (bp= iguana_bundlefind(coin,&bp,&bundlei,hash2)) == 0 ) if ( (bp= iguana_bundlefind(coin,&bp,&bundlei,hash2)) == 0 )
{ {
int32_t i;
if ( (bp= coin->bundles[0]) != 0 && bp->speculative != 0 )
for (i=0; i<100; i++)
printf("(%d %d %d).%d ",bits256_nonz(bp->hashes[i]),bits256_nonz(bp->speculative[i]),bits256_cmp(bp->hashes[i],bp->speculative[i]),bits256_cmp(hash2,bp->hashes[i]));
printf("iguana_peerfname error finding.(%s)\n",bits256_str(str,hash2));
if ( bits256_nonz(prevhash2) == 0 || (bp= iguana_bundlefind(coin,&bp,&bundlei,prevhash2)) == 0 || bundlei >= coin->chain->bundlesize-1 ) if ( bits256_nonz(prevhash2) == 0 || (bp= iguana_bundlefind(coin,&bp,&bundlei,prevhash2)) == 0 || bundlei >= coin->chain->bundlesize-1 )
{
return(-2); return(-2);
}
else bundlei++; else bundlei++;
} }
hash2 = bp->hashes[0], *hdrsip = bp->hdrsi; hash2 = bp->hashes[0], *hdrsip = bp->hdrsi;

54
iguana/iguana_recv.c

@ -192,11 +192,12 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i
} }
else if ( 0 && coin->enableCACHE != 0 ) else if ( 0 && coin->enableCACHE != 0 )
printf("validated.(%s)\n",bits256_str(str,origtxdata->block.RO.hash2)); printf("validated.(%s)\n",bits256_str(str,origtxdata->block.RO.hash2));
copyflag = coin->enableCACHE * (coin->enableCACHE != 0); copyflag = coin->enableCACHE;
bp = 0, bundlei = -2; 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)) ) 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)) )
{ {
req = iguana_bundlereq(coin,addr,'B',copyflag * recvlen); req = iguana_bundlereq(coin,addr,'B',copyflag * recvlen);
req->copyflag = 1;
//printf("copy %p serialized[%d]\n",req,req->recvlen); //printf("copy %p serialized[%d]\n",req,req->recvlen);
memcpy(req->serialized,data,recvlen); memcpy(req->serialized,data,recvlen);
} }
@ -564,7 +565,7 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct iguana_info *coin,struct ig
struct iguana_bundlereq *iguana_recvblockhashes(struct iguana_info *coin,struct iguana_bundlereq *req,bits256 *blockhashes,int32_t num) struct iguana_bundlereq *iguana_recvblockhashes(struct iguana_info *coin,struct iguana_bundlereq *req,bits256 *blockhashes,int32_t num)
{ {
int32_t bundlei,i,len; struct iguana_bundle *bp; bits256 allhash,zero; char hashstr[65]; uint8_t serialized[512]; struct iguana_peer *addr; int32_t bundlei,i,len; struct iguana_bundle *bp,*newbp; bits256 allhash,zero; char hashstr[65]; uint8_t serialized[512]; struct iguana_peer *addr;
memset(zero.bytes,0,sizeof(zero)); memset(zero.bytes,0,sizeof(zero));
bp = 0, bundlei = -2; bp = 0, bundlei = -2;
if ( num < 2 ) if ( num < 2 )
@ -588,13 +589,13 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct iguana_info *coin,struct
{ {
init_hexbytes_noT(hashstr,blockhashes[coin->chain->bundlesize].bytes,sizeof(bits256)); init_hexbytes_noT(hashstr,blockhashes[coin->chain->bundlesize].bytes,sizeof(bits256));
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr),1); queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr),1);
bp = iguana_bundlecreate(coin,&bundlei,bp->bundleheight+coin->chain->bundlesize,blockhashes[coin->chain->bundlesize],zero,1); newbp = iguana_bundlecreate(coin,&bundlei,bp->bundleheight+coin->chain->bundlesize,blockhashes[coin->chain->bundlesize],zero,1);
if ( bp != 0 ) if ( newbp != 0 )
{ {
char str2[65]; 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); printf("EXTEND last bundle %s/%s ht.%d\n",bits256_str(str,newbp->hashes[0]),bits256_str(str2,blockhashes[coin->chain->bundlesize]),newbp->bundleheight);
if ( bp->queued == 0 ) if ( newbp->queued == 0 )
iguana_bundleQ(coin,bp,1000); iguana_bundleQ(coin,newbp,1000);
} }
} }
else if ( iguana_allhashcmp(coin,bp,blockhashes,num) > 0 ) else if ( iguana_allhashcmp(coin,bp,blockhashes,num) > 0 )
@ -603,7 +604,7 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct iguana_info *coin,struct
} }
if ( bp != 0 && (bp->speculative == 0 || num > bp->numspec) && bp->emitfinish == 0 ) if ( bp != 0 && (bp->speculative == 0 || num > bp->numspec) && bp->emitfinish == 0 )
{ {
printf("FOUND speculative.%p BLOCKHASHES[%d] ht.%d\n",bp->speculative,num,bp->bundleheight); printf("FOUND speculative.%s BLOCKHASHES[%d] ht.%d\n",bits256_str(str,blockhashes[1]),num,bp->bundleheight);
if ( bp->speculative != 0 ) if ( bp->speculative != 0 )
myfree(bp->speculative,sizeof(*bp->speculative) * bp->numspec); myfree(bp->speculative,sizeof(*bp->speculative) * bp->numspec);
bp->speculative = blockhashes; bp->speculative = blockhashes;
@ -660,6 +661,24 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana
struct iguana_bundle *bp=0; int32_t i,numsaved=0,bundlei = -2; struct iguana_block *block,*tmpblock; char str[65]; struct iguana_bundle *bp=0; int32_t i,numsaved=0,bundlei = -2; struct iguana_block *block,*tmpblock; char str[65];
if ( (bp= iguana_bundleset(coin,&block,&bundlei,origblock)) == 0 ) if ( (bp= iguana_bundleset(coin,&block,&bundlei,origblock)) == 0 )
{ {
if ( (bp= iguana_bundlefind(coin,&bp,&bundlei,origblock->RO.hash2)) != 0 )
{
printf("got block [%d:%d]\n",bp->hdrsi,bundlei);
/*if ( bits256_cmp(prev->RO.hash2,block->RO.prev_block) == 0 && bundlei < bp->n-1 )
{
bundlei++;
iguana_bundlehash2add(coin,&tmpblock,bp,bundlei,block->RO.hash2);
if ( tmpblock == block )
{
printf("[%d:%d] speculative block.%p\n",bp->hdrsi,bundlei,block);
bp->blocks[bundlei] = block;
bp->hashes[bundlei] = block->RO.hash2;
block->bundlei = bundlei;
block->hdrsi = bp->hdrsi;
block->mainchain = prev->mainchain;
} else printf("error adding speculative prev [%d:%d]\n",bp->hdrsi,bundlei);
}*/
}
for (i=coin->bundlescount-1; i>=0; i--) for (i=coin->bundlescount-1; i>=0; i--)
{ {
//if ( coin->bundles[i] != 0 ) //if ( coin->bundles[i] != 0 )
@ -681,7 +700,7 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana
} }
//printf("i.%d ref prev.(%s)\n",i,bits256_str(str,origblock->RO.prev_block)); //printf("i.%d ref prev.(%s)\n",i,bits256_str(str,origblock->RO.prev_block));
} }
if ( 0 && bp != 0 && bp->hdrsi == coin->bundlescount-1 ) if ( 1 )//&& bp != 0 && bp->hdrsi == coin->bundlescount-1 )
{ {
int32_t i; static int32_t numrecv; int32_t i; static int32_t numrecv;
numrecv++; numrecv++;
@ -691,7 +710,7 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana
if ( (tmpblock= bp->blocks[i]) != 0 && tmpblock->fpipbits != 0 && tmpblock->fpos >= 0 && ((bp->hdrsi == 0 && i == 0) || bits256_nonz(tmpblock->RO.prev_block) != 0) ) if ( (tmpblock= bp->blocks[i]) != 0 && tmpblock->fpipbits != 0 && tmpblock->fpos >= 0 && ((bp->hdrsi == 0 && i == 0) || bits256_nonz(tmpblock->RO.prev_block) != 0) )
numsaved++; numsaved++;
} }
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); //fprintf(stderr,"%s [%d:%d] block.%x | s.%d r.%d copy.%d\n",bits256_str(str,origblock->RO.hash2),bp!=0?bp->hdrsi:-1,bundlei,block->fpipbits,numsaved,numrecv,req->copyflag);
} }
if ( 1 && bundlei == 1 && bp != 0 && bp->numhashes < bp->n && coin->enableCACHE != 0 ) if ( 1 && bundlei == 1 && bp != 0 && bp->numhashes < bp->n && coin->enableCACHE != 0 )
{ {
@ -706,7 +725,7 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana
{ {
if ( block->queued == 0 && bp != 0 ) if ( block->queued == 0 && bp != 0 )
{ {
char str[65]; fprintf(stderr,"req.%p %s copyflag.%d %d data %d %d\n",req,bits256_str(str,block->RO.hash2),req->copyflag,block->height,req->recvlen,recvlen); //char str[65]; fprintf(stderr,"req.%p %s copyflag.%d %d data %d %d\n",req,bits256_str(str,block->RO.hash2),req->copyflag,block->height,req->recvlen,recvlen);
coin->numcached++; coin->numcached++;
block->queued = 1; block->queued = 1;
queue_enqueue("cacheQ",&coin->cacheQ,&req->DL,0); queue_enqueue("cacheQ",&coin->cacheQ,&req->DL,0);
@ -901,8 +920,19 @@ int32_t iguana_reqblocks(struct iguana_info *coin)
if ( bp != 0 && bits256_nonz(hash2) == 0 ) if ( bp != 0 && bits256_nonz(hash2) == 0 )
{ {
hash2 = bp->hashes[bundlei]; hash2 = bp->hashes[bundlei];
if ( bits256_nonz(hash2) == 0 && bp->speculative != 0 ) /*if ( bits256_nonz(hash2) == 0 && bp->speculative != 0 )
{
hash2 = bp->speculative[bundlei]; hash2 = bp->speculative[bundlei];
if ( bits256_nonz(hash2) > 0 )
{
if ( (block= iguana_blockfind(coin,hash2)) != 0 && bits256_cmp(block->RO.prev_block,coin->blocks.hwmchain.RO.hash2) == 0 )
{
printf("speculative is next at %d\n",coin->backstop);
if ( _iguana_chainlink(coin,block) != 0 )
lflag++, flag++, printf("NEWHWM.%d\n",coin->backstop);
}
}
}*/
} }
if ( bits256_nonz(hash2) > 0 ) if ( bits256_nonz(hash2) > 0 )
{ {

2
iguana/main.c

@ -1117,7 +1117,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("{\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":128,\"maxpeers\":64,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":1,\"poll\":1,\"startpend\":2,\"endpend\":2,\"cache\":0}"),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\":2,\"endpend\":2}"),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