From 2eddc1d57ee696345e688db7fa5217bcc106f7fd Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Mar 2016 23:54:36 -0300 Subject: [PATCH] test --- iguana/iguana777.h | 3 ++- iguana/iguana_msg.c | 8 +++++++- iguana/iguana_recv.c | 15 ++++++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/iguana/iguana777.h b/iguana/iguana777.h index d6d74ab19..da3b47283 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -461,7 +461,8 @@ struct iguana_info uint64_t instance_nonce,myservices,totalsize,totalrecv,totalpackets,sleeptime; int64_t mining,totalfees,TMPallocated,MAXRECVCACHE,MAXMEM,estsize,activebundles; int32_t MAXPEERS,MAXPENDING,MAXBUNDLES,active,closestbundle,numemitted,lastsweep,startutc,newramchain,numcached,cachefreed,helperdepth,startPEND,endPEND,enableCACHE,RELAYNODE,VALIDATENODE,balanceswritten,RTheight; bits256 balancehash; - uint32_t longestchain,lastsync,parsetime,numiAddrs,firstblock,lastpossible,bundlescount,savedblocks; + uint32_t lastsync,parsetime,numiAddrs,firstblock,lastpossible,bundlescount,savedblocks; + int32_t longestchain,badlongestchain,longestchain_strange; struct tai starttime; double startmillis; struct iguana_chain *chain; struct iguana_iAddr *iAddrs; diff --git a/iguana/iguana_msg.c b/iguana/iguana_msg.c index aa7fdc6f0..1658c9b25 100755 --- a/iguana/iguana_msg.c +++ b/iguana/iguana_msg.c @@ -172,7 +172,13 @@ 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 + 1) >> 1; + { + if ( coin->badlongestchain != 0 && vers->nStartingHeight >= coin->badlongestchain ) + { + printf("peer.(%s) gives badlongestchain.%d\n",addr->ipaddr,vers->nStartingHeight); + addr->dead = 1; + } else coin->longestchain = (vers->nStartingHeight + coin->longestchain + 1) >> 1; + } iguana_queue_send(coin,addr,0,serialized,"getaddr",0,0,0); } diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 94f0a81a0..016cdbfe2 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -630,7 +630,20 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct iguana_info *coin,struct return(req); //printf("done allhashes\n"); } - if ( bp != 0 && (bp->speculative == 0 || num > bp->numspec) && bp->emitfinish == 0 ) + else if ( bp->hdrsi == coin->bundlescount-1 ) + { + if ( num < bp->n && coin->longestchain > bp->bundleheight+bp->n ) + { + printf("suspicious longestchain.%d vs [%d:%d] %d\n",coin->longestchain,bp->hdrsi,num,bp->bundleheight+num); + if ( coin->longestchain_strange++ > 10 ) + { + coin->badlongestchain = coin->longestchain; + coin->longestchain = bp->bundleheight+num; + coin->longestchain_strange = 0; + } + } + } + if ( (bp->speculative == 0 || num > bp->numspec) && bp->emitfinish == 0 ) { //printf("FOUND speculative.%s BLOCKHASHES[%d] ht.%d\n",bits256_str(str,blockhashes[1]),num,bp->bundleheight); if ( bp->speculative == 0 )