jl777 7 years ago
parent
commit
e79ca5e60a
  1. 106
      iguana/exchanges/LP_ordermatch.c
  2. 2
      iguana/exchanges/LP_statemachine.c
  3. 4
      iguana/exchanges/LP_swap.c

106
iguana/exchanges/LP_ordermatch.c

@ -1008,6 +1008,59 @@ void LP_tradesloop(void *ctx)
{ {
LP_millistats_update(&LP_tradesloop_stats); LP_millistats_update(&LP_tradesloop_stats);
nonz = 0; nonz = 0;
HASH_ITER(hh,LP_trades,tp,tmp)
{
if ( tp->negotiationdone != 0 )
continue;
timeout = LP_AUTOTRADE_TIMEOUT;
if ( (coin= LP_coinfind(tp->Q.srccoin)) != 0 && coin->electrum != 0 )
timeout += LP_AUTOTRADE_TIMEOUT * .5;
if ( (coin= LP_coinfind(tp->Q.destcoin)) != 0 && coin->electrum != 0 )
timeout += LP_AUTOTRADE_TIMEOUT * .5;
now = (uint32_t)time(NULL);
if ( now > tp->lastprocessed )
{
if ( tp->iambob == 0 )
{
if ( tp->bestprice > 0. )
{
if ( tp->connectsent == 0 )
{
tp->negotiationdone = (uint32_t)time(NULL);
LP_Alicemaxprice = tp->bestprice;
LP_reserved(ctx,LP_myipaddr,LP_mypubsock,&tp->Qs[LP_CONNECT]); // send LP_CONNECT
tp->connectsent = now;
//printf("send LP_connect aliceid.%llu %.8f\n",(long long)tp->aliceid,tp->bestprice);
}
else if ( now < tp->firstprocessed+timeout && ((tp->firstprocessed - now) % 10) == 9 )
{
//LP_Alicemaxprice = tp->bestprice;
//LP_reserved(ctx,LP_myipaddr,LP_mypubsock,&tp->Qs[LP_CONNECT]); // send LP_CONNECT
printf("mark slow LP_connect aliceid.%llu %.8f\n",(long long)tp->aliceid,tp->bestprice);
if ( (pubp= LP_pubkeyfind(tp->Qs[LP_CONNECT].srchash)) != 0 )
pubp->slowresponse++;
}
}
}
}
}
now = (uint32_t)time(NULL);
HASH_ITER(hh,LP_trades,tp,tmp)
{
timeout = LP_AUTOTRADE_TIMEOUT;
if ( (coin= LP_coinfind(tp->Q.srccoin)) != 0 && coin->electrum != 0 )
timeout += LP_AUTOTRADE_TIMEOUT * .5;
if ( (coin= LP_coinfind(tp->Q.destcoin)) != 0 && coin->electrum != 0 )
timeout += LP_AUTOTRADE_TIMEOUT * .5;
if ( now > tp->firstprocessed+timeout*10 )
{
//printf("purge swap aliceid.%llu\n",(long long)tp->aliceid);
portable_mutex_lock(&LP_tradesmutex);
HASH_DELETE(hh,LP_trades,tp);
portable_mutex_unlock(&LP_tradesmutex);
free(tp);
}
}
DL_FOREACH_SAFE(LP_tradesQ,qtp,tmp) DL_FOREACH_SAFE(LP_tradesQ,qtp,tmp)
{ {
now = (uint32_t)time(NULL); now = (uint32_t)time(NULL);
@ -1089,59 +1142,6 @@ void LP_tradesloop(void *ctx)
} }
} else printf("qtp->iambob.%d vs tp->iambob.%d\n",qtp->iambob,tp->iambob); } else printf("qtp->iambob.%d vs tp->iambob.%d\n",qtp->iambob,tp->iambob);
} }
HASH_ITER(hh,LP_trades,tp,tmp)
{
if ( tp->negotiationdone != 0 )
continue;
timeout = LP_AUTOTRADE_TIMEOUT;
if ( (coin= LP_coinfind(tp->Q.srccoin)) != 0 && coin->electrum != 0 )
timeout += LP_AUTOTRADE_TIMEOUT * .5;
if ( (coin= LP_coinfind(tp->Q.destcoin)) != 0 && coin->electrum != 0 )
timeout += LP_AUTOTRADE_TIMEOUT * .5;
now = (uint32_t)time(NULL);
if ( now > tp->lastprocessed )
{
if ( tp->iambob == 0 )
{
if ( tp->bestprice > 0. )
{
if ( tp->connectsent == 0 )
{
tp->negotiationdone = (uint32_t)time(NULL);
LP_Alicemaxprice = tp->bestprice;
LP_reserved(ctx,LP_myipaddr,LP_mypubsock,&tp->Qs[LP_CONNECT]); // send LP_CONNECT
tp->connectsent = now;
//printf("send LP_connect aliceid.%llu %.8f\n",(long long)tp->aliceid,tp->bestprice);
}
else if ( now < tp->firstprocessed+timeout && ((tp->firstprocessed - now) % 10) == 9 )
{
//LP_Alicemaxprice = tp->bestprice;
//LP_reserved(ctx,LP_myipaddr,LP_mypubsock,&tp->Qs[LP_CONNECT]); // send LP_CONNECT
printf("mark slow LP_connect aliceid.%llu %.8f\n",(long long)tp->aliceid,tp->bestprice);
if ( (pubp= LP_pubkeyfind(tp->Qs[LP_CONNECT].srchash)) != 0 )
pubp->slowresponse++;
}
}
}
}
}
now = (uint32_t)time(NULL);
HASH_ITER(hh,LP_trades,tp,tmp)
{
timeout = LP_AUTOTRADE_TIMEOUT;
if ( (coin= LP_coinfind(tp->Q.srccoin)) != 0 && coin->electrum != 0 )
timeout += LP_AUTOTRADE_TIMEOUT * .5;
if ( (coin= LP_coinfind(tp->Q.destcoin)) != 0 && coin->electrum != 0 )
timeout += LP_AUTOTRADE_TIMEOUT * .5;
if ( now > tp->firstprocessed+timeout*10 )
{
//printf("purge swap aliceid.%llu\n",(long long)tp->aliceid);
portable_mutex_lock(&LP_tradesmutex);
HASH_DELETE(hh,LP_trades,tp);
portable_mutex_unlock(&LP_tradesmutex);
free(tp);
}
}
if ( nonz == 0 ) if ( nonz == 0 )
sleep(1); sleep(1);
} }

2
iguana/exchanges/LP_statemachine.c

@ -2491,7 +2491,7 @@ void basilisk_swaploop(void *_utxo)
{ {
uint8_t *data; uint32_t expiration,savestatebits=0,saveotherbits=0; uint32_t channel; int32_t iters,retval=0,j,datalen,maxlen; struct basilisk_swap *swap; struct LP_utxoinfo *utxo = _utxo; uint8_t *data; uint32_t expiration,savestatebits=0,saveotherbits=0; uint32_t channel; int32_t iters,retval=0,j,datalen,maxlen; struct basilisk_swap *swap; struct LP_utxoinfo *utxo = _utxo;
swap = utxo->swap; swap = utxo->swap;
fprintf(stderr,"start swap iambob.%d\n",swap->I.iambob); //fprintf(stderr,"start swap iambob.%d\n",swap->I.iambob);
maxlen = 1024*1024 + sizeof(*swap); maxlen = 1024*1024 + sizeof(*swap);
data = malloc(maxlen); data = malloc(maxlen);
expiration = (uint32_t)time(NULL) + 300; expiration = (uint32_t)time(NULL) + 300;

4
iguana/exchanges/LP_swap.c

@ -995,8 +995,8 @@ int32_t instantdex_pubkeyargs(struct basilisk_swap *swap,int32_t numpubs,bits256
} }
n++; n++;
} }
if ( n > 2 || m > 2 ) //if ( n > 2 || m > 2 )
printf("n.%d m.%d len.%d numpubs.%d\n",n,m,len,swap->I.numpubs); // printf("n.%d m.%d len.%d numpubs.%d\n",n,m,len,swap->I.numpubs);
return(n); return(n);
} }

Loading…
Cancel
Save