From 3d067956abe6da252c0c7dbaedc43663cb0bd078 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Apr 2016 23:03:16 -0600 Subject: [PATCH] test --- iguana/iguana777.h | 2 +- iguana/iguana_bundles.c | 18 +++++++++++++----- iguana/iguana_recv.c | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/iguana/iguana777.h b/iguana/iguana777.h index fd6be6597..832d16963 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -26,7 +26,7 @@ typedef int32_t (*blockhashfunc)(uint8_t *blockhashp,uint8_t *serialized,int32_t #define IGUANA_SERIALIZE_SPENDVECTORGEN #define IGUANA_SERIALIZE_BALANCEGEN //#define IGUANA_DISABLEPEERS -#define _IGUANA_MAXSTUCKTIME 30 +#define _IGUANA_MAXSTUCKTIME 60 #define IGUANA_MAXITERATIONS 10000 #define IGUANA_DEFAULTLAG 30 diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 68efc67e7..4eb51f699 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -596,7 +596,11 @@ 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,tmp,tmp2; bits256 hash2; + int32_t i,tmp,tmp2,priority = 3; bits256 hash2; double aveduration; + if ( bp->durationscount != 0 ) + aveduration = (double)bp->totaldurations / bp->durationscount; + else aveduration = IGUANA_DEFAULTLAG/3 + 1; + aveduration *= 3.; for (i=0; in; i++) { if ( GETBIT(missings,i) != 0 ) @@ -614,7 +618,7 @@ void iguana_bundleissuemissing(struct iguana_info *coin,struct iguana_bundle *bp } } } - iguana_bundlerequests(coin,missings,&tmp,&tmp2,bp,3,3); + iguana_bundlerequests(coin,missings,&tmp,&tmp2,bp,aveduration,priority); } int32_t iguana_bundlehdr(struct iguana_info *coin,struct iguana_bundle *bp,int32_t starti) @@ -773,7 +777,7 @@ int32_t iguana_bundlefinalize(struct iguana_info *coin,struct iguana_bundle *bp, int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,struct OS_memspace *memB,struct iguana_bundle *bp,int32_t timelimit,int32_t lag) { - int32_t range,starti,lasti,tmp,tmp2,n,retval=0,max,counter = 0; struct iguana_bundle *currentbp,*lastbp; uint8_t missings[IGUANA_MAXBUNDLESIZE/8+1]; struct iguana_blockreq *breq; + int32_t range,starti,lasti,tmp,tmp2,n,retval=0,max,priority=3,counter = 0; struct iguana_bundle *currentbp,*lastbp; uint8_t missings[IGUANA_MAXBUNDLESIZE/8+1]; struct iguana_blockreq *breq; double aveduration; //serialized[512], if ( coin->started == 0 || coin->active == 0 ) { @@ -847,7 +851,11 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,stru while ( (breq= queue_dequeue(&coin->priorityQ,0)) != 0 ) myfree(breq,sizeof(*breq)); } - if ( (n= iguana_bundlerequests(coin,missings,&tmp,&tmp2,bp,30,3)) > 0 ) + if ( bp->durationscount != 0 ) + aveduration = (double)bp->totaldurations / bp->durationscount; + else aveduration = IGUANA_DEFAULTLAG/3 + 1; + aveduration *= 3.; + if ( (n= iguana_bundlerequests(coin,missings,&tmp,&tmp2,bp,aveduration,priority)) > 0 ) printf("issued %d priority requests [%d] to unstick stuckiters.%d lag.%d\n",n,bp->hdrsi,coin->stuckiters,lag); } } @@ -935,7 +943,7 @@ double iguana_bundlemissings(struct iguana_info *coin,struct iguana_bundle *bp,d printf("priority.%d [%d] dist.%d durations %.2f vs %.2f counts[%d %d] \n",priority,bp->hdrsi,dist,aveduration,aveduplicates,(int32_t)bp->durationscount,bp->duplicatescount); } if ( aveduration != 0. ) - lag = 7 * aveduration; + lag = 7 * aveduration + 3; if ( (n= iguana_bundlerequests(coin,missings,&bp->origmissings,&tmp,bp,lag,priority)) > 0 ) { bp->numissued += n; diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 188ae4960..994c827a1 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -936,7 +936,7 @@ 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]; bits256 hash2; + struct iguana_bundle *bp=0,*prev; int32_t numsaved=0,bundlei = -2; struct iguana_block *block,*tmpblock; char str[65]; 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 )