Browse Source

Test

etomic
jl777 8 years ago
parent
commit
8b819f5790
  1. 4
      iguana/exchanges/LP_commands.c
  2. 6
      iguana/exchanges/LP_forwarding.c
  3. 6
      iguana/exchanges/LP_nativeDEX.c
  4. 2
      iguana/exchanges/mm.c
  5. 4
      iguana/exchanges/stats.c

4
iguana/exchanges/LP_commands.c

@ -231,7 +231,7 @@ int32_t LP_tradecommand(char *myipaddr,int32_t pubsock,cJSON *argjson,uint8_t *d
return(retval);
}
char *stats_JSON(cJSON *argjson,char *remoteaddr,uint16_t port) // from rpc port
char *stats_JSON(int32_t pubsock,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 otherpeers,othernumutxos; struct LP_peerinfo *peer; cJSON *retjson; struct iguana_info *ptr;
if ( (method= jstr(argjson,"method")) == 0 )
@ -422,7 +422,7 @@ forwardhex(pubkey,hex)\n\
else if ( strcmp(method,"lookup") == 0 )
retstr = LP_lookup(jbits256(argjson,"client"));
else if ( strcmp(method,"forwardhex") == 0 )
retstr = LP_forwardhex(jbits256(argjson,"pubkey"),jstr(argjson,"hex"));
retstr = LP_forwardhex(pubsock,jbits256(argjson,"pubkey"),jstr(argjson,"hex"));
else if ( strcmp(method,"notify") == 0 )
retstr = clonestr("{\"result\":\"success\",\"notify\":\"received\"}");
else if ( strcmp(method,"notified") == 0 )

6
iguana/exchanges/LP_forwarding.c

@ -123,7 +123,7 @@ cJSON *LP_dereference(cJSON *argjson,char *excludemethod)
return(reqjson);
}
char *LP_forwardhex(bits256 pubkey,char *hexstr)
char *LP_forwardhex(int32_t pubsock,bits256 pubkey,char *hexstr)
{
struct LP_forwardinfo *ptr=0; uint8_t *data; int32_t datalen=0,sentbytes=0; char *retstr=0; cJSON *retjson,*argjson,*reqjson;
if ( hexstr == 0 || hexstr[0] == 0 )
@ -136,7 +136,9 @@ char *LP_forwardhex(bits256 pubkey,char *hexstr)
if ( (argjson= cJSON_Parse((char *)data)) != 0 )
{
reqjson = LP_dereference(argjson,"forward");
retstr = LP_command_process(LP_mypeer != 0 ? LP_mypeer->ipaddr : "127.0.0.1",LP_mypubsock,reqjson,0,0,LP_profitratio - 1.);
if ( pubsock < 0 || bits256_cmp(pubkey,LP_mypubkey) == 0 )
retstr = LP_command_process(LP_mypeer != 0 ? LP_mypeer->ipaddr : "127.0.0.1",LP_mypubsock,reqjson,0,0,LP_profitratio - 1.);
else LP_send(pubsock,jprint(reqjson,0),1);
free_json(reqjson);
free_json(argjson);
}

6
iguana/exchanges/LP_nativeDEX.c

@ -84,7 +84,7 @@ char *LP_command_process(char *myipaddr,int32_t pubsock,cJSON *argjson,uint8_t *
char *retstr=0;
if ( LP_tradecommand(myipaddr,pubsock,argjson,data,datalen,profitmargin) <= 0 )
{
if ( (retstr= stats_JSON(argjson,"127.0.0.1",0)) != 0 )
if ( (retstr= stats_JSON(pubsock,argjson,"127.0.0.1",0)) != 0 )
{
printf("%s PULL.[%d]-> (%s)\n",myipaddr != 0 ? myipaddr : "127.0.0.1",datalen,retstr);
if ( pubsock >= 0 )
@ -114,7 +114,7 @@ int32_t LP_pullsock_check(char *myipaddr,int32_t pubsock,int32_t pullsock,double
portable_mutex_lock(&LP_commandmutex);
if ( jstr(argjson,"method") != 0 && strcmp(jstr(argjson,"method"),"forwardhex") == 0 )
{
if ( (retstr= LP_forwardhex(jbits256(argjson,"pubkey"),jstr(argjson,"hex"))) != 0 )
if ( (retstr= LP_forwardhex(pubsock,jbits256(argjson,"pubkey"),jstr(argjson,"hex"))) != 0 )
free(retstr);
}
else if ( jstr(argjson,"method") != 0 && strcmp(jstr(argjson,"method"),"publish") == 0 )
@ -147,7 +147,7 @@ int32_t LP_subsock_check(struct LP_peerinfo *peer)
if ( (argjson= cJSON_Parse((char *)ptr)) != 0 )
{
portable_mutex_lock(&LP_commandmutex);
if ( (retstr= stats_JSON(argjson,"127.0.0.1",0)) != 0 )
if ( (retstr= stats_JSON(-1,argjson,"127.0.0.1",0)) != 0 )
{
//printf("%s SUB.[%d] %s\n",peer->ipaddr,recvsize,(char *)ptr);
free(retstr);

2
iguana/exchanges/mm.c

@ -24,7 +24,7 @@
#include <stdint.h>
#include "OS_portable.h"
#define MAX(a,b) ((a) > (b) ? (a) : (b))
char *stats_JSON(cJSON *argjson,char *remoteaddr,uint16_t port);
char *stats_JSON(int32_t pubsock,cJSON *argjson,char *remoteaddr,uint16_t port);
#include "stats.c"
void LP_priceupdate(char *base,char *rel,double price,double avebid,double aveask,double highbid,double lowask,double PAXPRICES[32]);

4
iguana/exchanges/stats.c

@ -489,7 +489,7 @@ char *stats_rpcparse(char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *po
if ( userpass != 0 && jstr(argjson,"userpass") == 0 )
jaddstr(argjson,"userpass",userpass);
//printf("after urlconv.(%s) argjson.(%s)\n",jprint(json,0),jprint(argjson,0));
if ( (retstr= stats_JSON(argjson,remoteaddr,port)) != 0 )
if ( (retstr= stats_JSON(-1,argjson,remoteaddr,port)) != 0 )
{
if ( (retitem= cJSON_Parse(retstr)) != 0 )
jaddi(retarray,retitem);
@ -512,7 +512,7 @@ char *stats_rpcparse(char *retbuf,int32_t bufsize,int32_t *jsonflagp,int32_t *po
//printf("ARGJSON.(%s)\n",jprint(arg,0));
if ( userpass != 0 && jstr(arg,"userpass") == 0 )
jaddstr(arg,"userpass",userpass);
retstr = stats_JSON(arg,remoteaddr,port);
retstr = stats_JSON(-1,arg,remoteaddr,port);
}
free_json(argjson);
free_json(json);

Loading…
Cancel
Save