From fcd8c6f887a5b87d5f460605ff8d79e936602037 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 22 May 2016 00:51:23 -0500 Subject: [PATCH] test --- iguana/swaps/iguana_BTCswap.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/iguana/swaps/iguana_BTCswap.c b/iguana/swaps/iguana_BTCswap.c index ab459553a..346c83b4c 100755 --- a/iguana/swaps/iguana_BTCswap.c +++ b/iguana/swaps/iguana_BTCswap.c @@ -1018,7 +1018,7 @@ void instantdex_eventfree(struct bitcoin_eventitem *ptr) char *instantdex_statemachine(struct instantdex_stateinfo *states,int32_t numstates,struct supernet_info *myinfo,struct exchange_info *exchange,struct bitcoin_swapinfo *swap,char *cmdstr,cJSON *argjson,cJSON *newjson,uint8_t *serdata,int32_t serdatalen) { - uint32_t i; struct iguana_info *altcoin=0,*coinbtc=0; struct instantdex_stateinfo *state=0; char *retstr; + uint32_t i; struct iguana_info *altcoin=0,*coinbtc=0; struct instantdex_stateinfo *state=0; if ( swap == 0 || (state= swap->state) == 0 || (coinbtc= iguana_coinfind("BTC")) == 0 || (altcoin= iguana_coinfind(swap->mine.offer.base)) == 0 ) { printf("state.%s btc.%p altcoin.%p (%s)\n",state->name,coinbtc,altcoin,swap->mine.offer.base); @@ -1052,17 +1052,18 @@ char *instantdex_statemachine(struct instantdex_stateinfo *states,int32_t numsta } else { + if ( strcmp(cmdstr,"poll") != 0 ) + { + if ( swap->pollevent != 0 ) + instantdex_eventfree(swap->pollevent); + swap->pollevent = instantdex_event("poll",argjson,newjson,serdata,serdatalen); + } if ( state->events[i].sendcmd[0] != 0 ) { if ( state->events[i].nextstateind > 1 ) { swap->state = &states[state->events[i].nextstateind]; - if ( swap->pollevent != 0 ) - instantdex_eventfree(swap->pollevent); - swap->pollevent = instantdex_event("poll",argjson,newjson,serdata,serdatalen); - retstr = instantdex_sendcmd(myinfo,&swap->mine.offer,newjson,state->events[i].sendcmd,swap->othertrader,INSTANTDEX_HOPS,serdata,serdatalen,0); - free_json(newjson); - return(retstr); + return(instantdex_sendcmd(myinfo,&swap->mine.offer,newjson,state->events[i].sendcmd,swap->othertrader,INSTANTDEX_HOPS,serdata,serdatalen,0)); } else return(clonestr("{\"error\":\"instantdex_statemachine: illegal state\"}")); } else return(clonestr("{\"result\":\"instantdex_statemachine: processed\"}")); }