diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 8481a952b..74e716eb4 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -83,7 +83,7 @@ char *dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *data,int32 } else { - timeout = 500; + timeout = 100; nn_setsockopt(reqsock,NN_SOL_SOCKET,NN_SNDTIMEO,&timeout,sizeof(timeout)); timeout = 2000; 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) ) return(-1); portable_mutex_lock(&myinfo->dpowmutex); - for (i=0; i<100; i++) + /*for (i=0; i<100; i++) { struct nn_pollfd pfd; pfd.fd = myinfo->dpowsock; @@ -1205,12 +1205,13 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo) if ( nn_poll(&pfd,1,100) > 0 ) break; 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) ) { //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; 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++; 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 ( (size= nn_recv(myinfo->repsock,&dexp,NN_MSG,0)) >= 0 ) + if ( (size= nn_recv(myinfo->repsock,&dexp,NN_MSG,0)) > 0 ) { num++; + //fprintf(stderr,"%d ",size); //printf("REP got %d\n",size); if ( (retstr= dex_response(&broadcastflag,myinfo,dexp)) != 0 ) { diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index b5bbcbe75..9f1a6b158 100755 --- a/iguana/iguana_notary.c +++ b/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) { - int32_t i,height; uint32_t blocktime; bits256 blockhash; struct iguana_info *src,*dest; - for (i=0; i<100; i++) - if ( dpow_nanomsg_update(myinfo) <= 0 ) + int32_t i,height,num; uint32_t blocktime; bits256 blockhash; struct iguana_info *src,*dest; + for (i=0; i<3; i++) + { + if ( (num= dpow_nanomsg_update(myinfo)) <= 0 ) break; + //fprintf(stderr,"%d ",num); + } src = iguana_coinfind(dp->symbol); 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 ) { dp->numdesttx = sizeof(dp->desttx)/sizeof(*dp->desttx);