Browse Source

Recent swaps

etomic
jl777 7 years ago
parent
commit
70ec72915d
  1. 5
      iguana/exchanges/LP_commands.c
  2. 2
      iguana/exchanges/LP_nativeDEX.c
  3. 32
      iguana/exchanges/LP_remember.c
  4. 3
      iguana/exchanges/recentswaps
  5. 1
      iguana/exchanges/stop

5
iguana/exchanges/LP_commands.c

@ -110,6 +110,7 @@ sell(base, rel, price, basevolume, timeout=10, duration=3600, nonce)*\n\
withdraw(coin, outputs[])*\n\
sendrawtransaction(coin, signedtx)\n\
swapstatus()*\n\
recentswaps(limit=3)\n\
swapstatus(requestid, quoteid)*\n\
public API:\n \
getcoins()\n\
@ -159,6 +160,10 @@ dividends(coin, height, <args>)\n\
}
return(clonestr("{\"result\":\"success\"}"));
}
else if ( strcmp(method,"recentswaps") == 0 )
{
return(LP_recent_swaps(jint(argjson,"limit")));
}
else if ( strcmp(method,"stop") == 0 )
{
printf("DEBUG stop\n");

2
iguana/exchanges/LP_nativeDEX.c

@ -24,7 +24,7 @@
// process stats.log local file
// verify portfolio, pricearray, interest to KMD withdraw
// handles<->pubkeys
// deal with offline pubkeys, reputations, etc.
// alice only coins GAME UNO BTM ANC: GAME BTCD PPC RDD XZC POT EAC FTC BASH SPR WDC UNO XPM XCN BELA CHC DIME MEC NAUT MED AUR MAX DGC RIC EB3 DOT BTM GEO ANC CANN ICASH WBB SRC PTC ADZ TIPS EQT START EFL FST FJC NYC GCN

32
iguana/exchanges/LP_remember.c

@ -1219,3 +1219,35 @@ void LP_tradecommand_log(cJSON *argjson)
}
}
char *LP_recent_swaps(int32_t limit)
{
char fname[512]; long fsize,offset; FILE *fp; int32_t i=0; uint32_t requestid,quoteid; cJSON *array,*item;
if ( limit <= 0 )
limit = 3;
sprintf(fname,"%s/SWAPS/list",GLOBAL_DBDIR), OS_compatible_path(fname);
array = cJSON_CreateArray();
if ( (fp= fopen(fname,"rb")) != 0 )
{
fseek(fp,0,SEEK_END);
fsize = ftell(fp);
offset = (sizeof(requestid) + sizeof(quoteid));
while ( offset <= fsize )
{
i++;
offset = i * (sizeof(requestid) + sizeof(quoteid));
fseek(fp,fsize-offset,SEEK_SET);
if ( ftell(fp) == fsize-offset )
{
if ( fread(&requestid,1,sizeof(requestid),fp) == sizeof(requestid) && fread(&quoteid,1,sizeof(quoteid),fp) == sizeof(quoteid) )
{
item = cJSON_CreateArray();
jaddinum(item,requestid);
jaddinum(item,quoteid);
jaddi(array,item);
} else break;
} else break;
}
fclose(fp);
}
return(jprint(array,1));
}

3
iguana/exchanges/recentswaps

@ -0,0 +1,3 @@
#!/bin/bash
source userpass
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"recentswaps\",\"limit\":1}"

1
iguana/exchanges/stop

@ -1,2 +1,3 @@
#!/bin/bash
source userpass
curl --url "http://127.0.0.1:7783" --data "{\"userpass\":\"$userpass\",\"method\":\"stop\"}"

Loading…
Cancel
Save