Browse Source

improve staying in RT sync

release/v0.1
jl777 8 years ago
parent
commit
fb37388fd0
  1. 4
      iguana/iguana_accept.c
  2. 2
      iguana/iguana_realtime.c
  3. 14
      iguana/iguana_recv.c
  4. 4
      iguana/iguana_txidfind.c

4
iguana/iguana_accept.c

@ -98,12 +98,12 @@ void iguana_acceptloop(void *args)
}
memcpy(&ipbits,&cli_addr.sin_addr.s_addr,sizeof(ipbits));
expand_ipbits(ipaddr,ipbits);
printf("incoming (%s:%u)\n",ipaddr,cli_addr.sin_port);
printf("incoming %s (%s:%u)\n",coin->symbol,ipaddr,cli_addr.sin_port);
for (i=flag=0; i<IGUANA_MAXPEERS; i++)
{
if ( coin->peers->active[i].ipbits == (uint32_t)ipbits && coin->peers->active[i].usock >= 0 )
{
printf("found existing peer.(%s) in slot[%d]\n",ipaddr,i);
//printf("found existing %s peer.(%s) in slot[%d]\n",coin->symbol,ipaddr,i);
close(coin->peers->active[i].usock);
coin->peers->active[i].dead = 0;
coin->peers->active[i].usock = sock;

2
iguana/iguana_realtime.c

@ -954,7 +954,7 @@ void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int3
if ( fwrite(recvlenp,1,sizeof(*recvlenp),fp) != sizeof(*recvlenp) || fwrite(numtxp,1,sizeof(*numtxp),fp) != sizeof(*numtxp) || fwrite(data,1,*recvlenp,fp) != *recvlenp )
printf("error writing %s len.%d numtx.%d\n",bits256_str(str,hash2),*recvlenp,*numtxp);
fclose(fp);
printf("numtx.%d len.%d %s hwm.%d L.%d\n",*numtxp,*recvlenp,fname,coin->blocks.hwmchain.height,coin->longestchain);
//printf("numtx.%d len.%d %s hwm.%d L.%d\n",*numtxp,*recvlenp,fname,coin->blocks.hwmchain.height,coin->longestchain);
} else printf("couldnt create %s\n",fname);
}
else if ( (ptr= OS_mapfile(fname,&filesize,0)) != 0 )

14
iguana/iguana_recv.c

@ -773,14 +773,22 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru
}
}
if ( bp == 0 )
{
req = iguana_recv_bundlereq(coin,addr,0,H,data,recvlen,0,-1,origtxdata);
queue_enqueue("recvQ",&coin->recvQ,&req->DL,0);
return;
}
for (i=numsaved=0; i<coin->chain->bundlesize; i++)
{
if ( (block= bp->blocks[i]) != 0 && block->fpipbits != 0 && block->fpos >= 0 && block->txvalid != 0 )
numsaved++;
}
if ( (speculative= iguana_bundlestats_update(coin,&block,bp,bundlei,origtxdata,data,recvlen)) < 0 )
{
req = iguana_recv_bundlereq(coin,addr,0,H,data,recvlen,0,-1,origtxdata);
queue_enqueue("recvQ",&coin->recvQ,&req->DL,0);
return;
}
if ( block == 0 )
block = iguana_blockhashset("noblock",coin,bp->bundleheight+bundlei,origtxdata->zblock.RO.hash2,1);
if ( block->hdrsi != bp->hdrsi || block->bundlei != bundlei )
@ -815,6 +823,8 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru
{
// printf("DUP s.%d [%d:%d].(%s) %s n%d\n",numsaved,bp!=0?bp->hdrsi:-1,bundlei,bits256_str(str,origtxdata->zblock.RO.hash2),addr->ipaddr,addr->pendblocks);
}
req = iguana_recv_bundlereq(coin,addr,0,H,data,recvlen,0,-1,origtxdata);
queue_enqueue("recvQ",&coin->recvQ,&req->DL,0);
return;
}
txdata = origtxdata;
@ -899,6 +909,8 @@ int32_t iguana_gotheadersM(struct iguana_info *coin,struct iguana_peer *addr,str
addr->numRThashes = num;
}
}
if ( strcmp("BTC",coin->symbol) != 0 && n == 2 )
iguana_sendblockreqPT(coin,addr,0,-1,zblocks[1].RO.hash2,0);
for (i=0; i<coin->bundlescount; i++)
{
if ( (bp= coin->bundles[i]) != 0 && bits256_cmp(zblocks[1].RO.hash2,bp->hashes[1]) == 0 && bp->numhashes >= coin->chain->bundlesize )
@ -1402,7 +1414,7 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct supernet_info *myinfo,str
memset(zero.bytes,0,sizeof(zero));
bp = 0, bundlei = -2;
iguana_bundlefind(coin,&bp,&bundlei,blockhashes[1]);
if ( 0 && strcmp("BTCD",coin->symbol) == 0 )//0 && num >= coin->chain->bundlesize )
//if ( 0 && strcmp("BTCD",coin->symbol) == 0 )//0 && num >= coin->chain->bundlesize )
printf("blockhashes[%d] %d of %d %s bp.%d[%d]\n",num,bp==0?-1:bp->hdrsi,coin->bundlescount,bits256_str(str,blockhashes[1]),bp==0?-1:bp->bundleheight,bundlei);
if ( num < 2 )
return(req);

4
iguana/iguana_txidfind.c

@ -621,7 +621,7 @@ struct iguana_monitorinfo *iguana_monitorfind(struct iguana_info *coin,bits256 t
struct iguana_monitorinfo *iguana_txidreport(struct iguana_info *coin,bits256 txid,struct iguana_peer *addr)
{
struct iguana_monitorinfo *ptr; char str[65];
struct iguana_monitorinfo *ptr; //char str[65];
if ( (ptr= iguana_monitorfind(coin,txid)) != 0 )
{
if ( GETBIT(ptr->peerbits,addr->addrind) == 0 )
@ -630,7 +630,7 @@ struct iguana_monitorinfo *iguana_txidreport(struct iguana_info *coin,bits256 tx
SETBIT(ptr->peerbits,addr->addrind);
ptr->numreported++;
}
} else printf("txid.%s not being monitored\n",bits256_str(str,txid));
} // else printf("%s txid.%s not being monitored\n",coin->symbol,bits256_str(str,txid));
return(0);
}

Loading…
Cancel
Save