Browse Source

Test

etomic
jl777 8 years ago
parent
commit
811129820c
  1. 14
      iguana/exchanges/LP_nativeDEX.c
  2. 8
      iguana/exchanges/LP_ordermatch.c

14
iguana/exchanges/LP_nativeDEX.c

@ -344,9 +344,14 @@ void LP_mainloop(char *myipaddr,struct LP_peerinfo *mypeer,uint16_t mypubport,in
}
}
void nn_tests()
{
}
void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,double profitmargin,char *passphrase,int32_t amclient,char *userhome,cJSON *argjson)
{
char *myipaddr=0; long filesize,n; int32_t timeout,pullsock=-1,pubsock=-1; struct LP_peerinfo *mypeer=0; char pushaddr[128],subaddr[128];
char *myipaddr=0; long filesize,n; int32_t timeout,pullsock=-1,pubsock=-1; struct LP_peerinfo *mypeer=0; char pushaddr[128],subaddr[128],bindaddr[128];
IAMLP = !amclient;
LP_profitratio += profitmargin;
OS_randombytes((void *)&n,sizeof(n));
@ -382,9 +387,11 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,double profit
} else printf("error getting myipaddr\n");
} else printf("error issuing curl\n");
nanomsg_tcpname(pushaddr,myipaddr,mypullport);
nn_tests();
if ( (pullsock= nn_socket(AF_SP,NN_PULL)) >= 0 )
{
if ( nn_bind(pullsock,pushaddr) >= 0 )
nanomsg_tcpname(bindaddr,"0.0.0.0",mypullport);
if ( nn_bind(pullsock,bindaddr) >= 0 )
{
timeout = 1;
nn_setsockopt(pullsock,NN_SOL_SOCKET,NN_RCVTIMEO,&timeout,sizeof(timeout));
@ -399,9 +406,10 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,double profit
{
pubsock = -1;
nanomsg_tcpname(subaddr,myipaddr,mypubport);
nanomsg_tcpname(bindaddr,"0.0.0.0",mypubport);
if ( (pubsock= nn_socket(AF_SP,NN_PUB)) >= 0 )
{
if ( nn_bind(pubsock,subaddr) >= 0 )
if ( nn_bind(pubsock,bindaddr) >= 0 )
{
timeout = 10;
nn_setsockopt(pubsock,NN_SOL_SOCKET,NN_SNDTIMEO,&timeout,sizeof(timeout));

8
iguana/exchanges/LP_ordermatch.c

@ -340,11 +340,13 @@ double LP_query(char *myipaddr,int32_t mypubsock,double profitmargin,char *metho
int32_t LP_nanobind(int32_t pair,char *pairstr,char *myipaddr)
{
int32_t i,timeout;
int32_t i,timeout,r; char bindaddr[128];
for (i=0; i<10; i++)
{
nanomsg_tcpname(pairstr,myipaddr,10000+(rand() % 50000));
if ( nn_bind(pair,pairstr) >= 0 )
r = (10000 + (rand() % 50000)) & 0xffff;
nanomsg_tcpname(pairstr,myipaddr,r);
nanomsg_tcpname(bindaddr,myipaddr,r);
if ( nn_bind(pair,bindaddr) >= 0 )
{
timeout = 100;
nn_setsockopt(pair,NN_SOL_SOCKET,NN_SNDTIMEO,&timeout,sizeof(timeout));

Loading…
Cancel
Save