Browse Source

Test

patch-3
jl777 7 years ago
parent
commit
ffbdfc75a3
  1. 2
      iguana/exchanges/LP_include.h
  2. 17
      iguana/exchanges/LP_ordermatch.c
  3. 1
      iguana/exchanges/LP_swap.c

2
iguana/exchanges/LP_include.h

@ -390,7 +390,7 @@ struct basilisk_swap
struct LP_endpoint N; struct LP_endpoint N;
void (*balancingtrade)(struct basilisk_swap *swap,int32_t iambob); void (*balancingtrade)(struct basilisk_swap *swap,int32_t iambob);
int32_t subsock,pushsock,connected,aliceunconf,depositunconf,paymentunconf; int32_t subsock,pushsock,connected,aliceunconf,depositunconf,paymentunconf;
uint32_t lasttime,aborted,tradeid; uint32_t lasttime,aborted,tradeid,received;
FILE *fp; FILE *fp;
bits256 persistent_privkey,persistent_pubkey; bits256 persistent_privkey,persistent_pubkey;
struct basilisk_swapinfo I; struct basilisk_swapinfo I;

17
iguana/exchanges/LP_ordermatch.c

@ -451,7 +451,7 @@ struct LP_utxoinfo *LP_address_myutxopair(struct LP_utxoinfo *butxo,int32_t iamb
int32_t LP_connectstartbob(void *ctx,int32_t pubsock,char *base,char *rel,double price,struct LP_quoteinfo *qp) int32_t LP_connectstartbob(void *ctx,int32_t pubsock,char *base,char *rel,double price,struct LP_quoteinfo *qp)
{ {
char pairstr[512],otheraddr[64]; cJSON *reqjson; bits256 privkey; int32_t pair=-1,retval = -1,DEXselector = 0; int64_t dtrust; struct basilisk_swap *swap; struct iguana_info *coin,*kmdcoin; char pairstr[512],otheraddr[64]; cJSON *reqjson; bits256 privkey; int32_t i,pair=-1,retval = -1,DEXselector = 0; int64_t dtrust; struct basilisk_swap *swap; struct iguana_info *coin,*kmdcoin;
qp->quotetime = (uint32_t)time(NULL); qp->quotetime = (uint32_t)time(NULL);
if ( (coin= LP_coinfind(qp->srccoin)) == 0 ) if ( (coin= LP_coinfind(qp->srccoin)) == 0 )
{ {
@ -486,12 +486,17 @@ int32_t LP_connectstartbob(void *ctx,int32_t pubsock,char *base,char *rel,double
//char str[65]; printf("BOB pubsock.%d binds to %d (%s)\n",pubsock,pair,bits256_str(str,qp->desthash)); //char str[65]; printf("BOB pubsock.%d binds to %d (%s)\n",pubsock,pair,bits256_str(str,qp->desthash));
bits256 zero; bits256 zero;
memset(zero.bytes,0,sizeof(zero)); memset(zero.bytes,0,sizeof(zero));
LP_reserved_msg(1,qp->srccoin,qp->destcoin,qp->desthash,jprint(reqjson,0)); for (i=0; i<10; i++)
LP_reserved_msg(1,qp->srccoin,qp->destcoin,zero,jprint(reqjson,0));
if ( 0 )
{ {
LP_reserved_msg(1,base,rel,zero,jprint(reqjson,0)); LP_reserved_msg(1,qp->srccoin,qp->destcoin,qp->desthash,jprint(reqjson,0));
LP_reserved_msg(0,base,rel,zero,jprint(reqjson,0)); sleep(3);
if ( swap->received != 0 )
{
printf("swap %u-%u has started t%u\n",swap->I.req.requestid,swap->I.req.quoteid,swap->received);
break;
}
printf("bob tries %u-%u again i.%d\n",swap->I.req.requestid,swap->I.req.quoteid,i);
LP_reserved_msg(1,qp->srccoin,qp->destcoin,zero,jprint(reqjson,0));
} }
free_json(reqjson); free_json(reqjson);
LP_importaddress(qp->destcoin,qp->destaddr); LP_importaddress(qp->destcoin,qp->destaddr);

1
iguana/exchanges/LP_swap.c

@ -473,6 +473,7 @@ int32_t LP_waitfor(int32_t pairsock,struct basilisk_swap *swap,int32_t timeout,i
{ {
//printf("wait for got.%d\n",datalen); //printf("wait for got.%d\n",datalen);
retval = (*verify)(swap,data,datalen); retval = (*verify)(swap,data,datalen);
swap->received = (uint32_t)time(NULL);
nn_freemsg(data); nn_freemsg(data);
//printf("retval.%d\n",retval); //printf("retval.%d\n",retval);
return(retval); return(retval);

Loading…
Cancel
Save