From 193dd3527c55f55144451c72566f770e5b107a6b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Dec 2017 16:35:50 +0400 Subject: [PATCH] Test --- iguana/exchanges/LP_rpc.c | 6 +++++- iguana/exchanges/LP_stats.c | 24 ++++++++++++++++++------ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/iguana/exchanges/LP_rpc.c b/iguana/exchanges/LP_rpc.c index 5c60ea47e..e3b8e5d07 100644 --- a/iguana/exchanges/LP_rpc.c +++ b/iguana/exchanges/LP_rpc.c @@ -102,7 +102,11 @@ int32_t LP_getheight(int32_t *notarizedp,struct iguana_info *coin) { retjson = cJSON_Parse(retstr); coin->height = height = jint(retjson,"blocks"); - *notarizedp = jint(retjson,"notarized"); + if ( (*notarizedp= jint(retjson,"notarized")) != 0 && *notarizedp != coin->notarized ) + { + printf("new notarized %s %d -> %d\n",coin->symbol,coin->notarized,*notarizedp); + coin->notarized = *notarizedp; + } free_json(retjson); if ( coin->height > 0 ) coin->heighttime = (uint32_t)time(NULL); diff --git a/iguana/exchanges/LP_stats.c b/iguana/exchanges/LP_stats.c index 49fbdc8cc..c0bf11515 100644 --- a/iguana/exchanges/LP_stats.c +++ b/iguana/exchanges/LP_stats.c @@ -210,10 +210,19 @@ int32_t LP_swapstats_update(struct LP_swapstats *sp,struct LP_quoteinfo *qp,cJSO int32_t LP_dPoWheight(struct iguana_info *coin) // get dPoW protected height { - int32_t notarized; - LP_getheight(¬arized,coin); - printf("dPoWheight.%s %d\n",coin->symbol,notarized); - return(notarized); + int32_t notarized,oldnotarized; + if ( coin->electrum == 0 ) + { + coin->heighttime = (uint32_t)(time(NULL) - 61); + oldnotarized = coin->notarized; + LP_getheight(¬arized,coin); + if ( notarized != 0 && notarized != oldnotarized ) + { + printf("dPoWheight.%s %d <- %d\n",coin->symbol,oldnotarized,notarized); + coin->notarized = notarized; + } + } + return(coin->notarized); } int32_t LP_finished_lastheight(struct LP_swapstats *sp,int32_t iambob) @@ -248,6 +257,8 @@ int32_t LP_swap_finished(struct LP_swapstats *sp,int32_t dPoWflag) struct iguana_info *bob,*alice; bob = LP_coinfind(sp->Q.srccoin); alice = LP_coinfind(sp->Q.destcoin); + sp->bob_dPoWheight = LP_dPoWheight(bob); + sp->alice_dPoWheight = LP_dPoWheight(alice); if ( sp->finished == 0 ) { if ( sp->expired != 0 ) @@ -258,8 +269,6 @@ int32_t LP_swap_finished(struct LP_swapstats *sp,int32_t dPoWflag) return(1); else if ( sp->finished != 0 ) { - sp->bob_dPoWheight = LP_dPoWheight(bob); - sp->alice_dPoWheight = LP_dPoWheight(alice); if ( bob->isassetchain != 0 ) sp->bobneeds_dPoW = LP_finished_lastheight(sp,1); if ( alice->isassetchain != 0 ) @@ -267,7 +276,10 @@ int32_t LP_swap_finished(struct LP_swapstats *sp,int32_t dPoWflag) printf("bob needs %d @ %d, alice needs %d @ %d\n",sp->bobneeds_dPoW,sp->bob_dPoWheight,sp->aliceneeds_dPoW,sp->alice_dPoWheight); } if ( (sp->bobneeds_dPoW == 0 || (sp->bobneeds_dPoW > 1 && sp->bob_dPoWheight >= sp->bobneeds_dPoW)) && (sp->aliceneeds_dPoW == 0 || (sp->aliceneeds_dPoW > 1 && sp->alice_dPoWheight >= sp->aliceneeds_dPoW)) ) + { + sp->dPoWfinished = (uint32_t)time(NULL); return(1); + } } } return(0);