Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
816b84f82b
  1. 24
      iguana/iguana777.c
  2. 7
      iguana/iguana777.h
  3. 39
      iguana/iguana_bundles.c
  4. 36
      iguana/iguana_recv.c
  5. 4
      iguana/main.c

24
iguana/iguana777.c

@ -247,7 +247,7 @@ void iguana_mergeQ(struct iguana_info *coin,struct iguana_bundle *bp,struct igua
queue_enqueue("helperQ",&helperQ,&ptr->DL,0);
}
void iguana_bundleQ(struct iguana_info *coin,struct iguana_bundle *bp)
void iguana_bundleQ(struct iguana_info *coin,struct iguana_bundle *bp,int32_t timelimit)
{
struct iguana_helper *ptr;
ptr = mycalloc('i',1,sizeof(*ptr));
@ -256,6 +256,7 @@ void iguana_bundleQ(struct iguana_info *coin,struct iguana_bundle *bp)
ptr->bp = bp, ptr->hdrsi = bp->hdrsi;
ptr->type = 'B';
ptr->starttime = (uint32_t)time(NULL);
ptr->timelimit = timelimit;
coin->numbundlesQ++;
//printf("%s bundle.%d[%d] emitfinish.%u\n",coin->symbol,ptr->hdrsi,bp->n,bp->emitfinish);
queue_enqueue("helperQ",&helperQ,&ptr->DL,0);
@ -264,35 +265,36 @@ void iguana_bundleQ(struct iguana_info *coin,struct iguana_bundle *bp)
int32_t iguana_helpertask(FILE *fp,struct OS_memspace *mem,struct OS_memspace *memB,struct iguana_helper *ptr)
{
struct iguana_info *coin; struct iguana_peer *addr; struct iguana_bundle *bp,*nextbp;
coin = ptr->coin, addr = ptr->addr;
if ( 0 && ptr->type == 'M' )
{
addr = ptr->addr;
if ( (coin= ptr->coin) != 0 )
{
if ( (bp= ptr->bp) != 0 && (nextbp= ptr->nextbp) != 0 )
if ( (bp= ptr->bp) != 0 )
{
if ( 0 && ptr->type == 'M' )
{
if ( (nextbp= ptr->nextbp) != 0 )
{
bp->mergefinish = nextbp->mergefinish = (uint32_t)time(NULL);
if ( iguana_bundlemergeHT(coin,mem,memB,bp,nextbp,ptr->starttime) < 0 )
bp->mergefinish = nextbp->mergefinish = 0;
}
}
else if ( ptr->type == 'B' )
{
iguana_bundleiters(coin,bp,ptr->timelimit);
}
else if ( ptr->type == 'E' )
{
//printf("emitQ coin.%p bp.%p\n",ptr->coin,ptr->bp);
if ( (coin= ptr->coin) != 0 )
{
if ( (bp= ptr->bp) != 0 )
{
if ( iguana_bundlesaveHT(coin,mem,memB,bp,ptr->starttime) == 0 )
{
bp->emitfinish = (uint32_t)time(NULL);
coin->numemitted++;
}
else bp->emitfinish = 0;
} else printf("error missing bp in emit\n");
} else printf("no coin in helper request?\n");
}
} else printf("no bundle in helperrequest\n");
} else printf("no coin in helperrequest\n");
return(0);
}

7
iguana/iguana777.h

@ -29,7 +29,7 @@
#define IGUANA_HEIGHT 200
#define IGUANA_MAXPENDHDRS 1
#define _IGUANA_MAXPENDING 512 //64
#define _IGUANA_MAXPENDING 3 //64
#define _IGUANA_MAXBUNDLES 8
#define IGUANA_MAXACTIVEBUNDLES 32
#define IGUANA_MAXFILES 4096
@ -588,7 +588,7 @@ void iguana_emitQ(struct iguana_info *coin,struct iguana_bundle *bp);
void iguana_txdataQ(struct iguana_info *coin,struct iguana_peer *addr,FILE *fp,long fpos,int32_t datalen);
void iguana_helper(void *arg);
struct iguana_helper { struct queueitem DL; void *coin,*addr,*bp,*nextbp,*fp; long fpos; int32_t allocsize,type,hdrsi,bundlei,datalen; uint32_t starttime; };
struct iguana_helper { struct queueitem DL; void *coin,*addr,*bp,*nextbp,*fp; long fpos; int32_t allocsize,type,hdrsi,bundlei,datalen,timelimit; uint32_t starttime; };
int32_t iguana_helpertask(FILE *fp,struct OS_memspace *mem,struct OS_memspace *memB,struct iguana_helper *ptr);
void iguana_flushQ(struct iguana_info *coin,struct iguana_peer *addr);
//struct iguana_txdatabits iguana_peerfilePT(struct iguana_info *coin,struct iguana_peer *addr,bits256 hash2,struct iguana_txdatabits txdatabits,int32_t recvlen);
@ -685,7 +685,8 @@ int32_t iguana_jsonQ();
int32_t is_bitcoinrpc(char *method);
char *iguana_bitcoinRPC(struct supernet_info *myinfo,char *method,cJSON *json,char *remoteaddr);
cJSON *iguana_pubkeyjson(struct iguana_info *coin,char *pubkeystr);
void iguana_bundleQ(struct iguana_info *coin,struct iguana_bundle *bp);
void iguana_bundleQ(struct iguana_info *coin,struct iguana_bundle *bp,int32_t timelimit);
void iguana_bundleiters(struct iguana_info *coin,struct iguana_bundle *bp,int32_t timelimit);
#include "../includes/iguana_api.h"

39
iguana/iguana_bundles.c

@ -425,7 +425,7 @@ int64_t iguana_bundlecalcs(struct iguana_info *coin,struct iguana_bundle *bp)
}
}
bp->metric = bp->numhashes;
//if ( bp->numsaved > 0 )
/*if ( bp->numsaved > 0 )
{
bp->estsize = ((uint64_t)bp->datasize * bp->n) / (bp->numrecv+1);
if ( bp->numsaved >= bp->n && bp->emitfinish == 0 )
@ -437,7 +437,7 @@ int64_t iguana_bundlecalcs(struct iguana_info *coin,struct iguana_bundle *bp)
else if ( bp->hdrsi >= coin->bundlescount-8 )
bp->metric = 1;
else bp->metric = (bp->hdrsi + 1);//(2*bp->n - bp->numsaved - bp->numrecv);//sqrt((sqrt(fabs(bp->estsize - bp->datasize)) * (bp->n - bp->numsaved)) * (bp->hdrsi + 1));
}
}*/
//printf("%f ",bp->metric);
return(bp->estsize);
}
@ -559,3 +559,38 @@ void iguana_bundlestats(struct iguana_info *coin,char *str)
strcpy(coin->statusstr,str);
coin->estsize = estsize;
}
void iguana_bundleiters(struct iguana_info *coin,struct iguana_bundle *bp,int32_t timelimit)
{
int32_t i,n; uint32_t now; struct iguana_block *block; double endmillis = OS_milliseconds() + timelimit;
printf("ITERATE bundle.%d r.%d s.%d\n",bp->bundleheight,bp->numrecv,bp->numsaved);
memset(bp->issued,0,sizeof(bp->issued));
while ( bp->emitfinish == 0 && OS_milliseconds() < endmillis )
{
now = (uint32_t)time(NULL);
for (i=n=0; i<bp->n; i++)
{
if ( (block= bp->blocks[i]) != 0 )
{
if ( block->queued == 0 && block->fpipbits == 0 && bp->issued[i] == 0 )
{
printf("(%d:%d) ",bp->hdrsi,i);
iguana_blockQ(coin,bp,i,block->RO.hash2,0);
bp->issued[i] = now;
}
else if ( block->fpipbits != 0 )
n++;
} else printf("iguana_bundleiters[%d] unexpected null block[%d]\n",bp->bundleheight,i);
bp->numsaved = n;
}
if ( bp->numsaved >= bp->n && bp->emitfinish == 0 )
{
printf(">>>>>>>>>>>>>>>>>>>>>>> EMIT\n");
bp->emitfinish = 1;
iguana_emitQ(coin,bp);
return;
}
usleep(1000);
}
iguana_bundleQ(coin,bp,timelimit);
}

36
iguana/iguana_recv.c

@ -310,7 +310,7 @@ uint32_t iguana_allhashcmp(struct iguana_info *coin,struct iguana_bundle *bp,bit
}
//printf("ALLHASHES FOUND! %d requested.%d\n",bp->bundleheight,n);
bp->queued = (uint32_t)time(NULL);
iguana_bundleQ(coin,bp);
iguana_bundleQ(coin,bp,1000);
return(bp->queued);
}
}
@ -394,7 +394,7 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct iguana_info *coin,struct ig
//fprintf(stderr,"i.%d of %d bundleset\n",i,n);
if ( (bp= iguana_bundleset(coin,&block,&bundlei,&blocks[i])) != 0 && bp->hdrsi < IGUANA_MAXACTIVEBUNDLES )
{
iguana_blockQ(coin,bp,bundlei,blocks[i].RO.hash2,1);
//iguana_blockQ(coin,bp,bundlei,blocks[i].RO.hash2,1);
if ( i == 0 )
printf("GOT HDRS[%d] Q.(%d %d) ht.%d hashes.%d recv.%d\n",n,queue_size(&coin->priorityQ),queue_size(&coin->blocksQ),bp->bundleheight,bp->numhashes,bp->numrecv);
}
@ -405,7 +405,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)
{
int32_t bundlei,i; struct iguana_bundle *bp;
int32_t bundlei,i,flag = 0; struct iguana_bundle *bp; struct iguana_block *block;
bp = 0, bundlei = -2, iguana_bundlefind(coin,&bp,&bundlei,blockhashes[1]);
//char str[65]; printf("blockhashes[%d] %s bp.%d[%d]\n",num,bits256_str(str,blockhashes[1]),bp==0?-1:bp->bundleheight,bundlei);
if ( bp != 0 )
@ -419,8 +419,16 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct iguana_info *coin,struct
}
if ( bp->hdrsi == coin->bundlescount-1 )
{
for (i=0; i<num; i++)
iguana_blockQ(coin,0,-1,blockhashes[i],0);
printf("FOUND LAST BLOCKHASHES\n");
for (i=1; i<num-1; i++)
{
if ( (block= iguana_blockfind(coin,blockhashes[i])) != 0 )
{
block->hh.next = iguana_blockfind(coin,blockhashes[i+1]);
if ( flag == 0 && bits256_nonz(block->RO.prev_block) == 0 )
iguana_blockQ(coin,0,-1,block->RO.hash2,0), flag++;
}
}
}
}
else if ( num >= coin->chain->bundlesize )
@ -453,8 +461,13 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct iguana_info *coin,struct
struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_bundlereq *req,struct iguana_block *origblock,int32_t numtx,int32_t datalen,int32_t recvlen,int32_t *newhwmp)
{
struct iguana_bundle *prevbp=0,*bp=0; int32_t prevbundlei=-2,bundlei = -2; struct iguana_block *prevblock,*block;
struct iguana_bundle *prevbp=0,*bp=0; int32_t prevbundlei=-2,bundlei = -2; struct iguana_block *prevblock,*block,*next;
bp = iguana_bundleset(coin,&block,&bundlei,origblock);
if ( bp != 0 && bp->hdrsi == coin->bundlescount-1 )
{
if ( block != 0 && (next= block->hh.next) != 0 )
iguana_blockQ(coin,bp,bundlei+1,next->RO.hash2,0), printf("AUTONEXT ");
}
static int total; char str[65]; printf("RECV %s [%d:%d] block.%08x | %d\n",bits256_str(str,origblock->RO.hash2),bp!=0?bp->hdrsi:-1,bundlei,block->fpipbits,total++);
iguana_bundlefind(coin,&prevbp,&prevbundlei,origblock->RO.prev_block);
if ( prevbp != 0 && prevbundlei >= 0 && (prevblock= iguana_blockfind(coin,origblock->RO.prev_block)) != 0 )
@ -471,10 +484,7 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana
iguana_bundlecreate(coin,&prevbundlei,prevbp->bundleheight + coin->chain->bundlesize,block->RO.hash2,zero,0);
}
}
else
{
iguana_bundlehash2add(coin,0,prevbp,prevbundlei+1,block->RO.hash2);
}
else iguana_bundlehash2add(coin,0,prevbp,prevbundlei+1,block->RO.hash2);
}
if ( prevbp->numhashes < prevbp->n && prevbundlei == 0 )
{
@ -628,7 +638,9 @@ int32_t iguana_blockQ(struct iguana_info *coin,struct iguana_bundle *bp,int32_t
printf("cant queue zerohash bundlei.%d\n",bundlei);
return(-1);
}
if ( (bp != 0 && (block= iguana_blockfind(coin,bp->hashes[bundlei])) == 0) || priority != 0 || bp == 0 )
if ( bp != 0 )
block = iguana_blockfind(coin,bp->hashes[bundlei]);
if ( priority != 0 || block == 0 || (block->queued == 0 && block->fpipbits == 0) )
{
if ( block != 0 )
{
@ -665,7 +677,7 @@ int32_t iguana_blockQ(struct iguana_info *coin,struct iguana_bundle *bp,int32_t
queue_enqueue(str,Q,&req->DL,0);
return(1);
} else printf("null Q\n");
} //else printf("queueblock skip priority.%d bundlei.%d\n",bundlei,priority);
} else printf("queueblock skip priority.%d bundlei.%d\n",bundlei,priority);
return(0);
}

4
iguana/main.c

@ -35,9 +35,9 @@ uint64_t IGUANA_MY64BITS;
queue_t helperQ,jsonQ,finishedQ;
static int32_t initflag;
#ifdef __linux__
int32_t IGUANA_NUMHELPERS = 8;
int32_t IGUANA_NUMHELPERS = 16;
#else
int32_t IGUANA_NUMHELPERS = 1;
int32_t IGUANA_NUMHELPERS = 8;
#endif
char *hash_parser(struct supernet_info *myinfo,char *hashname,cJSON *json,char *remoteaddr)

Loading…
Cancel
Save