From 614a2c5744e346a97799cbaf0fbf02722128f4bf Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 4 Feb 2018 23:25:22 +0200 Subject: [PATCH] Test --- iguana/exchanges/LP_nativeDEX.c | 4 ++-- iguana/exchanges/LP_network.c | 4 ++-- iguana/exchanges/LP_peers.c | 12 +++++------- iguana/exchanges/LP_prices.c | 1 + 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 6d40c92b0..ad3ae272b 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -1104,7 +1104,7 @@ void LP_reserved_msgs(void *ignore) if ( num_Reserved_msgs[1] > 0 ) { num_Reserved_msgs[1]--; - printf("PRIORITY BROADCAST.(%s)\n",Reserved_msgs[1][num_Reserved_msgs[1]]); + //printf("PRIORITY BROADCAST.(%s)\n",Reserved_msgs[1][num_Reserved_msgs[1]]); LP_broadcast_message(LP_mypubsock,"","",zero,Reserved_msgs[1][num_Reserved_msgs[1]]); Reserved_msgs[1][num_Reserved_msgs[1]] = 0; } @@ -1162,7 +1162,7 @@ int32_t LP_reserved_msg(int32_t priority,char *base,char *rel,bits256 pubkey,cha { if ( (pubp= LP_pubkeyfind(pubkey)) != 0 ) { - if ( pubp->pairsock > 0 ) + if ( pubp->pairsock >= 0 ) { if ( (sentbytes= nn_send(pubp->pairsock,msg,(int32_t)strlen(msg)+1,0)) < 0 ) { diff --git a/iguana/exchanges/LP_network.c b/iguana/exchanges/LP_network.c index c3f9f3048..35f37e966 100644 --- a/iguana/exchanges/LP_network.c +++ b/iguana/exchanges/LP_network.c @@ -712,7 +712,7 @@ char *_LP_psock_create(int32_t *pullsockp,int32_t *pubsockp,char *ipaddr,uint16_ char str[65]; if ( (pubp= LP_pubkeyadd(pubkey)) != 0 ) { - if ( pubp->pairsock > 0 ) + if ( pubp->pairsock >= 0 ) { //printf("warning %s already has pairsock.%d, mark for purge\n",bits256_str(str,pubkey),pubp->pairsock); for (i=0; ipairsock <= 0 ) + if ( peer->pairsock < 0 ) LP_cmdchannel(peer); } } @@ -131,7 +131,7 @@ struct LP_peerinfo *LP_addpeer(struct LP_peerinfo *mypeer,int32_t mypubsock,char if ( (peer->isLP= isLP) != 0 ) LP_numactive_LP++; } - if ( IAMLP == 0 && peer->pairsock <= 0 ) + if ( IAMLP == 0 && peer->pairsock < 0 ) LP_cmdchannel(peer); /*if ( numpeers > peer->numpeers ) peer->numpeers = numpeers; @@ -144,6 +144,7 @@ struct LP_peerinfo *LP_addpeer(struct LP_peerinfo *mypeer,int32_t mypubsock,char { //printf("addpeer (%s:%u) pushport.%u subport.%u\n",ipaddr,port,pushport,subport); peer = calloc(1,sizeof(*peer)); + peer->pairsock = -1; if ( strcmp(peer->ipaddr,LP_myipaddr) == 0 ) peer->sessionid = G.LP_sessionid; else peer->sessionid = sessionid; @@ -159,12 +160,9 @@ struct LP_peerinfo *LP_addpeer(struct LP_peerinfo *mypeer,int32_t mypubsock,char if ( pushport != 0 && subport != 0 && (pushsock= nn_socket(AF_SP,NN_PUSH)) >= 0 ) { nanomsg_transportname(0,pushaddr,peer->ipaddr,pushport); - //nanomsg_transportname2(0,pushaddr2,peer->ipaddr,pushport); valid = 0; if ( nn_connect(pushsock,pushaddr) >= 0 ) valid++; - //if ( nn_connect(pushsock,pushaddr2) >= 0 ) - // valid++; if ( valid > 0 ) { //timeout = 10; @@ -214,7 +212,7 @@ struct LP_peerinfo *LP_addpeer(struct LP_peerinfo *mypeer,int32_t mypubsock,char printf("_LPaddpeer %s -> numpeers.%d mypubsock.%d other.(%d)\n",ipaddr,mypeer->numpeers,mypubsock,isLP); } else peer->numpeers = 1; // will become mypeer portable_mutex_unlock(&LP_peermutex); - if ( IAMLP == 0 && peer->pairsock <= 0 ) + if ( IAMLP == 0 && peer->pairsock < 0 ) LP_cmdchannel(peer); } else printf("%s invalid pushsock.%d or subsock.%d\n",peer->ipaddr,peer->pushsock,peer->subsock); } @@ -274,7 +272,7 @@ void LP_peer_recv(char *ipaddr,int32_t ismine,struct LP_pubkey_info *pubp) if ( (peer= LP_peerfind((uint32_t)calc_ipbits(ipaddr),RPC_port)) != 0 ) { peer->numrecv++; - if ( ismine != 0 && bits256_cmp(G.LP_mypub25519,pubp->pubkey) != 0 && (bits256_nonz(peer->pubkey) == 0 || pubp->pairsock <= 0) ) + if ( ismine != 0 && bits256_cmp(G.LP_mypub25519,pubp->pubkey) != 0 && (bits256_nonz(peer->pubkey) == 0 || pubp->pairsock < 0) ) { peer->pubkey = pubp->pubkey; pubp->pairsock = peer->pairsock; diff --git a/iguana/exchanges/LP_prices.c b/iguana/exchanges/LP_prices.c index 38ba3578d..a887331da 100644 --- a/iguana/exchanges/LP_prices.c +++ b/iguana/exchanges/LP_prices.c @@ -304,6 +304,7 @@ struct LP_pubkey_info *LP_pubkeyadd(bits256 pubkey) { pubp = calloc(1,sizeof(*pubp)); pubp->pubkey = pubkey; + pubp->pairsock = -1; if ( bits256_cmp(G.LP_mypub25519,pubkey) == 0 ) { memcpy(pubp->rmd160,G.LP_myrmd160,sizeof(pubp->rmd160));