Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
8cf5eeec91
  1. 10
      iguana/iguana_bundles.c
  2. 17
      iguana/iguana_unspents.c

10
iguana/iguana_bundles.c

@ -511,7 +511,7 @@ int32_t iguana_blocksmissing(struct iguana_info *coin,int32_t *nonzp,uint8_t mis
int32_t iguana_sendhashes(struct iguana_info *coin,struct iguana_peer *addr,int32_t msgtype,bits256 hashes[],int32_t n,int32_t priority)
{
int32_t len; uint8_t *serialized;
if ( priority > 1 )
if ( addr->usock >= 0 && addr->dead == 0 && priority > 1 )
{
serialized = malloc((sizeof(int32_t) + sizeof(*hashes))*n + 1024);
if ( (len= iguana_getdata(coin,serialized,MSG_BLOCK,hashes,n)) > 0 )
@ -565,7 +565,7 @@ int32_t iguana_bundlerequests(struct iguana_info *coin,uint8_t missings[IGUANA_M
//printf("n.%d avail.%d numpeers.%d\n",n,avail,numpeers);
for (i=0; i<numpeers && avail>0; i++)
{
if ( (addr= peers[i]) != 0 && (c= (coin->MAXPENDINGREQUESTS - addr->pendblocks)) > 0 )
if ( (addr= peers[i]) != 0 && addr->usock >= 0 && addr->dead == 0 && (c= (coin->MAXPENDINGREQUESTS - addr->pendblocks)) > 0 )
{
if ( c+m > max )
c = max - m;
@ -949,15 +949,17 @@ int32_t iguana_cacheprocess(struct iguana_info *coin,struct iguana_bundle *bp,in
void iguana_unstickhdr(struct iguana_info *coin,struct iguana_bundle *bp,int32_t lag)
{
int32_t datalen,m; uint8_t serialized[512]; char str[65]; struct iguana_peer *addr;
int32_t datalen,m,i; uint8_t serialized[512]; char str[65]; struct iguana_peer *addr;
if ( (m= coin->peers.numranked) > 0 && bp->numhashes < bp->n && bp->hdrsi < coin->longestchain/coin->chain->bundlesize && time(NULL) > bp->unsticktime+lag )
{
if ( (addr= coin->peers.ranked[rand() % m]) != 0 && (datalen= iguana_gethdrs(coin,serialized,coin->chain->gethdrsmsg,bits256_str(str,bp->hashes[0]))) > 0 )
for (i=0; i<10; i++)
if ( (addr= coin->peers.ranked[rand() % m]) != 0 && addr->usock >= 0 && addr->dead == 0 && (datalen= iguana_gethdrs(coin,serialized,coin->chain->gethdrsmsg,bits256_str(str,bp->hashes[0]))) > 0 )
{
//printf("UNSTICK HDR.[%d]\n",bp->hdrsi);
iguana_send(coin,addr,serialized,datalen);
addr->pendhdrs++;
bp->unsticktime = (uint32_t)time(NULL);
break;
}
}
}

17
iguana/iguana_unspents.c

@ -1839,7 +1839,7 @@ void iguana_RThdrs(struct iguana_info *coin,struct iguana_bundle *bp,int32_t num
for (i=0; i<numaddrs && i<coin->peers.numranked; i++)
{
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1);
if ( (addr= coin->peers.ranked[i]) != 0 && (datalen= iguana_gethdrs(coin,serialized,coin->chain->gethdrsmsg,bits256_str(str,bp->hashes[0]))) > 0 )
if ( (addr= coin->peers.ranked[i]) != 0 && addr->usock >= 0 && addr->dead == 0 && (datalen= iguana_gethdrs(coin,serialized,coin->chain->gethdrsmsg,bits256_str(str,bp->hashes[0]))) > 0 )
{
printf("%s UNSTICK HDR.[%d]\n",addr->ipaddr,bp->hdrsi);
iguana_send(coin,addr,serialized,datalen);
@ -1871,10 +1871,10 @@ void iguana_RTspendvectors(struct iguana_info *coin,struct iguana_bundle *bp,str
int32_t iguana_realtime_update(struct iguana_info *coin)
{
double startmillis0; static double totalmillis0; static int32_t num0;
struct iguana_bundle *bp; struct iguana_ramchaindata *rdata; int32_t bundlei,i,n,flag=0; bits256 hash2; struct iguana_peer *addr;
struct iguana_bundle *bp; struct iguana_ramchaindata *rdata; int32_t bundlei,i,j,n,flag=0; bits256 hash2; struct iguana_peer *addr;
struct iguana_block *block=0; struct iguana_blockRO *B; struct iguana_ramchain *dest=0,blockR;
//starti = coin->RTheight % coin->chain->bundlesize;
if ( (bp= coin->current) != 0 && bp->hdrsi == coin->longestchain/coin->chain->bundlesize && bp->hdrsi == coin->balanceswritten && coin->RTheight >= bp->bundleheight && coin->RTheight < bp->bundleheight+bp->n && (coin->RTheight <= coin->blocks.hwmchain.height || time(NULL) > bp->lastRT+10) )
if ( (bp= coin->current) != 0 && bp->hdrsi == coin->longestchain/coin->chain->bundlesize && bp->hdrsi == coin->balanceswritten && coin->RTheight >= bp->bundleheight && coin->RTheight < bp->bundleheight+bp->n && ((coin->RTheight <= coin->blocks.hwmchain.height && time(NULL) > bp->lastRT) || time(NULL) > bp->lastRT+10) )
{
printf("check RTheight.%d hwm.%d longest.%d\n",coin->RTheight,coin->blocks.hwmchain.height,coin->longestchain);
if ( bits256_cmp(coin->RThash1,bp->hashes[1]) != 0 )
@ -1886,8 +1886,15 @@ int32_t iguana_realtime_update(struct iguana_info *coin)
coin->RThdrstime = bp->lastRT;
for (i=0; i<coin->peers.numranked; i++)
{
if ( (addr= coin->peers.ranked[i]) != 0 )
if ( (addr= coin->peers.ranked[i]) != 0 && addr->usock >= 0 && addr->dead == 0 )
{
printf("%d ",addr->numRThashes);
for (j=coin->RTheight; j<addr->numRThashes; j++)
{
if ( (block= bp->blocks[j]) == 0 || block->txvalid == 0 )
iguana_blockQ("RT",coin,bp,j,block->RO.hash2,1);
}
}
}
printf("RTheaders\n");
}
@ -1914,7 +1921,7 @@ int32_t iguana_realtime_update(struct iguana_info *coin)
uint8_t serialized[512]; int32_t len; struct iguana_peer *addr;
char str[65]; printf("RT error [%d:%d] %s %p\n",bp->hdrsi,i,bits256_str(str,hash2),block);
addr = coin->peers.ranked[rand() % 8];
if ( addr != 0 && (len= iguana_getdata(coin,serialized,MSG_BLOCK,&hash2,1)) > 0 )
if ( addr != 0 && addr->usock >= 0 && addr->dead == 0 && (len= iguana_getdata(coin,serialized,MSG_BLOCK,&hash2,1)) > 0 )
iguana_send(coin,addr,serialized,len);
coin->RTgenesis = 0;
}

Loading…
Cancel
Save