jl777 7 years ago
parent
commit
7a187951d6
  1. 21
      iguana/exchanges/LP_peers.c
  2. 7
      iguana/exchanges/LP_privkey.c

21
iguana/exchanges/LP_peers.c

@ -181,6 +181,27 @@ struct LP_peerinfo *LP_addpeer(struct LP_peerinfo *mypeer,int32_t mypubsock,char
return(peer); return(peer);
} }
uint64_t ip_port;
uint32_t recvtime,numrecv,ipbits,errortime,errors,numpeers,needping,lasttime,connected,lastutxos,lastpeers,diduquery,good,sessionid;
uint16_t port,netid;
void LP_closepeers()
{
struct LP_peerinfo *peer,*tmp;
HASH_ITER(hh,LP_peerinfos,peer,tmp)
{
portable_mutex_lock(&LP_peermutex);
HASH_DELETE(hh,LP_peerinfos,peer);
portable_mutex_unlock(&LP_peermutex);
if ( peer->pushsock >= 0 )
nn_close(peer->pushsock), peer->pushsock = -1;
if ( peer->subsock >= 0 )
nn_close(peer->subsock), peer->subsock = -1;
// free(peer); a small memleak to avoid freein inflight requests
}
}
/*int32_t LP_coinbus(uint16_t coin_busport) /*int32_t LP_coinbus(uint16_t coin_busport)
{ {
struct LP_peerinfo *peer,*tmp; char busaddr[64]; int32_t timeout,bussock = -1; struct LP_peerinfo *peer,*tmp; char busaddr[64]; int32_t timeout,bussock = -1;

7
iguana/exchanges/LP_privkey.c

@ -382,6 +382,11 @@ int32_t LP_passphrase_init(char *passphrase,char *gui,uint16_t netid,char *seedn
printf("sorry, LP nodes can only set netid during startup\n"); printf("sorry, LP nodes can only set netid during startup\n");
return(-1); return(-1);
} }
else if ( IAMLP == 0 && netid != G.netid )
{
LP_closepeers();
LP_initpeers(LP_mypubsock,LP_mypeer,LP_myipaddr,RPC_port,netid,seednode);
}
G.initializing = 1; G.initializing = 1;
if ( gui == 0 ) if ( gui == 0 )
gui = "cli"; gui = "cli";
@ -392,8 +397,6 @@ int32_t LP_passphrase_init(char *passphrase,char *gui,uint16_t netid,char *seedn
sleep(5); sleep(5);
} }
memset(&G,0,sizeof(G)); memset(&G,0,sizeof(G));
if ( IAMLP == 0 )
LP_initpeers(LP_mypubsock,LP_mypeer,LP_myipaddr,RPC_port,netid,seednode);
G.netid = netid; G.netid = netid;
safecopy(G.seednode,seednode,sizeof(G.seednode)); safecopy(G.seednode,seednode,sizeof(G.seednode));
vcalc_sha256(0,G.LP_passhash.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase)); vcalc_sha256(0,G.LP_passhash.bytes,(uint8_t *)passphrase,(int32_t)strlen(passphrase));

Loading…
Cancel
Save