From 934a2b0461a837436ee090b404e9e1169a2b9b3e Mon Sep 17 00:00:00 2001 From: pbca26 Date: Thu, 9 Mar 2017 10:28:43 +0300 Subject: [PATCH] flush cache if local data is corrupted --- assets/scripts/dashboard.js | 1 - assets/scripts/iguana_api/IguanaEDEX.js | 16 ++++++++-------- assets/scripts/iguana_api/IguanaShepherd.js | 8 +++++++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/assets/scripts/dashboard.js b/assets/scripts/dashboard.js index 14b01a8..7bab021 100644 --- a/assets/scripts/dashboard.js +++ b/assets/scripts/dashboard.js @@ -916,7 +916,6 @@ jQuery(document).ready(function() { Dashboard.init(); }); - function resizeDashboardWindow() { /* set default map height */ var navbarH = $('.site-navbar').outerHeight(), diff --git a/assets/scripts/iguana_api/IguanaEDEX.js b/assets/scripts/iguana_api/IguanaEDEX.js index d6ec2fa..ebc925e 100644 --- a/assets/scripts/iguana_api/IguanaEDEX.js +++ b/assets/scripts/iguana_api/IguanaEDEX.js @@ -285,10 +285,10 @@ function EDEXSendutxoRawTx(data) { return new Promise(function(resolve, reject) { //console.log(gettxdata) //console.log(utxos_set) - EDEX_GetTxIDList(gettxdata).then(function(get_txid_list){ - console.log(get_txid_list) - resolve(get_txid_list); - }) + EDEX_GetTxIDList(gettxdata).then(function(get_txid_list) { + console.log(get_txid_list) + resolve(get_txid_list); + }); /*EDEX_ProcessRefreshData(gettxdata,utxos_set).then(function(new_utxos_set) { console.log(new_utxos_set); resolve(new_utxos_set); @@ -298,7 +298,7 @@ function EDEXSendutxoRawTx(data) { var get_data_cache_contents = function(get_txid_list) { return new Promise(function(resolve, reject) { - console.log(get_txid_list) + console.log(get_txid_list); //console.log(send_data) //console.log(send_data.sendfrom) Shepherd_GroomData_Get().then(function(result) { @@ -310,8 +310,8 @@ function EDEXSendutxoRawTx(data) { console.log(result.basilisk.KMD[send_data.sendfrom].refresh); var save_this_data = result;*/ var save_this_data = EDEX_RemoveTXID(result, get_txid_list); - console.log(save_this_data) - //resolve(result); + console.log(save_this_data); + //resolve(result); resolve(save_this_data); }); }); @@ -659,7 +659,7 @@ function EDEXgetaddrbyaccount_cache(coin) { .then(result => { //console.log(result); resolve(result); - }) + }); }); }); } diff --git a/assets/scripts/iguana_api/IguanaShepherd.js b/assets/scripts/iguana_api/IguanaShepherd.js index b8e9331..5bd569b 100644 --- a/assets/scripts/iguana_api/IguanaShepherd.js +++ b/assets/scripts/iguana_api/IguanaShepherd.js @@ -221,7 +221,13 @@ function Shepherd_GetBasiliskCache() { url: 'http://127.0.0.1:17777/shepherd/cache', contentType: 'application/json' // send as JSON }).done(function(data) { - resolve(data); + resolve(data); + data = JSON.parse(data); + if (data.result === 'JSON parse error') { + Shepherd_GroomData_Delete().then(function(result) { + console.log('error reading cache, flushing...'); + }); + } }); }); }