Browse Source

Test

etomic
jl777 7 years ago
parent
commit
86ea52d2eb
  1. 2
      iguana/exchanges/LP_include.h
  2. 2
      iguana/exchanges/LP_remember.c
  3. 15
      iguana/exchanges/LP_tradebots.c

2
iguana/exchanges/LP_include.h

@ -389,7 +389,7 @@ int32_t LP_reserved_msg(char *base,char *rel,bits256 pubkey,char *msg);
struct iguana_info *LP_coinfind(char *symbol);
int32_t LP_crc32find(int32_t *duplicatep,int32_t ind,uint32_t crc32);
char *LP_pricepings(void *ctx,char *myipaddr,int32_t pubsock,char *base,char *rel,double price);
void LP_tradebot_finished(uint32_t tradeid);
void LP_tradebot_finished(uint32_t tradeid,uint32_t requestid,uint32_t quoteid);
uint64_t LP_txfeecalc(struct iguana_info *coin,uint64_t txfee,int32_t txlen);
struct LP_address *_LP_address(struct iguana_info *coin,char *coinaddr);
struct LP_address *_LP_addressfind(struct iguana_info *coin,char *coinaddr);

2
iguana/exchanges/LP_remember.c

@ -1110,7 +1110,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti
LP_numfinished++;
printf("SWAP %u-%u finished LP_numfinished.%d !\n",requestid,quoteid,LP_numfinished);
if ( rswap.tradeid != 0 )
LP_tradebot_finished(rswap.tradeid);
LP_tradebot_finished(rswap.tradeid,rswap.requestid,rswap.quoteid);
sprintf(fname,"%s/SWAPS/%u-%u.finished",GLOBAL_DBDIR,rswap.requestid,rswap.quoteid), OS_compatible_path(fname);
if ( (fp= fopen(fname,"wb")) != 0 )
{

15
iguana/exchanges/LP_tradebots.c

@ -100,8 +100,11 @@ cJSON *LP_tradebot_tradejson(struct LP_tradebot_trade *tp,int32_t dispflag)
double price,basevol; cJSON *item = cJSON_CreateObject();
if ( tp == 0 )
return(cJSON_Parse("{}"));
jaddnum(item,"requestid",tp->requestid);
jaddnum(item,"quoteid",tp->quoteid);
if ( tp->requestid != 0 && tp->quoteid != 0 )
{
jaddnum(item,"requestid",tp->requestid);
jaddnum(item,"quoteid",tp->quoteid);
} else jaddnum(item,"tradeid",tp->tradeid);
if ( tp->basevol > SMALLVAL && tp->relvol > SMALLVAL )
{
if ( dispflag > 0 )
@ -295,7 +298,7 @@ void LP_tradebot_timeslice(void *ctx,struct LP_tradebot *bot)
bot->pause = (uint32_t)time(NULL);
}
void LP_tradebot_finished(uint32_t tradeid)
void LP_tradebot_finished(uint32_t tradeid,uint32_t requestid,uint32_t quoteid)
{
struct LP_tradebot *bot,*tmp; int32_t i; struct LP_tradebot_trade *tp;
DL_FOREACH_SAFE(LP_tradebots,bot,tmp)
@ -304,11 +307,14 @@ void LP_tradebot_finished(uint32_t tradeid)
{
if ( (tp= bot->trades[i]) != 0 && tp->finished == 0 && tp->tradeid == tradeid )
{
tp->requestid = requestid;
tp->quoteid = quoteid;
bot->pendbasesum -= tp->basevol, bot->basesum += tp->basevol;
bot->pendrelsum -= tp->relvol, bot->relsum += tp->relvol;
bot->numpending--, bot->completed++;
printf("detected completion aliceid.%llx r.%u q.%u\n",(long long)tp->aliceid,tp->requestid,tp->quoteid);
printf("bot.%u detected completion tradeid.%u aliceid.%llx r.%u q.%u\n",bot->id,tp->tradeid,(long long)tp->aliceid,tp->requestid,tp->quoteid);
tp->finished = (uint32_t)time(NULL);
printf("%s\n",jprint(LP_tradebot_json(bot),1));
break;
}
}
@ -373,7 +379,6 @@ char *LP_tradebot_buy(int32_t dispdir,char *base,char *rel,double maxprice,doubl
for (i=0; i<n; i++)
{
item = jitem(array,i);
//valuesum += j64bits(item,"value") + j64bits(item,"value2");
abalance += j64bits(item,"satoshis");
}
}

Loading…
Cancel
Save