Browse Source

Detect and skip status for realtime swaps

beta
jl777 7 years ago
parent
commit
7ae3b102a3
  1. 8
      iguana/exchanges/LP_nativeDEX.c
  2. 18
      iguana/exchanges/LP_remember.c
  3. 3
      iguana/exchanges/LP_swap.c

8
iguana/exchanges/LP_nativeDEX.c

@ -21,11 +21,11 @@
//
// new features:
// -check for completed one being spent
// better error message in ordermatch
// withdraw
// sign, spv check
// bittrex balancing
// withdraw
// stats, fix pricearray
// better error message in ordermatch
// verify portfolio
#include <stdio.h>
@ -53,16 +53,16 @@ int32_t LP_mypullsock = -1;
int32_t LP_showwif,IAMLP = 0;
double LP_profitratio = 1.;
struct LP_privkey { bits256 privkey; uint8_t rmd160[20]; };
struct LP_globals
{
struct LP_utxoinfo *LP_utxoinfos[2],*LP_utxoinfos2[2];
bits256 LP_mypub25519,LP_mypriv25519;
uint64_t LP_skipstatus[10000];
uint8_t LP_myrmd160[20],LP_pubsecp[33];
uint32_t LP_sessionid,counter;
int32_t LP_pendingswaps,USERPASS_COUNTER,LP_numprivkeys,initializing,waiting;
int32_t LP_pendingswaps,USERPASS_COUNTER,LP_numprivkeys,initializing,waiting,LP_numskips;
char USERPASS[65],USERPASS_WIFSTR[64],LP_myrmd160str[41],gui[16];
struct LP_privkey LP_privkeys[100];
} G;

18
iguana/exchanges/LP_remember.c

@ -1037,7 +1037,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti
char *basilisk_swaplist()
{
char fname[512]; FILE *fp; cJSON *item,*retjson,*array,*totalsobj; uint32_t quoteid,requestid; int64_t KMDtotals[16],BTCtotals[16],Btotal,Ktotal; int32_t i;
char fname[512]; FILE *fp; cJSON *item,*retjson,*array,*totalsobj; uint32_t r,q,quoteid,requestid; int64_t KMDtotals[16],BTCtotals[16],Btotal,Ktotal; int32_t i;
portable_mutex_lock(&LP_swaplistmutex);
memset(KMDtotals,0,sizeof(KMDtotals));
memset(BTCtotals,0,sizeof(BTCtotals));
@ -1052,13 +1052,21 @@ char *basilisk_swaplist()
while ( fread(&requestid,1,sizeof(requestid),fp) == sizeof(requestid) && fread(&quoteid,1,sizeof(quoteid),fp) == sizeof(quoteid) )
{
flag = 0;
/*for (i=0; i<myinfo->numswaps; i++)
if ( (swap= myinfo->swaps[i]) != 0 && swap->I.req.requestid == requestid && swap->I.req.quoteid == quoteid )
for (i=0; i<G.LP_numskips; i++)
{
r = (uint32_t)(G.LP_skipstatus[i] >> 32);
q = (uint32_t)G.LP_skipstatus[i];
if ( r == requestid && q == quoteid )
{
jaddi(array,basilisk_swapjson(swap));
item = cJSON_CreateObject();
jaddstr(item,"status","realtime");
jaddnum(item,"requestid",r);
jaddnum(item,"quoteid",q);
jaddi(array,item);
flag = 1;
break;
}*/
}
}
if ( flag == 0 )
{
if ( (item= basilisk_remember(KMDtotals,BTCtotals,requestid,quoteid)) != 0 )

3
iguana/exchanges/LP_swap.c

@ -1071,6 +1071,9 @@ struct basilisk_swap *LP_swapinit(int32_t iambob,int32_t optionduration,bits256
swap->ctx = bitcoin_ctx();
vcalc_sha256(0,swap->I.orderhash.bytes,(uint8_t *)rp,sizeof(*rp));
swap->I.req = *rp;
G.LP_skipstatus[G.LP_numskips] = ((uint64_t)rp->requestid << 32) | rp->quoteid;
if ( G.LP_numskips < sizeof(G.LP_skipstatus)/sizeof(*G.LP_skipstatus) )
G.LP_numskips++;
printf("basilisk_thread_start request.%u iambob.%d (%s/%s) quoteid.%u\n",rp->requestid,iambob,rp->src,rp->dest,rp->quoteid);
bitcoin_pubkey33(swap->ctx,pubkey33,privkey);
pubkey25519 = curve25519(privkey,curve25519_basepoint9());

Loading…
Cancel
Save