Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
6378b2e1a2
  1. 4
      iguana/iguana777.h
  2. 2
      iguana/iguana_blocks.c
  3. 2
      iguana/iguana_bundles.c
  4. 4
      iguana/iguana_ramchain.c
  5. 48
      iguana/iguana_recv.c
  6. 4
      iguana/main.c

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 8
#define IGUANA_MINPENDBUNDLES 64
#define IGUANA_MAXPENDBUNDLES 64
#define IGUANA_MINPENDBUNDLES 100
#define IGUANA_MAXPENDBUNDLES 128
#define IGUANA_BUNDLELOOP 10000
#define IGUANA_RPCPORT 7778
#define IGUANA_MAXRAMCHAINSIZE ((uint64_t)1024L * 1024L * 1024L * 16)

2
iguana/iguana_blocks.c

@ -51,7 +51,7 @@ struct iguana_block *iguana_blockhashset(struct iguana_info *coin,int32_t height
struct iguana_block *block,*prev;
if ( height > 0 && (height > coin->blocks.maxbits || depth != 0) )
{
printf("illegal height.%d when max.%d, depth.%d\n",height,coin->blocks.maxbits,depth);
printf("illegal height.%d when max.%d, or nonz depth.%d\n",height,coin->blocks.maxbits,depth);
//getchar();
return(0);
}

2
iguana/iguana_bundles.c

@ -146,7 +146,7 @@ int32_t iguana_hash2set(struct iguana_info *coin,char *debugstr,struct iguana_bu
bits256_str(str2,*orighash2p), bits256_str(str3,newhash2);
printf("WARNING iguana_hash2set REFUSE overwrite [%s] %s with %s [%d:%d]\n",debugstr,str2,str3,bp->hdrsi,bundlei);
//*orighash2p = newhash2;
//getchar();
// getchar();
return(-1);
}
if ( isinside != 0 )

4
iguana/iguana_ramchain.c

@ -1809,7 +1809,9 @@ long iguana_ramchain_data(struct iguana_info *coin,struct iguana_peer *addr,stru
}
if ( (block= bp->blocks[bundlei]) == 0 || bits256_cmp(block->RO.hash2,origtxdata->block.RO.hash2) != 0 || bits256_cmp(bp->hashes[bundlei],origtxdata->block.RO.hash2) != 0 )
{
char str[65]; printf("%d:%d has no block ptr.%p %s or wrong hash\n",bp->hdrsi,bundlei,block,bits256_str(str,origtxdata->block.RO.hash2));
char str[65];
if ( block != 0 )
printf("%d:%d has no block ptr.%p %s or wrong hash\n",bp->hdrsi,bundlei,block,bits256_str(str,origtxdata->block.RO.hash2));
return(-1);
}
if ( block->fpipbits != 0 )

48
iguana/iguana_recv.c

@ -465,7 +465,7 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct iguana_bundle *bp,int
char str[64];
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1);
}
else if ( time(NULL) > bp->lastspeculative+60 )
else if ( time(NULL) > bp->lastspeculative+600 )
{
for (i=1,counter=0; i<bp->n; i++)
if ( bits256_nonz(bp->hashes[i]) == 0 && bits256_nonz(bp->speculative[i]) > 0 )
@ -811,9 +811,14 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana
{
struct iguana_bundle *bp=0; int32_t bundlei = -2; struct iguana_block *block;
bp = iguana_bundleset(coin,&block,&bundlei,origblock);
static int total; char str[65];
if ( 0 )//bundlei == 1 || bp == coin->current )
fprintf(stderr,"blockRECV %s [%d:%d] block.%08x | %d\n",bits256_str(str,origblock->RO.hash2),bp!=0?bp->hdrsi:-1,bundlei,block->fpipbits,total++);
if ( bp != 0 && bundlei > 0 && bits256_nonz(origblock->RO.prev_block) > 0 && bits256_cmp(origblock->RO.prev_block,bp->hashes[bundlei-1]) != 0 )
{
printf("backfill [%d:%d]\n",bp->hdrsi,bundlei-1);
bp->hashes[bundlei-1] = origblock->RO.prev_block;
}
char str[65];
if ( 0 && bundlei >= 0 )
fprintf(stderr,"blockRECV %s [%d:%d] block.%08x | h.%d\n",bits256_str(str,origblock->RO.hash2),bp!=0?bp->hdrsi:-1,bundlei,block->fpipbits,bp!=0?bp->numhashes:-1);
if ( bundlei == 1 && bp != 0 && bp->numhashes < bp->n )
{
//printf("reissue hdrs request for [%d]\n",bp->hdrsi);
@ -821,18 +826,18 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana
}
if ( block != 0 )
{
if ( 0 && block->mainchain != 0 && bp != 0 && bits256_nonz(block->RO.prev_block) > 0 && bits256_nonz(bp->hashes[bundlei-1]) == 0 )
if ( 0&&bp != 0 && bundlei > 0 && bits256_nonz(block->RO.prev_block) > 0 && bits256_cmp(block->RO.prev_block,bp->hashes[bundlei-1]) != 0 )
{
if ( bundlei > 0 )
{
printf("backfill [%d:%d]\n",bp->hdrsi,bundlei-1);
bp->hashes[bundlei-1] = block->RO.prev_block;
}
else if ( bp->hdrsi > 0 && coin->bundles[bp->hdrsi-1] != 0 )
/*else if ( bp->hdrsi > 0 && coin->bundles[bp->hdrsi-1] != 0 )
{
printf("prev backfill [%d:%d]\n",bp->hdrsi-1,coin->chain->bundlesize-1);
iguana_blockQ(coin,coin->bundles[bp->hdrsi-1],coin->chain->bundlesize-1,block->RO.prev_block,0);
}
}*/
//iguana_blockQ(coin,bundlei > 0 ? bp : 0,bundlei-1,block->RO.prev_block,0);
//printf("recv autoreq prev [%d:%d]\n",bp!=0?bp->hdrsi:-1,bundlei);
}
@ -1247,21 +1252,25 @@ int32_t iguana_reqblocks(struct iguana_info *coin)
_iguana_chainlink(coin,next);
else if ( next->queued == 0 && next->fpipbits == 0 )
{
//printf("HWM next %d\n",coin->blocks.hwmchain.height+1);
//iguana_blockQ(coin,bp,bundlei,next->RO.hash2,0);
printf("HWM next %d\n",coin->blocks.hwmchain.height+1);
iguana_blockQ(coin,bp,bundlei,next->RO.hash2,0);
}
}
else
else if ( iguana_blockfind(coin,bp->hashes[bundlei]) == 0 )
{
if ( bits256_nonz(bp->hashes[bundlei]) > 0 )
/*if ( bits256_nonz(bp->hashes[bundlei]) > 0 )
{
//printf("next %d\n",coin->blocks.hwmchain.height+1);
//iguana_blockQ(coin,bp,bundlei,bp->hashes[bundlei],0);
printf("next %d\n",coin->blocks.hwmchain.height+1);
iguana_blockQ(coin,bp,bundlei,bp->hashes[bundlei],0);
}
else if ( bp->speculative != 0 && bits256_nonz(bp->speculative[bundlei]) > 0 )
else*/ if ( bp->speculative != 0 && bits256_cmp(bp->hashes[bundlei],bp->speculative[bundlei]) != 0 )
{
//printf("speculative next %d\n",coin->blocks.hwmchain.height+1);
//iguana_blockQ(coin,0,-1,bp->speculative[bundlei],0);
if ( iguana_blockfind(coin,bp->speculative[bundlei]) == 0 )
{
bp->hashes[bundlei] = bp->speculative[bundlei];
printf("speculative next %d\n",coin->blocks.hwmchain.height+1);
iguana_blockQ(coin,0,-1,bp->speculative[bundlei],0);
}
}
}
}
@ -1322,9 +1331,14 @@ int32_t iguana_reqblocks(struct iguana_info *coin)
iguana_blockQ(coin,bp,bundlei,bp->hashes[bundlei],0);
flag++;
char str[65];
if ( 1 && (rand() % 1000) == 0 )
//if ( 1 && (rand() % 1000) == 0 )
printf("%s MAINCHAIN.%d threshold %.3f %.3f lag %.3f\n",bits256_str(str,hash2),coin->blocks.hwmchain.height+1,threshold,coin->backstopmillis,lag);
}
else if ( bp != 0 && bundlei < bp->n-1 && bits256_nonz(bp->hashes[bundlei+1]) > 0 )
{
printf("MAINCHAIN skip issue %d\n",bundlei+1);
iguana_blockQ(coin,bp,bundlei,bp->hashes[bundlei+1],0);
}
}
}
}

4
iguana/main.c

@ -1131,10 +1131,10 @@ 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\":512,\"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\":1024,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":1,\"poll\":1}"),0)) != 0 )
{
free(str);
if ( 0 && (str= SuperNET_JSON(&MYINFO,cJSON_Parse("{\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":256,\"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 )
{
free(str);
if ( 0 && (str= SuperNET_JSON(&MYINFO,cJSON_Parse("{\"agent\":\"SuperNET\",\"method\":\"login\",\"handle\":\"alice\",\"password\":\"alice\",\"passphrase\":\"alice\"}"),0)) != 0 )

Loading…
Cancel
Save