Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
bad6db52e5
  1. 3
      iguana/iguana777.h
  2. 9
      iguana/iguana_bundles.c
  3. 20
      iguana/iguana_recv.c
  4. 2
      iguana/main.c

3
iguana/iguana777.h

@ -43,7 +43,7 @@ typedef int32_t (*blockhashfunc)(uint8_t *blockhashp,uint8_t *serialized,int32_t
#define IGUANA_TAILPERCENTAGE 1.0
#define IGUANA_MAXPENDHDRS 1
#define IGUANA_MAXPENDINGREQUESTS 2
#define IGUANA_PENDINGREQUESTS 512
#define IGUANA_PENDINGREQUESTS 32
#define IGUANA_MINPENDBUNDLES 2
#define IGUANA_MAXPENDBUNDLES 128
#define IGUANA_BUNDLELOOP 77
@ -842,6 +842,7 @@ int32_t iguana_reqblocks(struct iguana_info *coin);
void iguana_walletlock(struct supernet_info *myinfo);
int32_t _SuperNET_encryptjson(char *destfname,char *passphrase,int32_t passsize,char *fname2fa,int32_t fnamesize,cJSON *argjson);
int32_t bitcoin_pubkeylen(const uint8_t *pubkey);
struct iguana_block *iguana_bundleblock(struct iguana_info *coin,bits256 *hash2p,struct iguana_bundle *bp,int32_t i);
extern int32_t HDRnet,netBLOCKS;

9
iguana/iguana_bundles.c

@ -596,24 +596,25 @@ int32_t iguana_bundleready(struct iguana_info *coin,struct iguana_bundle *bp)
void iguana_bundleissuemissing(struct iguana_info *coin,struct iguana_bundle *bp,uint8_t *missings)
{
int32_t i; bits256 hash2;
int32_t i,tmp,tmp2; bits256 hash2;
for (i=0; i<bp->n; i++)
{
if ( GETBIT(missings,i) != 0 )
{
if ( bits256_nonz(bp->hashes[i]) != 0 )
hash2 = bp->hashes[i];
else if ( bits256_nonz(bp->hashes[i]) != 0 && bp->speculative != 0 )
else if ( bp->speculative != 0 && bits256_nonz(bp->speculative[i]) != 0 )
hash2 = bp->speculative[i];
else continue;
if ( bits256_nonz(hash2) != 0 )
{
if ( 0 && bp == coin->current )
printf("issue.[%d:%d]\n",bp->hdrsi,i);
printf("iguana_bundleissuemissing.[%d:%d]\n",bp->hdrsi,i);
iguana_blockQ("missings",coin,bp,i,hash2,1);
}
}
}
iguana_bundlerequests(coin,missings,&tmp,&tmp2,bp,3,3);
}
int32_t iguana_bundlehdr(struct iguana_info *coin,struct iguana_bundle *bp,int32_t starti)
@ -631,7 +632,7 @@ int32_t iguana_bundlehdr(struct iguana_info *coin,struct iguana_bundle *bp,int32
if ( bp == coin->current && bp->speculative != 0 )
{
printf("iguana_bundlehdr.[%d] %d %s\n",bp->hdrsi,bp->numspec,bits256_str(str,bp->hashes[0]));
if ( iguana_blocksmissing(coin,&avail,missings,0,bp,0,IGUANA_DEFAULTLAG) > 0 )
if ( iguana_blocksmissing(coin,&avail,missings,0,bp,0,3) > 0 )
iguana_bundleissuemissing(coin,bp,missings);
}
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1);

20
iguana/iguana_recv.c

@ -314,7 +314,7 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i
uint64_t sum2 = 0,sum = 0;
for (i=0; i<sizeof(received)/sizeof(*received); i++)
sum += received[i], sum2 += count[i];
//char str[65],str2[65],str3[65]; printf("TOTAL BLOCKS.%llu RECEIVED %s ave %.1f | duplicates.%d %s afteremit.%d %s\n",(long long)sum2,mbstr(str,sum),(double)sum/(sum2!=0?sum2:1),numDuplicates,mbstr(str2,sizeDuplicates),numAfteremit,mbstr(str3,sizeAfteremit));
char str[65],str2[65],str3[65]; printf("TOTAL BLOCKS.%llu RECEIVED %s ave %.1f | duplicates.%d %s afteremit.%d %s\n",(long long)sum2,mbstr(str,sum),(double)sum/(sum2!=0?sum2:1),numDuplicates,mbstr(str2,sizeDuplicates),numAfteremit,mbstr(str3,sizeAfteremit));
}
}
copyflag = 0;//(coin->enableCACHE != 0) && (strcmp(coin->symbol,"BTC") != 0);
@ -328,7 +328,7 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i
sizeAfteremit += recvlen;
if ( (block= bp->blocks[bundlei]) != 0 )
iguana_bundletime(coin,bp,bundlei,block,1);
//printf("got [%d:%d] with emitfinish.%u\n",bp->hdrsi,bundlei,bp->emitfinish);
printf("got [%d:%d] with emitfinish.%u\n",bp->hdrsi,bundlei,bp->emitfinish);
return;
}
bp->dirty++;
@ -339,13 +339,14 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i
numDuplicates++;
sizeDuplicates += recvlen;
iguana_bundletime(coin,bp,bundlei,block,1);
//printf("duplicate [%d:%d] %s\n",bp->hdrsi,bundlei,bits256_str(str,block->RO.hash2));
printf("duplicate [%d:%d] %s\n",bp->hdrsi,bundlei,bits256_str(str,block->RO.hash2));
if ( bits256_cmp(origtxdata->block.RO.hash2,block->RO.hash2) == 0 )
return;
else printf("mismatched tx received? mainchain.%d\n",block->mainchain);
if ( block->mainchain != 0 )
return;
} //else printf("recv [%d:%d] %s\n",bp->hdrsi,bundlei,bits256_str(str,block->RO.hash2));
} else if ( bp == coin->current )
printf("recv [%d:%d] %s\n",bp->hdrsi,bundlei,bits256_str(str,block->RO.hash2));
iguana_bundletime(coin,bp,bundlei,block,0);
block->RO = origtxdata->block.RO;
block->txvalid = 1;
@ -934,13 +935,20 @@ 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 *bp=0,*prev; int32_t numsaved=0,bundlei = -2; struct iguana_block *block,*tmpblock; char str[65];
struct iguana_bundle *bp=0,*prev; int32_t numsaved=0,bundlei = -2; struct iguana_block *block,*tmpblock; char str[65]; bits256 hash2;
if ( (bp= iguana_bundleset(coin,&block,&bundlei,origblock)) != 0 && bp == coin->current && block != 0 && bp->speculative != 0 && bundlei >= 0 )
{
if ( bp->speculative != 0 && bp->numspec <= bundlei )
{
bp->speculative[bundlei] = block->RO.hash2;
bp->numspec = bundlei+1;
while ( bundlei < bp->n && block != 0 && bp->bundleheight+bundlei == coin->blocks.hwmchain.height+1 && _iguana_chainlink(coin,block) != 0 )
{
printf("MAIN.%d ",bp->bundleheight+bundlei);
bundlei++;
block = iguana_bundleblock(coin,&hash2,bp,bundlei);
}
printf("autoadd [%d:%d]\n",bp->hdrsi,bundlei);
}
}
if ( bp != 0 )
@ -950,7 +958,7 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana
{
if ( (prev= coin->bundles[bp->hdrsi - 1]) != 0 )
{
printf("found adjacent [%d:%d] speculative.%p\n",prev->hdrsi,bp->n-1,prev->speculative);
//printf("found adjacent [%d:%d] speculative.%p\n",prev->hdrsi,bp->n-1,prev->speculative);
}
}
}

2
iguana/main.c

@ -46,7 +46,7 @@ cJSON *API_json;
#ifdef __linux__
int32_t IGUANA_NUMHELPERS = 16;
#else
int32_t IGUANA_NUMHELPERS = 3;
int32_t IGUANA_NUMHELPERS = 8;
#endif
struct iguana_jsonitem { struct queueitem DL; struct supernet_info *myinfo; uint32_t fallback,expired,allocsize; char **retjsonstrp; char remoteaddr[64]; uint16_t port; char jsonstr[]; };

Loading…
Cancel
Save