Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
2a0acbeecb
  1. 8
      iguana/iguana777.c
  2. 4
      iguana/iguana777.h
  3. 2
      iguana/iguana_bundles.c
  4. 24
      iguana/iguana_recv.c
  5. 2
      iguana/main.c

8
iguana/iguana777.c

@ -370,14 +370,14 @@ void iguana_helper(void *arg)
{
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;
type = rand();
if ( arg != 0 && (argjson= cJSON_Parse(arg)) != 0 )
helpername = jstr(argjson,"name");
if ( helpername == 0 )
{
sprintf(name,"helper.%d",rand());
sprintf(name,"%d",rand());
helpername = name;
}
type = (name[0] % 2);
sprintf(fname,"%s/%s",GLOBALTMPDIR,helpername);
OS_compatible_path(fname);
fp = fopen(fname,"wb");
@ -389,7 +389,7 @@ void iguana_helper(void *arg)
{
//iguana_jsonQ();
flag = 0;
if ( (type % 2) == 0 && ((ptr= queue_dequeue(&emitQ,0)) != 0 || (ptr= queue_dequeue(&helperQ,0)) != 0) )
if ( type == 0 && ((ptr= queue_dequeue(&emitQ,0)) != 0 || (ptr= queue_dequeue(&helperQ,0)) != 0) )
{
if ( ptr->bp != 0 && (coin= ptr->coin) != 0 )
{
@ -401,7 +401,7 @@ void iguana_helper(void *arg)
}
myfree(ptr,ptr->allocsize);
}
else if ( (type % 2) == 1 && (ptr= queue_dequeue(&bundlesQ,0)) != 0 )
else if ( type == 1 && (ptr= queue_dequeue(&bundlesQ,0)) != 0 )
{
idle = 0;
if ( ptr->bp != 0 && ptr->coin != 0 )

4
iguana/iguana777.h

@ -38,8 +38,8 @@ typedef int32_t (*blockhashfunc)(uint8_t *blockhashp,uint8_t *serialized,int32_t
#define IGUANA_TAILPERCENTAGE 1.0
#define IGUANA_MAXPENDHDRS 1
#define _IGUANA_MAXPENDING 3
#define IGUANA_MINPENDBUNDLES 16
#define IGUANA_MAXPENDBUNDLES 100
#define IGUANA_MINPENDBUNDLES 64
#define IGUANA_MAXPENDBUNDLES 64
#define IGUANA_BUNDLELOOP 77
#define IGUANA_RPCPORT 7778
#define IGUANA_MAXRAMCHAINSIZE ((uint64_t)1024L * 1024L * 1024L * 16)

2
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);
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);
if ( 0 )
{

24
iguana/iguana_recv.c

@ -189,7 +189,7 @@ 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.%s\n",bits256_str(str,origtxdata->block.RO.hash2));
} else printf("validated.%s\n",bits256_str(str,origtxdata->block.RO.hash2));
copyflag = 1 * (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)) )
@ -449,15 +449,15 @@ struct iguana_bundle *iguana_bundleset(struct iguana_info *coin,struct iguana_bl
// iguana_patch(coin,block);
if ( (bp= iguana_bundlefind(coin,&bp,&bundlei,hash2)) != 0 && bundlei < coin->chain->bundlesize )
{
//fprintf(stderr,"bundle found %d:%d\n",bp->hdrsi,bundlei);
fprintf(stderr,"bundle found %d:%d\n",bp->hdrsi,bundlei);
block->bundlei = bundlei;
block->hdrsi = bp->hdrsi;
bp->blocks[bundlei] = block;
//printf("bundlehashadd set.%d\n",bundlei);
printf("bundlehashadd set.%d\n",bundlei);
iguana_bundlehash2add(coin,0,bp,bundlei,hash2);
if ( bundlei > 0 )
{
//printf("bundlehashadd prev %d\n",bundlei);
printf("bundlehashadd prev %d\n",bundlei);
iguana_bundlehash2add(coin,0,bp,bundlei-1,prevhash2);
}
else if ( bp->hdrsi > 0 && (bp= coin->bundles[bp->hdrsi-1]) != 0 )
@ -612,7 +612,7 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct iguana_info *coin,struct
}
else if ( num >= coin->chain->bundlesize )
{
for (i=0; i<coin->bundlescount; i++)
for (i=coin->bundlescount-1; i>=0; i--)
{
if ( (bp= coin->bundles[i]) != 0 && bp->emitfinish == 0 )
{
@ -628,17 +628,23 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct iguana_info *coin,struct
iguana_blockQ("recvhash2",coin,bp,1,blockhashes[1],0);
iguana_blockQ("recvhash3",coin,bp,0,blockhashes[0],0);
iguana_blockQ("recvhash4",coin,bp,coin->chain->bundlesize-1,blockhashes[coin->chain->bundlesize-1],0);
//printf("matched bundle.%d\n",bp->bundleheight);
printf("matched bundle.%d\n",bp->bundleheight);
return(req);
} else printf("unexpected mismatch??\n");
}
}
}
//printf("no match to allhashes issue block1\n");
printf("no match to allhashes issue block1\n");
struct iguana_block *block;
if ( num == coin->chain->bundlesize+1 && (block= iguana_blockhashset(coin,-1,blockhashes[1],1)) != 0 )
{
block->blockhashes = blockhashes, req->hashes = 0;
iguana_blockQ("recvhash5",coin,0,-5,blockhashes[1],0);
printf("set block->blockhashes[%d]\n",num);
}
iguana_blockQ("recvhash5",coin,0,-1,blockhashes[1],0);
iguana_blockQ("recvhash5",coin,0,-1,blockhashes[1],1);
if ( coin->peers.ranked[0] != 0 )
iguana_sendblockreqPT(coin,coin->peers.ranked[0],0,-1,blockhashes[1],0);
} else iguana_blockQ("recvhash6",coin,0,-6,blockhashes[1],0); // should be RT block
return(req);
}
@ -648,7 +654,7 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana
struct iguana_bundle *bp=0; int32_t numsaved=0,bundlei = -2; struct iguana_block *block,*tmpblock;
bp = iguana_bundleset(coin,&block,&bundlei,origblock);
char str[65];
if ( 1 && bp != 0 && bp->hdrsi == coin->bundlescount-1 )
//if ( 1 && bp != 0 && bp->hdrsi == coin->bundlescount-1 )
{
int32_t i; static int32_t numrecv;
numrecv++;

2
iguana/main.c

@ -1142,7 +1142,7 @@ void iguana_main(void *arg)
IGUANA_NUMHELPERS = 1;
for (i=0; i<IGUANA_NUMHELPERS; i++)
{
sprintf(helperstr,"{\"name\":\"helper.%d\"}",i);
sprintf(helperstr,"{\"name\":\"%d\"}",i);
helperargs = clonestr(helperstr);
iguana_launch(iguana_coinadd("BTCD",0),"iguana_helper",iguana_helper,helperargs,IGUANA_PERMTHREAD);
}

Loading…
Cancel
Save