Browse Source

Merge pull request #169 from jl777/dev

Dev
win-cross
jl777 8 years ago
committed by GitHub
parent
commit
09b55e325c
  1. 19
      iguana/dpow/dpow_network.c
  2. 11
      iguana/iguana_notary.c

19
iguana/dpow/dpow_network.c

@ -83,7 +83,7 @@ char *dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *data,int32
} }
else else
{ {
timeout = 500; timeout = 100;
nn_setsockopt(reqsock,NN_SOL_SOCKET,NN_SNDTIMEO,&timeout,sizeof(timeout)); nn_setsockopt(reqsock,NN_SOL_SOCKET,NN_SNDTIMEO,&timeout,sizeof(timeout));
timeout = 2000; timeout = 2000;
nn_setsockopt(reqsock,NN_SOL_SOCKET,NN_RCVTIMEO,&timeout,sizeof(timeout)); nn_setsockopt(reqsock,NN_SOL_SOCKET,NN_RCVTIMEO,&timeout,sizeof(timeout));
@ -1197,7 +1197,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
if ( time(NULL) < myinfo->nanoinit+5 || (myinfo->dpowsock < 0 && myinfo->dexsock < 0 && myinfo->repsock < 0) ) if ( time(NULL) < myinfo->nanoinit+5 || (myinfo->dpowsock < 0 && myinfo->dexsock < 0 && myinfo->repsock < 0) )
return(-1); return(-1);
portable_mutex_lock(&myinfo->dpowmutex); portable_mutex_lock(&myinfo->dpowmutex);
for (i=0; i<100; i++) /*for (i=0; i<100; i++)
{ {
struct nn_pollfd pfd; struct nn_pollfd pfd;
pfd.fd = myinfo->dpowsock; pfd.fd = myinfo->dpowsock;
@ -1205,12 +1205,13 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
if ( nn_poll(&pfd,1,100) > 0 ) if ( nn_poll(&pfd,1,100) > 0 )
break; break;
usleep(1000); usleep(1000);
} }*/
if ( i < 100 && (size= nn_recv(myinfo->dpowsock,&np,NN_MSG,0)) >= 0 ) while ( (size= nn_recv(myinfo->dpowsock,&np,NN_MSG,0)) >= 0 && num < 100 )
{ {
num++; if ( size > 0 )
if ( size >= 0 )
{ {
//fprintf(stderr,"%d ",size);
num++;
if ( np->version0 == (DPOW_VERSION & 0xff) && np->version1 == ((DPOW_VERSION >> 8) & 0xff) ) if ( np->version0 == (DPOW_VERSION & 0xff) && np->version1 == ((DPOW_VERSION >> 8) & 0xff) )
{ {
//printf("v.%02x %02x datalen.%d size.%d %d vs %d\n",np->version0,np->version1,np->datalen,size,np->datalen,(int32_t)(size - sizeof(*np))); //printf("v.%02x %02x datalen.%d size.%d %d vs %d\n",np->version0,np->version1,np->datalen,size,np->datalen,(int32_t)(size - sizeof(*np)));
@ -1259,8 +1260,9 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
n = 0; n = 0;
if ( myinfo->dexsock >= 0 ) // from servers if ( myinfo->dexsock >= 0 ) // from servers
{ {
if ( (size= nn_recv(myinfo->dexsock,&dexp,NN_MSG,0)) >= 0 ) if ( (size= nn_recv(myinfo->dexsock,&dexp,NN_MSG,0)) > 0 )
{ {
//fprintf(stderr,"%d ",size);
num++; num++;
if ( dex_packetcheck(myinfo,dexp,size) == 0 ) if ( dex_packetcheck(myinfo,dexp,size) == 0 )
{ {
@ -1275,9 +1277,10 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
} }
if ( myinfo->repsock >= 0 ) // from clients if ( myinfo->repsock >= 0 ) // from clients
{ {
if ( (size= nn_recv(myinfo->repsock,&dexp,NN_MSG,0)) >= 0 ) if ( (size= nn_recv(myinfo->repsock,&dexp,NN_MSG,0)) > 0 )
{ {
num++; num++;
//fprintf(stderr,"%d ",size);
//printf("REP got %d\n",size); //printf("REP got %d\n",size);
if ( (retstr= dex_response(&broadcastflag,myinfo,dexp)) != 0 ) if ( (retstr= dex_response(&broadcastflag,myinfo,dexp)) != 0 )
{ {

11
iguana/iguana_notary.c

@ -142,13 +142,16 @@ void dpow_destupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t h
void iguana_dPoWupdate(struct supernet_info *myinfo,struct dpow_info *dp) void iguana_dPoWupdate(struct supernet_info *myinfo,struct dpow_info *dp)
{ {
int32_t i,height; uint32_t blocktime; bits256 blockhash; struct iguana_info *src,*dest; int32_t i,height,num; uint32_t blocktime; bits256 blockhash; struct iguana_info *src,*dest;
for (i=0; i<100; i++) for (i=0; i<3; i++)
if ( dpow_nanomsg_update(myinfo) <= 0 ) {
if ( (num= dpow_nanomsg_update(myinfo)) <= 0 )
break; break;
//fprintf(stderr,"%d ",num);
}
src = iguana_coinfind(dp->symbol); src = iguana_coinfind(dp->symbol);
dest = iguana_coinfind(dp->dest); dest = iguana_coinfind(dp->dest);
fprintf(stderr,"i.%d dp.%p dPoWupdate (%s -> %s)\n",i,dp,dp!=0?dp->symbol:"",dp!=0?dp->dest:""); //fprintf(stderr,"i.%d dp.%p dPoWupdate (%s -> %s)\n",i,dp,dp!=0?dp->symbol:"",dp!=0?dp->dest:"");
if ( src != 0 && dest != 0 ) if ( src != 0 && dest != 0 )
{ {
dp->numdesttx = sizeof(dp->desttx)/sizeof(*dp->desttx); dp->numdesttx = sizeof(dp->desttx)/sizeof(*dp->desttx);

Loading…
Cancel
Save