Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
05131e0966
  1. 50
      iguana/iguana_bundles.c
  2. 49
      iguana/iguana_recv.c
  3. 1
      includes/iguana_funcs.h

50
iguana/iguana_bundles.c

@ -1242,6 +1242,47 @@ void iguana_bundlemissings(struct iguana_info *coin,struct iguana_bundle *bp,uin
}
}
int32_t iguana_bundlehash2_check(struct iguana_info *coin,bits256 hash2)
{
struct iguana_bundle *bp; int32_t j,flag=0; struct iguana_block *block;
if ( bits256_nonz(hash2) == 0 )
return(-1);
if ( (bp= coin->current) != 0 )
{
for (j=0; j<bp->n; j++)
{
if ( j < bp->numspec && bp->speculative != 0 && bits256_cmp(bp->speculative[j],hash2) == 0 )
{
flag = 1;
if ( (block= iguana_blockfind("hashspec",coin,hash2)) != 0 )
{
if ( block->mainchain != 0 && block->txvalid != 0 && block->hdrsi != bp->hdrsi )
{
printf("found [%d:%d] in [%d:%d]'s place\n",block->hdrsi,block->bundlei,bp->hdrsi,j);
memset(&bp->speculative[j],0,sizeof(bp->speculative[j]));
}
}
break;
}
if ( bits256_cmp(bp->hashes[j],hash2) == 0 )
{
flag = 1;
if ( (block= iguana_blockfind("hashspec",coin,hash2)) != 0 )
{
if ( block->mainchain != 0 && block->txvalid != 0 && block->hdrsi != bp->hdrsi )
{
printf("found [%d:%d] in [%d:%d]'s place\n",block->hdrsi,block->bundlei,bp->hdrsi,j);
memset(&bp->hashes[j],0,sizeof(bp->hashes[j]));
bp->blocks[j] = 0;
}
}
break;
}
}
}
return(flag);
}
void iguana_bundlestats(struct iguana_info *coin,char *str,int32_t lag)
{
int32_t i,n,m,j,numv,numconverted,count,starti,lasti,pending,capacity,displag,numutxo,numbalances,numrecv,done,numhashes,numcached,numsaved,numemit; struct iguana_block *block; bits256 hash2;
@ -1489,6 +1530,15 @@ void iguana_bundlestats(struct iguana_info *coin,char *str,int32_t lag)
// myallocated(0,0);
coin->lastdisp = (uint32_t)time(NULL);
}
if ( (bp= coin->current) != 0 && coin->RTheight >= bp->bundleheight && coin->RTheight < bp->bundleheight+bp->n )
{
for (i=coin->RTheight-bp->bundleheight; i<bp->n; i++)
{
iguana_bundlehash2_check(coin,bp->hashes[i]);
if ( bp->speculative != 0 )
iguana_bundlehash2_check(coin,bp->speculative[i]);
}
}
iguana_setmaxbundles(coin);
strcpy(coin->statusstr,str);
coin->estsize = estsize;

49
iguana/iguana_recv.c

@ -315,7 +315,7 @@ void iguana_bundletime(struct iguana_info *coin,struct iguana_bundle *bp,int32_t
void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_txblock *origtxdata,struct iguana_msgtx *txarray,struct iguana_msghdr *H,uint8_t *data,int32_t recvlen,int32_t fromcache)
{
struct iguana_bundlereq *req; struct iguana_txblock *txdata = 0; int32_t valid,speculative=0,i,j,bundlei,copyflag,numtx; struct iguana_block *block; struct iguana_bundle *bp; uint32_t now; char str[65];
struct iguana_bundlereq *req; struct iguana_txblock *txdata = 0; int32_t valid,speculative=0,i,j,bundlei,copyflag,numtx,len; struct iguana_block *block; struct iguana_bundle *bp; uint32_t now; char str[65];
if ( recvlen < 0 || recvlen > IGUANA_MAXPACKETSIZE )
{
printf("iguana_getblockM: illegal recvlen.%d\n",recvlen);
@ -523,7 +523,7 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i
netBLOCKS++;
}
req->addr = addr;
if ( req->zblock.mainchain == 0 )
if ( req->zblock.mainchain == 0 && iguana_RTrawdata(coin,origtxdata->zblock.RO.hash2,0,&len,&numtx,1) == 0 )
queue_enqueue("recvQ",&coin->recvQ,&req->DL,0);
}
}
@ -793,8 +793,8 @@ int32_t iguana_height_estimate(struct iguana_info *coin,struct iguana_block **ma
{
if ( tmp->mainchain != 0 )
{
char str[65];
printf("%s found mainchain.%d dist.%d\n",bits256_str(str,block->RO.hash2),tmp->height,n);
//char str[65];
//printf("%s found mainchain.%d dist.%d\n",bits256_str(str,block->RO.hash2),tmp->height,n);
*mainchainp = tmp;
return(tmp->height + n);
}
@ -825,7 +825,7 @@ struct iguana_bundle *iguana_bundleset(struct iguana_info *coin,struct iguana_bl
*blockp = block;
if ( coin->firstRTheight > 0 && coin->blocks.hwmchain.height > 0 && (hwmblock= iguana_blockfind("hwm",coin,coin->blocks.hwmchain.RO.hash2)) != 0 )
{
if ( (newheight= iguana_height_estimate(coin,&mainchain,block)) >= coin->blocks.hwmchain.height )
if ( (newheight= iguana_height_estimate(coin,&mainchain,block)) >= coin->blocks.hwmchain.height || newheight == coin->RTheight )
{
iguana_mainchain_clear(coin,mainchain,hwmblock,coin->blocks.hwmchain.height-mainchain->height);
tmp = block;
@ -1182,45 +1182,10 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct iguana_info *coin,struct
}
if ( coin->RTheight > 0 )
{
int32_t j,flag;
for (i=1; i<num; i++)
{
flag = 0;
if ( (bp= coin->current) != 0 )
{
for (j=0; j<bp->n; j++)
{
if ( j < bp->numspec && bp->speculative != 0 && bits256_cmp(bp->speculative[j],blockhashes[i]) == 0 )
{
flag = 1;
if ( (block= iguana_blockfind("hashspec",coin,blockhashes[i])) != 0 )
{
if ( block->mainchain != 0 && block->txvalid != 0 && block->hdrsi != bp->hdrsi )
{
printf("found [%d:%d] in [%d:%d]'s place\n",block->hdrsi,block->bundlei,bp->hdrsi,j);
memset(&bp->speculative[j],0,sizeof(bp->speculative[j]));
}
}
break;
}
if ( bits256_cmp(bp->hashes[j],blockhashes[i]) == 0 )
{
flag = 1;
if ( (block= iguana_blockfind("hashspec",coin,blockhashes[i])) != 0 )
{
if ( block->mainchain != 0 && block->txvalid != 0 && block->hdrsi != bp->hdrsi )
{
printf("found [%d:%d] in [%d:%d]'s place\n",block->hdrsi,block->bundlei,bp->hdrsi,j);
memset(&bp->hashes[j],0,sizeof(bp->hashes[j]));
bp->blocks[j] = 0;
}
}
break;
}
}
}
if ( flag == 0 )
iguana_sendblockreqPT(coin,addr,0,-1,blockhashes[i],0);
if ( iguana_bundlehash2_check(coin,blockhashes[i]) == 0 )
iguana_blockQ("recvhashRT",coin,0,-7,blockhashes[1],1);
}
}
return(req);

1
includes/iguana_funcs.h

@ -547,6 +547,7 @@ void iguana_RTreset(struct iguana_info *coin);
void iguana_RTpurge(struct iguana_info *coin,int32_t lastheight);
void iguana_RTnewblock(struct iguana_info *coin,struct iguana_block *block);
void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int32_t *recvlenp,int32_t *numtxp,int32_t checkonly);
int32_t iguana_bundlehash2_check(struct iguana_info *coin,bits256 hash2);
void iguana_RTramchainalloc(char *fname,struct iguana_info *coin,struct iguana_bundle *bp);
void iguana_update_balances(struct iguana_info *coin);
void iguana_RTspendvectors(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp);

Loading…
Cancel
Save