From 444f1cd5003b8c10c594e97f144ca05ab81f579d Mon Sep 17 00:00:00 2001 From: Artem Pikulin Date: Tue, 1 Jan 2019 14:16:01 +0700 Subject: [PATCH] Cache electrum tx history only when it's enabled explicitly in argjson. This feature is used by AtomicDEX GUI only so I disable it by default. --- iguana/exchanges/LP_commands.c | 1 + iguana/exchanges/LP_include.h | 4 ++-- iguana/exchanges/LP_socket.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 2369ef698..d9e58cff7 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -717,6 +717,7 @@ version\n\ if ( (ptr= LP_coinsearch(coin)) != 0 ) { ptr->inactive = 0; + ptr->cache_history = juint(argjson, "cache_history"); return(jprint(LP_electrumserver(ptr,jstr(argjson,"ipaddr"),juint(argjson,"port")),1)); } else return(clonestr("{\"error\":\"cant find coind\"}")); } diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 66da591ce..1a30675ec 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -337,8 +337,9 @@ struct iguana_info uint64_t txfee,do_autofill_merge; int32_t numutxos,notarized,longestchain,firstrefht,firstscanht,lastscanht,height; uint16_t busport,did_addrutxo_reset; uint32_t txversion,dPoWtime,lastautosplit,lastresetutxo,loadedcache,electrumlist,lastunspent,importedprivkey,lastpushtime,lastutxosync,addr_listunspent_requested,lastutxos,updaterate,counter,inactive,lastmempool,lastgetinfo,ratetime,heighttime,lastmonitor,obooktime; - uint8_t pubtype,p2shtype,isPoS,wiftype,wiftaddr,taddr,noimportprivkey_flag,userconfirms,isassetchain,maxconfirms; + uint8_t pubtype,p2shtype,isPoS,wiftype,wiftaddr,taddr,noimportprivkey_flag,userconfirms,isassetchain,maxconfirms,cache_history; char symbol[128],smartaddr[64],userpass[1024],serverport[128],instantdex_address[64],estimatefeestr[32],getinfostr[32],etomic[64],validateaddress[64]; + struct LP_tx_history_item *tx_history; // portfolio double price_kmd,force,perc,goal,goalperc,relvolume,rate; void *electrum; void *ctx; @@ -348,7 +349,6 @@ struct iguana_info void *curl_handle; portable_mutex_t curl_mutex; bits256 cachedtxid,notarizationtxid; uint8_t *cachedtxiddata; int32_t cachedtxidlen; bits256 cachedmerkle,notarizedhash; int32_t cachedmerkleheight; - struct LP_tx_history_item *tx_history; }; struct _LP_utxoinfo { bits256 txid; uint64_t value; int32_t height; uint32_t vout:30,suppress:1,pad:1; }; diff --git a/iguana/exchanges/LP_socket.c b/iguana/exchanges/LP_socket.c index e7ddb802b..03917354c 100644 --- a/iguana/exchanges/LP_socket.c +++ b/iguana/exchanges/LP_socket.c @@ -1502,7 +1502,7 @@ cJSON *LP_electrumserver(struct iguana_info *coin,char *ipaddr,uint16_t port) cJSON_Delete(balance); } #endif - if (coin->electrum != 0 && cur == 0) { + if (coin->cache_history > 0 && coin->electrum != 0 && cur == 0) { if ( OS_thread_create(malloc(sizeof(pthread_t)),NULL,(void *)LP_electrum_txhistory_loop,(void *)coin) != 0 ) { printf("error launching LP_electrum_tx_history_loop %s.(%s:%u)\n",coin->symbol,ep->ipaddr,ep->port);