From cf8d48a1da60270c709761ac16125824d9a4fe29 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 14 May 2016 13:31:29 -0500 Subject: [PATCH] test --- iguana/iguana_instantdex.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/iguana/iguana_instantdex.c b/iguana/iguana_instantdex.c index 4024de768..be76671d4 100755 --- a/iguana/iguana_instantdex.c +++ b/iguana/iguana_instantdex.c @@ -1230,8 +1230,8 @@ char *instantdex_gotoffer(struct supernet_info *myinfo,struct exchange_info *exc } else //if ( (retstr= instantdex_addfeetx(myinfo,newjson,ap,swap,"BOB_gotoffer","ALICE_gotoffer")) == 0 ) { - printf("add to both queues\n"); - queue_enqueue("acceptableQ",&exchange->acceptableQ,&swap->DL,0); + printf("create statemachine\n"); + //queue_enqueue("acceptableQ",&exchange->acceptableQ,&swap->DL,0); queue_enqueue("statemachineQ",&exchange->statemachineQ,&swap->DL,0); if ( (retstr= instantdex_choosei(swap,newjson,argjson,serdata,serdatalen)) != 0 ) return(retstr); @@ -1266,7 +1266,18 @@ char *instantdex_parse(struct supernet_info *myinfo,struct instantdex_msghdr *ms A.offer.minperc = INSTANTDEX_MINPERC; else if ( A.offer.minperc > 100 ) A.offer.minperc = 100; - if ( strcmp(cmdstr,"BTCoffer") == 0 ) // incoming + if ( (swap= instantdex_statemachinefind(myinfo,exchange,A.orderid,1)) != 0 ) + { + printf("found existing state machine %llu\n",(long long)A.orderid); + newjson = instantdex_parseargjson(myinfo,exchange,swap,argjson,0); + if ( serdatalen == sizeof(swap->otherdeck) && swap->choosei < 0 && (retstr= instantdex_choosei(swap,newjson,argjson,serdata,serdatalen)) != 0 ) + { + printf("error choosei\n"); + return(retstr); + } + return(instantdex_statemachine(BTC_states,BTC_numstates,myinfo,exchange,swap,cmdstr,argjson,newjson,serdata,serdatalen)); + } + else if ( strcmp(cmdstr,"BTCoffer") == 0 ) // incoming { printf("BTCoffer state exchange.%p serdatalen.%d\n",exchange,serdatalen); if ( (ap= instantdex_acceptable(myinfo,exchange,&A,A.offer.minperc)) != 0 ) @@ -1290,17 +1301,6 @@ char *instantdex_parse(struct supernet_info *myinfo,struct instantdex_msghdr *ms } else return(clonestr("{\"result\":\"order was already in orderbook\"}")); } } - else if ( (swap= instantdex_statemachinefind(myinfo,exchange,A.orderid,1)) != 0 ) - { - printf("found existing state machine %llu\n",(long long)A.orderid); - newjson = instantdex_parseargjson(myinfo,exchange,swap,argjson,0); - if ( serdatalen == sizeof(swap->otherdeck) && swap->choosei < 0 && (retstr= instantdex_choosei(swap,newjson,argjson,serdata,serdatalen)) != 0 ) - { - printf("error choosei\n"); - return(retstr); - } - return(instantdex_statemachine(BTC_states,BTC_numstates,myinfo,exchange,swap,cmdstr,argjson,newjson,serdata,serdatalen)); - } else { printf("cant find existing order.%llu that matches\n",(long long)A.orderid);