Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
616a009b8e
  1. 2
      iguana/iguana_exchanges.c
  2. 36
      iguana/iguana_instantdex.c

2
iguana/iguana_exchanges.c

@ -585,7 +585,7 @@ char *exchanges777_process(struct exchange_info *exchange,int32_t *retvalp,struc
void iguana_statemachineupdate(struct supernet_info *myinfo,struct exchange_info *exchange)
{
int32_t timemod,modwidth = 1; struct iguana_info *coin; struct bitcoin_swapinfo *swap,*tmp; struct iguana_bundlereq *req;
int32_t timemod,modwidth = 3; struct iguana_info *coin; struct bitcoin_swapinfo *swap,*tmp; struct iguana_bundlereq *req;
timemod = time(NULL) % modwidth;
coin = iguana_coinfind("BTCD");
portable_mutex_lock(&exchange->mutexS);

36
iguana/iguana_instantdex.c

@ -1181,6 +1181,21 @@ struct bitcoin_swapinfo *bitcoin_swapinit(struct supernet_info *myinfo,struct ex
return(swap);
}
struct bitcoin_eventitem *instantdex_event(char *cmdstr,cJSON *argjson,cJSON *newjson,uint8_t *serdata,int32_t serdatalen)
{
struct bitcoin_eventitem *ptr;
ptr = calloc(1,sizeof(*ptr) + serdatalen);
strcpy(ptr->cmd,cmdstr);
ptr->newjson = jduplicate(newjson);
ptr->argjson = jduplicate(argjson);
if ( serdatalen != 0 )
{
memcpy(ptr->serdata,serdata,serdatalen);
ptr->serdatalen = serdatalen;
}
return(ptr);
}
char *instantdex_checkoffer(struct supernet_info *myinfo,int32_t *addedp,uint64_t *txidp,struct exchange_info *exchange,struct instantdex_accept *ap,cJSON *argjson)
{
struct instantdex_accept *otherap,*tmp; struct bitcoin_swapinfo *swap; cJSON *newjson; int32_t isbob = 0; char *retstr = 0;
@ -1236,6 +1251,9 @@ char *instantdex_checkoffer(struct supernet_info *myinfo,int32_t *addedp,uint64_
*addedp = 1;
if ( (newjson= instantdex_parseargjson(myinfo,exchange,swap,argjson,1)) == 0 )
return(clonestr("{\"error\":\"instantdex_checkoffer null newjson\"}"));
if ( swap->pollevent != 0 )
instantdex_eventfree(swap->pollevent);
swap->pollevent = instantdex_event("poll",argjson,newjson,(void *)swap->deck,sizeof(swap->deck));
retstr = instantdex_sendcmd(myinfo,&swap->mine.offer,newjson,"BTCoffer",GENESIS_PUBKEY,INSTANTDEX_HOPS,swap->deck,sizeof(swap->deck),0);
free_json(newjson);
} else printf("error creating statemachine\n");
@ -1289,6 +1307,9 @@ char *instantdex_gotoffer(struct supernet_info *myinfo,struct exchange_info *exc
}
else
{
if ( swap->pollevent != 0 )
instantdex_eventfree(swap->pollevent);
swap->pollevent = instantdex_event("poll",argjson,newjson,(void *)swap->deck,sizeof(swap->deck));
retstr = instantdex_sendcmd(myinfo,&swap->mine.offer,newjson,"BTCdeckC",traderpub,INSTANTDEX_HOPS,swap->deck,sizeof(swap->deck),0);
free_json(newjson);
}
@ -1296,21 +1317,6 @@ char *instantdex_gotoffer(struct supernet_info *myinfo,struct exchange_info *exc
return(retstr);
}
struct bitcoin_eventitem *instantdex_event(char *cmdstr,cJSON *argjson,cJSON *newjson,uint8_t *serdata,int32_t serdatalen)
{
struct bitcoin_eventitem *ptr;
ptr = calloc(1,sizeof(*ptr) + serdatalen);
strcpy(ptr->cmd,cmdstr);
ptr->newjson = jduplicate(newjson);
ptr->argjson = jduplicate(argjson);
if ( serdatalen != 0 )
{
memcpy(ptr->serdata,serdata,serdatalen);
ptr->serdatalen = serdatalen;
}
return(ptr);
}
char *instantdex_parse(struct supernet_info *myinfo,struct instantdex_msghdr *msg,cJSON *argjson,char *remoteaddr,uint64_t signerbits,struct instantdex_offer *offer,bits256 orderhash,uint8_t *serdata,int32_t serdatalen)
{
char cmdstr[16],*retstr; struct exchange_info *exchange=0; struct instantdex_accept A,*ap = 0; bits256 traderpub; cJSON *newjson; struct bitcoin_swapinfo *swap; struct bitcoin_eventitem *ptr;

Loading…
Cancel
Save