jl777 7 years ago
parent
commit
614a2c5744
  1. 4
      iguana/exchanges/LP_nativeDEX.c
  2. 4
      iguana/exchanges/LP_network.c
  3. 12
      iguana/exchanges/LP_peers.c
  4. 1
      iguana/exchanges/LP_prices.c

4
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 )
{

4
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; i<Numpsocks; i++)
@ -805,7 +805,7 @@ char *issue_LP_psock(char *destip,uint16_t destport,int32_t ispaired,int32_t cmd
sprintf(url,"http://%s:%u/api/stats/psock?ispaired=%d&cmdchannel=%d&pubkey=%s",destip,destport-1,ispaired,cmdchannel,bits256_str(str,G.LP_mypub25519));
//return(LP_issue_curl("psock",destip,destport,url));
retstr = issue_curlt(url,LP_HTTP_TIMEOUT*3);
//printf("issue_LP_psock got (%s) from %s\n",retstr,url); // this is needed?!
printf("issue_LP_psock got (%s) from %s\n",retstr,url); // this is needed?!
return(retstr);
}

12
iguana/exchanges/LP_peers.c

@ -86,7 +86,7 @@ void LP_cmdchannels()
{
HASH_ITER(hh,LP_peerinfos,peer,tmp)
{
if ( peer->pairsock <= 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;

1
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));

Loading…
Cancel
Save