diff --git a/iguana/iguana_ramchain.c b/iguana/iguana_ramchain.c index 2bbfde180..58173cfd0 100755 --- a/iguana/iguana_ramchain.c +++ b/iguana/iguana_ramchain.c @@ -2653,7 +2653,9 @@ int32_t iguana_bundlesaveHT(struct iguana_info *coin,struct OS_memspace *mem,str { if ( (block= bp->blocks[i]) != 0 && block == iguana_blockfind(coin,bp->hashes[i]) ) { - if ( iguana_blockvalidate(coin,&valid,block,1) != 0 || (bp->bundleheight+i > 0 && bits256_nonz(block->RO.prev_block) == 0) ) + if ( bits256_nonz(block->RO.prev_block) == 0 && i > 0 ) + block->RO.prev_block = bp->hashes[i-1]; + if ( (bp->bundleheight+i > 0 && bits256_nonz(block->RO.prev_block) == 0) || iguana_blockvalidate(coin,&valid,block,1) < 0 ) { char str[65]; printf("null prevblock error at ht.%d patch.(%s)\n",bp->bundleheight+i,bits256_str(str,bp->hashes[i-1])); block->queued = 0; diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index a77b7054c..52c5ecb68 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -37,16 +37,16 @@ int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr, char hexstr[65]; init_hexbytes_noT(hexstr,hash2.bytes,sizeof(hash2)); if ( memcmp(lastreq.bytes,hash2.bytes,sizeof(hash2)) == 0 || memcmp(lastreq2.bytes,hash2.bytes,sizeof(hash2)) == 0 ) { - //printf("duplicate req\n"); + printf("duplicate req %s\n",bits256_str(hexstr,hash2)); return(0); } - lastreq2 = lastreq; - lastreq = hash2; if ( addr->msgcounts.verack == 0 ) { printf("iguana_sendblockreq %s hasn't verack'ed yet\n",addr->ipaddr); return(-1); } + lastreq2 = lastreq; + lastreq = hash2; if ( (len= iguana_getdata(coin,serialized,MSG_BLOCK,hexstr)) > 0 ) { iguana_send(coin,addr,serialized,len); @@ -656,7 +656,7 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana struct iguana_bundle *bp=0; int32_t bundlei = -2; struct iguana_block *block; bp = iguana_bundleset(coin,&block,&bundlei,origblock); static int total; char str[65]; - if ( 0 && bp != 0 && bp->hdrsi == 0 ) + if ( 1 && bp != 0 && bp->hdrsi == 0 ) fprintf(stderr,"RECV %s [%d:%d] block.%08x | %d\n",bits256_str(str,origblock->RO.hash2),bp!=0?bp->hdrsi:-1,bundlei,block->fpipbits,total++); if ( bundlei == 1 && bp != 0 && bp->numhashes < bp->n ) { @@ -905,7 +905,7 @@ int32_t iguana_neargap(struct iguana_info *coin,struct iguana_peer *addr) { printf("near hwm.%d gap.%d peer.%s bpranked.%d [%d:%d] pending.%d numreqs.%d\n",height,j,addr->ipaddr,bestbp->rank,bestbp->hdrsi,besti,addr->pendblocks,bestblock->numrequests); bestblock->numrequests++; - iguana_sendblockreqPT(coin,addr,bestbp,besti,bestblock->RO.hash2,1); + iguana_sendblockreqPT(coin,addr,bestbp,besti,bestblock->RO.hash2,0); return(1); } } @@ -985,7 +985,7 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr) printf("peer.%s BPranked.%d [%d:%d] pending.%d numreqs.%d\n",addr->ipaddr,bp->rank,bp->hdrsi,i,addr->pendblocks,block->numrequests); block->numrequests++; flag++; - iguana_sendblockreqPT(coin,addr,bp,i,block->RO.hash2,1); + iguana_sendblockreqPT(coin,addr,bp,i,block->RO.hash2,0); break; } } @@ -1014,8 +1014,11 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr) } else { + char str[65]; if ( block != 0 ) block->numrequests++; + if ( priority != 0 ) + printf("PRIORITY %s [%d:%d]\n",bits256_str(str,hash2),bp!=0?bp->bundleheight:-1,req->bundlei); iguana_sendblockreqPT(coin,addr,req->bp,req->bundlei,hash2,0); } flag++;