diff --git a/iguana/iguana_accept.c b/iguana/iguana_accept.c index a4a836d69..4504292a3 100755 --- a/iguana/iguana_accept.c +++ b/iguana/iguana_accept.c @@ -77,7 +77,7 @@ void iguana_acceptloop(void *args) if ( poll(&pfd,1,100) <= 0 ) continue; clilen = sizeof(cli_addr); - printf("ACCEPT (%s:%d) on sock.%d\n","127.0.0.1",coin->chain->portp2p,coin->bindsock); + //printf("ACCEPT (%s:%d) on sock.%d\n","127.0.0.1",coin->chain->portp2p,coin->bindsock); sock = accept(coin->bindsock,(struct sockaddr *)&cli_addr,&clilen); if ( sock < 0 ) { @@ -86,7 +86,6 @@ void iguana_acceptloop(void *args) } memcpy(&ipbits,&cli_addr.sin_addr.s_addr,sizeof(ipbits)); expand_ipbits(ipaddr,ipbits); - printf("NEWSOCK.%d for %x (%s)\n",sock,ipbits,ipaddr); for (i=0; ipeers.active[i].ipbits == (uint32_t)ipbits && coin->peers.active[i].usock >= 0 ) @@ -101,6 +100,7 @@ void iguana_acceptloop(void *args) } if ( sock < 0 ) continue; + printf("NEWSOCK.%d for %x (%s)\n",sock,ipbits,ipaddr); /*if ( (uint32_t)ipbits == myinfo->myaddr.myipbits ) { @@ -119,6 +119,7 @@ void iguana_acceptloop(void *args) { printf("LAUNCH DEDICATED THREAD for %s\n",ipaddr); addr->usock = sock; + addr->dead = 0; strcpy(addr->symbol,coin->symbol); iguana_launch(coin,"accept",iguana_dedicatedglue,addr,IGUANA_CONNTHREAD); //iguana_dedicatedloop(coin,addr); diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 0a4974a5f..b433a8aa1 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -403,8 +403,10 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int else starti = 0; priority = (bp->hdrsi < starti + coin->peers.numranked); if ( strcmp("BTC",coin->symbol) == 0 ) - lag = 30 + (bp->hdrsi - starti); + lag = 10 + (bp->hdrsi - starti); else lag = 3 + (bp->hdrsi - starti)/10; + if ( coin->current != bp ) + lag *= 3; if ( (numpeers= coin->peers.numranked) > 3 )//&& bp->currentflag < bp->n ) { if ( numpeers > 0xff ) @@ -988,6 +990,16 @@ void iguana_bundlestats(struct iguana_info *coin,char *str) } // else break; } } + else if ( bp == coin->current ) + { + for (j=0; jn; j++) + if ( (block= bp->blocks[j]) != 0 && block->fpipbits == 0 && time(NULL) > block->issued+10 ) + { + printf("current stop [%d:%d]\n",bp->hdrsi,j); + iguana_blockQ("currentstop",coin,0,-1,block->RO.hash2,1); + block->issued = (uint32_t)time(NULL); + } + } //bp->rank = 0; estsize += bp->estsize;//iguana_bundlecalcs(coin,bp,done); //bp->metric = bp->numhashes; diff --git a/iguana/iguana_msg.c b/iguana/iguana_msg.c index 5794a5107..aa7fdc6f0 100755 --- a/iguana/iguana_msg.c +++ b/iguana/iguana_msg.c @@ -172,7 +172,7 @@ void iguana_gotversion(struct iguana_info *coin,struct iguana_peer *addr,struct addr->supernet = 1; //else printf("nServices.%lld nonce.%llu %srelay node.(%s) supernet.%d\n",(long long)vers->nServices,(long long)vers->nonce,addr->relayflag==0?"non-":"",addr->ipaddr,addr->supernet); if ( vers->nStartingHeight > coin->longestchain ) - coin->longestchain = vers->nStartingHeight; + coin->longestchain = (vers->nStartingHeight + coin->longestchain + 1) >> 1; iguana_queue_send(coin,addr,0,serialized,"getaddr",0,0,0); } diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 36de9963c..f83420a55 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -576,8 +576,8 @@ void iguana_gotdata(struct iguana_info *coin,struct iguana_peer *addr,int32_t he //iguana_set_iAddrheight(coin,addr->ipbits,height); addr->height = height; } - if ( height > coin->longestchain ) - coin->longestchain = height; + if ( height > 0 && height > coin->longestchain ) + coin->longestchain = (height + coin->longestchain + 1) >> 1; } int32_t iguana_iAddrheight(struct iguana_info *coin,uint64_t ipbits) diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index ec4465b17..586b454a4 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -886,7 +886,7 @@ void iguana_RTramchainalloc(struct iguana_info *coin,struct iguana_bundle *bp) } if ( coin->RTramchain.H.data == 0 ) { - printf("ALLOC RTramchain\n"); + //printf("ALLOC RTramchain\n"); iguana_ramchainopen(coin,dest,&coin->RTmem,&coin->RThashmem,bp->bundleheight,bp->hashes[0]); dest->H.txidind = dest->H.unspentind = dest->H.spendind = dest->pkind = dest->H.data->firsti; dest->externalind = dest->H.stacksize = 0; @@ -941,13 +941,23 @@ int32_t iguana_realtime_update(struct iguana_info *coin) coin->RTheight++; printf(">>>> RT.%d hwm.%d L.%d T.%d U.%d S.%d P.%d X.%d -> size.%ld\n",coin->RTheight,coin->blocks.hwmchain.height,coin->longestchain,dest->H.txidind,dest->H.unspentind,dest->H.spendind,dest->pkind,dest->externalind,(long)dest->H.data->allocsize); coin->RTramchain.H.data->numblocks = bundlei + 1; - } else printf("error mapchaininit\n"); - iguana_ramchain_free(coin,&blockR,1); - } //else printf("no ptr for RTheight.%d\n",coin->RTheight); + } + else + { + printf("error mapchaininit\n"); + iguana_ramchain_free(coin,&blockR,1); + return(-1); + } + } + else + { + printf("no ptr for RTheight.%d\n",coin->RTheight); + return(-1); + } } else { - //printf("no blockptr for RTheight.%d\n",coin->RTheight); + printf("no blockptr for RTheight.%d\n",coin->RTheight); return(-1); } } @@ -1131,8 +1141,8 @@ int32_t iguana_balancecalc(struct iguana_info *coin,struct iguana_bundle *bp,int } } } - //printf("B [%d] j.%d u.%u b.%u\n",bp->hdrsi,j,bp->utxofinish,bp->balancefinish); - if ( bp->bundleheight+bp->n >= coin->blocks.hwmchain.height && bp->utxofinish > 1 && bp->balancefinish <= 1 && bp->hdrsi == j ) + // printf("B [%d] j.%d u.%u b.%u\n",bp->hdrsi,j,bp->utxofinish,bp->balancefinish); + if ( bp->bundleheight+bp->n < coin->blocks.hwmchain.height && bp->utxofinish > 1 && bp->balancefinish <= 1 && (bp->hdrsi == 0 || bp->hdrsi == j) ) { starttime = (uint32_t)time(NULL); for (j=0; j<=bp->hdrsi; j++)