|
|
@ -919,9 +919,24 @@ int32_t iguana_cacheprocess(struct iguana_info *coin,struct iguana_bundle *bp,in |
|
|
|
return(-1); |
|
|
|
} |
|
|
|
|
|
|
|
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; |
|
|
|
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 ) |
|
|
|
{ |
|
|
|
printf("UNSTICK HDR.[%d]\n",bp->hdrsi); |
|
|
|
iguana_send(coin,addr,serialized,datalen); |
|
|
|
addr->pendhdrs++; |
|
|
|
bp->unsticktime = (uint32_t)time(NULL); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
double iguana_bundlemissings(struct iguana_info *coin,struct iguana_bundle *bp,double aveduration,int32_t lag) |
|
|
|
{ |
|
|
|
uint8_t missings[IGUANA_MAXBUNDLESIZE/8+1]; int32_t tmp,m,dist=0,missing,priority,avail,n=0,max; double aveduplicates; //bits256 hash2;
|
|
|
|
uint8_t missings[IGUANA_MAXBUNDLESIZE/8+1]; int32_t tmp,dist=0,missing,priority,avail,n=0,max; double aveduplicates; //bits256 hash2;
|
|
|
|
missing = iguana_blocksmissing(coin,&avail,missings,0,bp,0,lag); |
|
|
|
priority = (strcmp("BTC",coin->symbol) != 0) * 2; |
|
|
|
lag = IGUANA_DEFAULTLAG; |
|
|
@ -932,16 +947,7 @@ double iguana_bundlemissings(struct iguana_info *coin,struct iguana_bundle *bp,d |
|
|
|
{ |
|
|
|
if ( (dist= bp->hdrsi - coin->current->hdrsi) < coin->MAXBUNDLES ) |
|
|
|
{ |
|
|
|
if ( (m= coin->peers.numranked) > 0 && bp->numcached < bp->n && bp->hdrsi < coin->longestchain/coin->chain->bundlesize ) |
|
|
|
{ |
|
|
|
int32_t datalen; uint8_t serialized[512]; char str[65]; struct iguana_peer *addr; |
|
|
|
if ( (addr= coin->peers.ranked[rand() % m]) != 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++; |
|
|
|
} |
|
|
|
} |
|
|
|
iguana_unstickhdr(coin,bp,60); |
|
|
|
if ( bp->numcached > bp->n - (coin->MAXBUNDLES - dist) ) |
|
|
|
priority += 1 + (bp == coin->current); |
|
|
|
if ( bp == coin->current || queue_size(&coin->priorityQ) < (coin->MAXBUNDLES * bp->n)/(dist*dist+1) ) |
|
|
@ -1131,8 +1137,7 @@ void iguana_bundlestats(struct iguana_info *coin,char *str,int32_t lag) |
|
|
|
if ( (lag/coin->MAXSTUCKTIME) > coin->stuckiters ) |
|
|
|
{ |
|
|
|
printf("UNSTICK\n"); |
|
|
|
if ( bp->numhashes < bp->n ) |
|
|
|
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1); |
|
|
|
iguana_unstickhdr(coin,bp,6); |
|
|
|
coin->stuckiters = (int32_t)(lag/coin->MAXSTUCKTIME); |
|
|
|
if ( coin->stuckiters > 2 ) |
|
|
|
{ |
|
|
|