Browse Source

Test

etomic
jl777 7 years ago
parent
commit
5284db6b19
  1. 2
      iguana/exchanges/LP_coins.c
  2. 4
      iguana/exchanges/LP_nativeDEX.c
  3. 11
      iguana/exchanges/LP_stats.c
  4. 6
      iguana/exchanges/LP_swap.c
  5. 6
      iguana/exchanges/LP_tradebots.c

2
iguana/exchanges/LP_coins.c

@ -229,7 +229,7 @@ cJSON *LP_coinjson(struct iguana_info *coin,int32_t showwif)
jaddnum(item,"pubtype",coin->pubtype); jaddnum(item,"pubtype",coin->pubtype);
jaddnum(item,"p2shtype",coin->p2shtype); jaddnum(item,"p2shtype",coin->p2shtype);
jaddnum(item,"wiftype",coin->wiftype); jaddnum(item,"wiftype",coin->wiftype);
jaddnum(item,"txfee",coin->txfee); jaddnum(item,"txfee",strcmp(coin->symbol,"BTC") != 0 ? coin->txfee : LP_txfeecalc(coin,0,0));
return(item); return(item);
} }

4
iguana/exchanges/LP_nativeDEX.c

@ -666,6 +666,8 @@ void LP_initcoins(void *ctx,int32_t pubsock,cJSON *coins)
if ( LP_getheight(coin) <= 0 ) if ( LP_getheight(coin) <= 0 )
coin->inactive = (uint32_t)time(NULL); coin->inactive = (uint32_t)time(NULL);
else LP_unspents_load(coin->symbol,coin->smartaddr); else LP_unspents_load(coin->symbol,coin->smartaddr);
if ( coin->txfee == 0 && strcmp(coin->symbol,"BTC") != 0 )
coin->txfee = LP_MIN_TXFEE;
} }
} }
if ( (n= cJSON_GetArraySize(coins)) > 0 ) if ( (n= cJSON_GetArraySize(coins)) > 0 )
@ -683,6 +685,8 @@ void LP_initcoins(void *ctx,int32_t pubsock,cJSON *coins)
if ( LP_getheight(coin) <= 0 ) if ( LP_getheight(coin) <= 0 )
coin->inactive = (uint32_t)time(NULL); coin->inactive = (uint32_t)time(NULL);
else LP_unspents_load(coin->symbol,coin->smartaddr); else LP_unspents_load(coin->symbol,coin->smartaddr);
if ( coin->txfee == 0 && strcmp(coin->symbol,"BTC") != 0 )
coin->txfee = LP_MIN_TXFEE;
} }
} }
} }

11
iguana/exchanges/LP_stats.c

@ -34,6 +34,13 @@ int32_t LP_statslog_parsequote(char *method,cJSON *lineobj);
char *LP_stats_methods[] = { "unknown", "request", "reserved", "connect", "connected", "tradestatus" }; char *LP_stats_methods[] = { "unknown", "request", "reserved", "connect", "connected", "tradestatus" };
uint32_t LP_atomic_locktime(char *base,char *rel)
{
if ( strcmp(base,"BTC") != 0 && strcmp(rel,"BTC") != 0 )
return(INSTANTDEX_LOCKTIME);
else return(INSTANTDEX_LOCKTIME * 10);
}
static uint32_t LP_requests,LP_reserveds,LP_connects,LP_connecteds,LP_tradestatuses,LP_parse_errors,LP_unknowns,LP_duplicates,LP_aliceids; static uint32_t LP_requests,LP_reserveds,LP_connects,LP_connecteds,LP_tradestatuses,LP_parse_errors,LP_unknowns,LP_duplicates,LP_aliceids;
void LP_tradecommand_log(cJSON *argjson) void LP_tradecommand_log(cJSON *argjson)
@ -195,7 +202,7 @@ int32_t LP_swapstats_update(struct LP_swapstats *sp,struct LP_quoteinfo *qp,cJSO
if ( (sp->finished= juint(lineobj,"timestamp")) == 0 ) if ( (sp->finished= juint(lineobj,"timestamp")) == 0 )
sp->finished = (uint32_t)time(NULL); sp->finished = (uint32_t)time(NULL);
} }
if ( sp->finished == 0 && time(NULL) > sp->Q.timestamp+INSTANTDEX_LOCKTIME*2 ) if ( sp->finished == 0 && time(NULL) > sp->Q.timestamp+LP_atomic_locktime(base,rel)*2 )
sp->expired = (uint32_t)time(NULL); sp->expired = (uint32_t)time(NULL);
return(0); return(0);
} }
@ -337,7 +344,7 @@ char *LP_statslog_disp(int32_t n,uint32_t starttime,uint32_t endtime,char *refgu
array = cJSON_CreateArray(); array = cJSON_CreateArray();
HASH_ITER(hh,LP_swapstats,sp,tmp) HASH_ITER(hh,LP_swapstats,sp,tmp)
{ {
if ( sp->finished == 0 && time(NULL) > sp->Q.timestamp+INSTANTDEX_LOCKTIME*2 ) if ( sp->finished == 0 && time(NULL) > sp->Q.timestamp+LP_atomic_locktime(sp->Q.srccoin,sp->Q.destcoin)*2 )
sp->expired = (uint32_t)time(NULL); sp->expired = (uint32_t)time(NULL);
dispflag = 0; dispflag = 0;
if ( starttime == 0 && endtime == 0 ) if ( starttime == 0 && endtime == 0 )

6
iguana/exchanges/LP_swap.c

@ -801,7 +801,7 @@ void LP_bobloop(void *_swap)
basilisk_bobpayment_reclaim(swap,swap->I.callduration); basilisk_bobpayment_reclaim(swap,swap->I.callduration);
if ( swap->N.pair >= 0 ) if ( swap->N.pair >= 0 )
nn_close(swap->N.pair), swap->N.pair = -1; nn_close(swap->N.pair), swap->N.pair = -1;
LP_swapwait(swap->I.req.requestid,swap->I.req.quoteid,INSTANTDEX_LOCKTIME*2,30); LP_swapwait(swap->I.req.requestid,swap->I.req.quoteid,LP_atomic_locktime(swap->bobcoin.symbol,swap->alicecoin.symbol)*2,30);
} }
} }
} }
@ -867,7 +867,7 @@ void LP_aliceloop(void *_swap)
}*/ }*/
if ( swap->N.pair >= 0 ) if ( swap->N.pair >= 0 )
nn_close(swap->N.pair), swap->N.pair = -1; nn_close(swap->N.pair), swap->N.pair = -1;
LP_swapwait(swap->I.req.requestid,swap->I.req.quoteid,INSTANTDEX_LOCKTIME*2,30); LP_swapwait(swap->I.req.requestid,swap->I.req.quoteid,LP_atomic_locktime(swap->bobcoin.symbol,swap->alicecoin.symbol)*2,30);
} }
} }
} }
@ -1009,7 +1009,7 @@ struct basilisk_swap *bitcoin_swapinit(bits256 privkey,uint8_t *pubkey33,bits256
printf("bitcoin_swapinit %s Btxfee %.8f rejected\n",swap->I.req.src,dstr(swap->I.Btxfee)); printf("bitcoin_swapinit %s Btxfee %.8f rejected\n",swap->I.req.src,dstr(swap->I.Btxfee));
return(0); return(0);
} }
swap->I.putduration = swap->I.callduration = INSTANTDEX_LOCKTIME; swap->I.putduration = swap->I.callduration = LP_atomic_locktime(swap->bobcoin.symbol,swap->alicecoin.symbol);
if ( optionduration < 0 ) if ( optionduration < 0 )
swap->I.putduration -= optionduration; swap->I.putduration -= optionduration;
else if ( optionduration > 0 ) else if ( optionduration > 0 )

6
iguana/exchanges/LP_tradebots.c

@ -27,13 +27,13 @@ struct LP_tradebot_trade
uint64_t aliceid; uint64_t aliceid;
int32_t dispdir; int32_t dispdir;
uint32_t started,finished,requestid,quoteid,tradeid,expired; uint32_t started,finished,requestid,quoteid,tradeid,expired;
char base[32],rel[32],event[32]; char base[65],rel[65],event[32];
}; };
struct LP_tradebot struct LP_tradebot
{ {
struct LP_tradebot *next,*prev; struct LP_tradebot *next,*prev;
char name[128],base[32],rel[32]; char name[128],base[65],rel[65];
int32_t numtrades,numpending,completed,dispdir; int32_t numtrades,numpending,completed,dispdir;
double maxprice,totalrelvolume,totalbasevolume,basesum,relsum,pendbasesum,pendrelsum; double maxprice,totalrelvolume,totalbasevolume,basesum,relsum,pendbasesum,pendrelsum;
uint32_t lasttime,dead,pause,userpause,started,id; uint32_t lasttime,dead,pause,userpause,started,id;
@ -74,7 +74,7 @@ void LP_tradebot_calcstats(struct LP_tradebot *bot)
{ {
if ( (tp= bot->trades[i]) == 0 ) if ( (tp= bot->trades[i]) == 0 )
continue; continue;
if ( tp->finished == 0 && time(NULL) > tp->started+INSTANTDEX_LOCKTIME*2 ) if ( tp->finished == 0 && time(NULL) > tp->started+LP_atomic_locktime(bot->base,bot->rel)*2 )
{ {
tp->expired = tp->finished = (uint32_t)time(NULL); tp->expired = tp->finished = (uint32_t)time(NULL);
printf("tradeid.%u expired\n",tp->tradeid); printf("tradeid.%u expired\n",tp->tradeid);

Loading…
Cancel
Save