Browse Source

test

etomic
jl777 8 years ago
parent
commit
cab016334b
  1. 15
      iguana/dpow/dpow_network.c
  2. 12
      iguana/iguana777.h

15
iguana/dpow/dpow_network.c

@ -74,9 +74,11 @@ int32_t dex_reqsend(struct supernet_info *myinfo,uint8_t *data,int32_t datalen)
} }
else else
{ {
timeout = 500; timeout = 2500;
nn_setsockopt(reqsock,NN_SOL_SOCKET,NN_SNDTIMEO,&timeout,sizeof(timeout)); nn_setsockopt(reqsock,NN_SOL_SOCKET,NN_SNDTIMEO,&timeout,sizeof(timeout));
nn_setsockopt(reqsock,NN_SOL_SOCKET,NN_RCVTIMEO,&timeout,sizeof(timeout)); nn_setsockopt(reqsock,NN_SOL_SOCKET,NN_RCVTIMEO,&timeout,sizeof(timeout));
timeout = 500;
nn_setsockopt(reqsock,NN_TCP,NN_RECONNECT_IVL,&timeout,sizeof(timeout));
if ( myinfo->IAMNOTARY == 0 && subsock < 0 && (subsock= nn_socket(AF_SP,NN_SUB)) >= 0 ) if ( myinfo->IAMNOTARY == 0 && subsock < 0 && (subsock= nn_socket(AF_SP,NN_SUB)) >= 0 )
{ {
if ( nn_connect(subsock,nanomsg_tcpname(0,str,myinfo->dexseed_ipaddr,PUB_SOCK)) < 0 ) if ( nn_connect(subsock,nanomsg_tcpname(0,str,myinfo->dexseed_ipaddr,PUB_SOCK)) < 0 )
@ -140,9 +142,14 @@ int32_t dex_reqsend(struct supernet_info *myinfo,uint8_t *data,int32_t datalen)
} }
portable_mutex_unlock(&myinfo->dexmutex); portable_mutex_unlock(&myinfo->dexmutex);
nn_freemsg(retptr); nn_freemsg(retptr);
} else retval = -2; }
else
{
retval = -2;
printf("no rep return? recvbytes.%d\n",recvbytes);
}
printf("DEXREQ.[%d] crc32.%08x datalen.%d sent.%d recv.%d timestamp.%u\n",size,dexp->crc32,datalen,sentbytes,recvbytes,dexp->timestamp);
free(dexp); free(dexp);
printf("DEXREQ.[%d] crc32.%08x datalen.%d sent.%d timestamp.%u\n",size,dexp->crc32,datalen,sentbytes,dexp->timestamp);
} else retval = -1; } else retval = -1;
return(retval); return(retval);
} }
@ -987,7 +994,7 @@ int32_t dpow_nanomsg_update(struct supernet_info *myinfo)
{ {
r = myinfo->dpowipbits[rand() % m]; r = myinfo->dpowipbits[rand() % m];
nn_send(myinfo->repsock,&r,sizeof(r),0); nn_send(myinfo->repsock,&r,sizeof(r),0);
printf("REP.%08x <- rand ip m.%d %x",dexp->crc32,m,r); printf("REP.%08x <- rand ip m.%d %x\n",dexp->crc32,m,r);
} else printf("illegal state without dpowipbits?\n"); } else printf("illegal state without dpowipbits?\n");
if ( dex_packetcheck(myinfo,dexp,size) == 0 ) if ( dex_packetcheck(myinfo,dexp,size) == 0 )
{ {

12
iguana/iguana777.h

@ -51,13 +51,19 @@
#include "nn.h" #include "nn.h"
#include "bus.h" #include "bus.h"
#else*/ #else*/
//#if ISNOTARYNODE #ifdef __APPLE__
#include "../crypto777/nanosrc/nn.h" #include "../crypto777/nanosrc/nn.h"
#include "../crypto777/nanosrc/bus.h" #include "../crypto777/nanosrc/bus.h"
#include "../crypto777/nanosrc/pubsub.h" #include "../crypto777/nanosrc/pubsub.h"
#include "../crypto777/nanosrc/reqrep.h" #include "../crypto777/nanosrc/reqrep.h"
//#endif #include "../crypto777/nanosrc/tcp.h"
//#endif #else
#include "<nanomsg/nn.h>"
#include "<nanomsg/bus.h>"
#include "<nanomsg/pubsub.h>"
#include "<nanomsg/reqrep.h>"
#include "<nanomsg/tcp.h>"
#endif
struct supernet_info; struct supernet_info;
struct exchange_info; struct exchange_info;

Loading…
Cancel
Save