Browse Source

Test

etomic
jl777 8 years ago
parent
commit
c80a705838
  1. 15
      iguana/exchanges/LP_commands.c
  2. 2
      iguana/exchanges/LP_nativeDEX.c
  3. 11
      iguana/exchanges/LP_utxos.c

15
iguana/exchanges/LP_commands.c

@ -192,7 +192,7 @@ char *LP_connected(cJSON *argjson)
char *stats_JSON(cJSON *argjson,char *remoteaddr,uint16_t port) // from rpc port char *stats_JSON(cJSON *argjson,char *remoteaddr,uint16_t port) // from rpc port
{ {
char *method,*ipaddr,*userpass,*base,*rel,*coin,*retstr = 0; uint16_t argport,pushport,subport; int32_t amclient,otherpeers,othernumutxos; struct LP_peerinfo *peer; cJSON *retjson; char *method,*ipaddr,*userpass,*base,*rel,*coin,*retstr = 0; uint16_t argport,pushport,subport; int32_t amclient,otherpeers,othernumutxos; struct LP_utxoinfo *utxo,*tmp; struct LP_peerinfo *peer; cJSON *retjson;
if ( (method= jstr(argjson,"method")) == 0 ) if ( (method= jstr(argjson,"method")) == 0 )
return(clonestr("{\"error\":\"need method in request\"}")); return(clonestr("{\"error\":\"need method in request\"}"));
if ( USERPASS[0] != 0 && strcmp(remoteaddr,"127.0.0.1") == 0 && port != 0 ) if ( USERPASS[0] != 0 && strcmp(remoteaddr,"127.0.0.1") == 0 && port != 0 )
@ -213,7 +213,18 @@ char *stats_JSON(cJSON *argjson,char *remoteaddr,uint16_t port) // from rpc port
{ {
if ( LP_mypriceset(base,rel,jdouble(argjson,"price")) < 0 ) if ( LP_mypriceset(base,rel,jdouble(argjson,"price")) < 0 )
return(clonestr("{\"error\":\"couldnt set price\"}")); return(clonestr("{\"error\":\"couldnt set price\"}"));
else return(clonestr("{\"result\":\"success\"}")); else
{
if ( IAMCLIENT == 0 )
{
HASH_ITER(hh,LP_utxoinfos,utxo,tmp)
{
if ( LP_ismine(utxo) != 0 && strcmp(utxo->coin,base) == 0 )
LP_priceping(LP_mypubsock,utxo,rel,LP_profitratio - 1.);
}
}
return(clonestr("{\"result\":\"success\"}"));
}
} }
else if ( strcmp(method,"myprice") == 0 ) else if ( strcmp(method,"myprice") == 0 )
{ {

2
iguana/exchanges/LP_nativeDEX.c

@ -162,7 +162,7 @@ void LP_mainloop(struct LP_peerinfo *mypeer,uint16_t mypubport,int32_t pubsock,i
{ {
HASH_ITER(hh,LP_utxoinfos,utxo,utmp) HASH_ITER(hh,LP_utxoinfos,utxo,utmp)
{ {
if ( strcmp(utxo->ipaddr,mypeer->ipaddr) == 0 && utxo->port == mypeer->port ) if ( LP_ismine(utxo) != 0 )
{ {
if ( strcmp(utxo->coin,"KMD") == 0 ) if ( strcmp(utxo->coin,"KMD") == 0 )
LP_priceping(pubsock,utxo,"BTC",profitmargin); LP_priceping(pubsock,utxo,"BTC",profitmargin);

11
iguana/exchanges/LP_utxos.c

@ -18,6 +18,17 @@
// marketmaker // marketmaker
// //
int32_t LP_ismine(struct LP_utxoinfo *utxo)
{
if ( strcmp(utxo->ipaddr,"127.0.0.1") == 0 )
return(1);
else if ( LP_mypeer == 0 )
return(0);
else if ( strcmp(utxo->ipaddr,LP_mypeer->ipaddr) == 0 && utxo->port == LP_mypeer->port )\
return(1);
else return(0);
}
struct LP_utxoinfo *LP_utxofind(bits256 txid,int32_t vout) struct LP_utxoinfo *LP_utxofind(bits256 txid,int32_t vout)
{ {
struct LP_utxoinfo *utxo=0; uint8_t key[sizeof(txid) + sizeof(vout)]; struct LP_utxoinfo *utxo=0; uint8_t key[sizeof(txid) + sizeof(vout)];

Loading…
Cancel
Save