Browse Source

Test

etomic
jl777 7 years ago
parent
commit
bce6409116
  1. 2
      iguana/exchanges/LP_include.h
  2. 1
      iguana/exchanges/LP_nativeDEX.c
  3. 2
      iguana/exchanges/LP_ordermatch.c
  4. 24
      iguana/exchanges/LP_peers.c
  5. 6
      iguana/exchanges/LP_signatures.c

2
iguana/exchanges/LP_include.h

@ -313,7 +313,7 @@ struct LP_peerinfo
{
UT_hash_handle hh;
uint64_t ip_port;
uint32_t numrecv,ipbits,errortime,errors,numpeers,needping,lasttime,connected,lastutxos,lastpeers,diduquery,good,sessionid;
uint32_t recvtime,numrecv,ipbits,errortime,errors,numpeers,needping,lasttime,connected,lastutxos,lastpeers,diduquery,good,sessionid;
int32_t pushsock,subsock,isLP;
uint16_t port;
char ipaddr[64];

1
iguana/exchanges/LP_nativeDEX.c

@ -21,6 +21,7 @@
// detecting new deposits in inventory
// BTC swaps
// bot progress
// will stale peers ever die?
// swap started event for bot
// lack of full depth
// withdraw too big

2
iguana/exchanges/LP_ordermatch.c

@ -453,7 +453,7 @@ void LP_reserved(void *ctx,char *myipaddr,int32_t mypubsock,struct LP_quoteinfo
Alice_expiration = 0;
LP_query(ctx,myipaddr,mypubsock,"connect",qp);
}
} else printf("reject reserved due to not eligible.%d or mismatched quote price %.8f vs maxprice %.8f\n",LP_alice_eligible(),price,maxprice);
} else printf("probably a timeout, reject reserved due to not eligible.%d or mismatched quote price %.8f vs maxprice %.8f\n",LP_alice_eligible(),price,maxprice);
}
char *LP_connectedalice(cJSON *argjson) // alice

24
iguana/exchanges/LP_peers.c

@ -206,11 +206,15 @@ int32_t LP_coinbus(uint16_t coin_busport)
return(bussock);
}
void LP_peer_recv(char *ipaddr)
void LP_peer_recv(char *ipaddr,int32_t ismine)
{
struct LP_peerinfo *peer;
if ( (peer= LP_peerfind((uint32_t)calc_ipbits(ipaddr),RPC_port)) != 0 )
{
peer->numrecv++;
if ( ismine != 0 )
peer->recvtime = (uint32_t)time(NULL);
}
}
int32_t LP_numpeers()
@ -251,15 +255,23 @@ uint16_t LP_randpeer(char *destip)
uint16_t LP_rarestpeer(char *destip)
{
struct LP_peerinfo *peer,*tmp,*rarest = 0;
struct LP_peerinfo *peer,*tmp,*rarest = 0; int32_t iter; uint32_t now;
now = (uint32_t)time(NULL);
destip[0] = 0;
HASH_ITER(hh,LP_peerinfos,peer,tmp)
for (iter=0; iter<2; iter++)
{
if ( peer->isLP != 0 )
HASH_ITER(hh,LP_peerinfos,peer,tmp)
{
if ( rarest == 0 || peer->numrecv < rarest->numrecv )
rarest = peer;
if ( iter == 0 && peer->recvtime < now-3600 )
continue;
if ( peer->isLP != 0 )
{
if ( rarest == 0 || peer->numrecv < rarest->numrecv )
rarest = peer;
}
}
if ( rarest != 0 )
break;
}
if ( rarest == 0 )
LP_randpeer(destip);

6
iguana/exchanges/LP_signatures.c

@ -572,7 +572,11 @@ void LP_notify_pubkeys(void *ctx,int32_t pubsock)
if ( IAMLP != 0 )
{
if ( LP_rarestpeer(LPipaddr) != 0 )
{
jaddstr(reqjson,"isLP",LPipaddr);
if ( strcmp(LPipaddr,LP_myipaddr) == 0 )
jaddnum(reqjson,"ismine",1);
}
else printf("no LPipaddr\n");
}
jaddnum(reqjson,"session",G.LP_sessionid);
@ -590,7 +594,7 @@ char *LP_notify_recv(cJSON *argjson)
if ( (ipaddr= jstr(argjson,"isLP")) != 0 )
{
//printf("notify got isLP %s\n",ipaddr);
LP_peer_recv(ipaddr);
LP_peer_recv(ipaddr,jint(argjson,ismine));
if ( IAMLP != 0 && G.LP_IAMLP == 0 && strcmp(ipaddr,LP_myipaddr) == 0 )
{
if ( bits256_cmp(pub,G.LP_mypub25519) != 0 )

Loading…
Cancel
Save