Browse Source

Test

etomic
jl777 8 years ago
parent
commit
abf2ce9fe3
  1. 19
      iguana/exchanges/LP_commands.c
  2. 11
      iguana/exchanges/LP_nativeDEX.c

19
iguana/exchanges/LP_commands.c

@ -230,6 +230,18 @@ int32_t LP_tradecommand(char *myipaddr,int32_t pubsock,cJSON *argjson,uint8_t *d
return(retval);
}
cJSON *LP_dereference(cJSON *argjson,char *excludemethod)
{
cJSON *reqjson = 0;
if ( jstr(argjson,"method2") != 0 && strncmp(excludemethod,jstr(argjson,"method2"),strlen(excludemethod)) != 0 )
{
reqjson = jduplicate(argjson);
jdelete(reqjson,"method");
jaddstr(reqjson,"method",jstr(argjson,"method2"));
}
return(reqjson);
}
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 otherpeers,othernumutxos; struct LP_utxoinfo *utxo,*tmp; struct LP_peerinfo *peer; cJSON *retjson; struct iguana_info *ptr;
@ -402,16 +414,15 @@ forward(pubkey,hexstr)\n\
retstr = LP_orderbook(jstr(argjson,"base"),jstr(argjson,"rel"));
else if ( strcmp(method,"forward") == 0 )
{
cJSON *reqjson = jduplicate(argjson);
cJSON *reqjson;
printf("FORWARDED.(%s)\n",jprint(argjson,0));
jdelete(reqjson,"method");
if ( jstr(reqjson,"method2") != 0 && strncmp("forward",jstr(reqjson,"method2"),strlen("forward")) != 0 )
if ( (reqjson= LP_dereference(argjson,"forward")) != 0 )
{
jaddstr(reqjson,"method",jstr(argjson,"method2"));
if ( LP_forward(jbits256(argjson,"pubkey"),jprint(reqjson,1),1) > 0 )
retstr = clonestr("{\"result\":\"success\"}");
else retstr = clonestr("{\"error\":\"error forwarding\"}");
} else retstr = clonestr("{\"error\":\"cant recurse forwards\"}");
}
else if ( strcmp(method,"getpeers") == 0 )
retstr = LP_peers();

11
iguana/exchanges/LP_nativeDEX.c

@ -81,7 +81,7 @@ char *blocktrail_listtransactions(char *symbol,char *coinaddr,int32_t num,int32_
int32_t LP_pullsock_check(char *myipaddr,int32_t pubsock,int32_t pullsock,double profitmargin)
{
int32_t recvsize,len,datalen=0,nonz = 0; void *ptr; char *retstr,*jsonstr=0; cJSON *argjson;
int32_t recvsize,len,datalen=0,nonz = 0; void *ptr; char *retstr,*jsonstr=0; cJSON *argjson,*reqjson;
while ( (recvsize= nn_recv(pullsock,&ptr,NN_MSG,0)) >= 0 )
{
nonz++;
@ -99,10 +99,17 @@ 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 )
{
printf("forwardhex\n");
if ( (retstr= LP_forwardhex(jbits256(argjson,"pubkey"),jstr(argjson,"hex"))) != 0 )
free(retstr);
}
else if ( jstr(argjson,"method") != 0 && strcmp(jstr(argjson,"method"),"publish") == 0 )
{
if ( pubsock >= 0 && (reqjson= LP_dereference(argjson,"publish")) != 0 )
{
printf("publish.(%s)\n",jprint(reqjson,0));
LP_send(pubsock,jprint(reqjson,1),1);
}
}
else if ( LP_tradecommand(myipaddr,pubsock,argjson,&((uint8_t *)ptr)[len],recvsize - len,profitmargin) <= 0 )
{
if ( (retstr= stats_JSON(argjson,"127.0.0.1",0)) != 0 )

Loading…
Cancel
Save