From fff619435a172bee02015b64c1fb471b90a89b11 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 9 Dec 2017 21:30:54 +0400 Subject: [PATCH] Test --- iguana/exchanges/LP_instantdex.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/iguana/exchanges/LP_instantdex.c b/iguana/exchanges/LP_instantdex.c index 32694fd0f..4d8002491 100644 --- a/iguana/exchanges/LP_instantdex.c +++ b/iguana/exchanges/LP_instantdex.c @@ -113,15 +113,13 @@ void LP_instantdex_filescreate(char *coinaddr) void LP_instantdex_depositadd(char *coinaddr,bits256 txid) { - static FILE *depositsfp; - struct iguana_info *coin; char fname[512],*addr; bits256 prevtxid; cJSON *array; int32_t i,n,iter; + FILE *fp; struct iguana_info *coin; char fname[512],*addr; bits256 prevtxid; cJSON *array; int32_t i,n,iter; coin = LP_coinfind("KMD"); - if ( depositsfp == 0 ) + sprintf(fname,"%s/deposits.%s",GLOBAL_DBDIR,coinaddr), OS_compatible_path(fname); + if ( (fp= fopen(fname,"rb+")) == 0 ) { - sprintf(fname,"%s/deposits.%s",GLOBAL_DBDIR,coinaddr), OS_compatible_path(fname); - if ( (depositsfp= fopen(fname,"rb+")) == 0 ) + if ( (fp= fopen(fname,"wb+")) != 0 ) { - depositsfp = fopen(fname,"wb+"); for (iter=0; iter<4; iter++) { if ( iter < 2 ) @@ -134,23 +132,23 @@ void LP_instantdex_depositadd(char *coinaddr,bits256 txid) for (i=0; i 0 ) { - LP_instantdex_deposituniq(depositsfp,prevtxid); - fflush(depositsfp); + LP_instantdex_deposituniq(fp,prevtxid); + fflush(fp); } } } free_json(array); } } - } else fseek(depositsfp,0,SEEK_END); - } - if ( depositsfp != 0 && bits256_nonz(txid) != 0 ) + } + } else fseek(fp,0,SEEK_END); + if ( fp != 0 && bits256_nonz(txid) != 0 ) { - LP_instantdex_deposituniq(depositsfp,txid); - fflush(depositsfp); + LP_instantdex_deposituniq(fp,txid); + fclose(fp); } LP_instantdex_filescreate(coinaddr); }