@@ -107,7 +107,6 @@ function get_requeststates(trigger, active_requests) {
107107 requeststates = statuscache . requeststates ;
108108 if ( cachetime > 30000 || empty_obj ( requeststates ) ) { //check if cached crypto rates are expired (check every 30 seconds on page refresh or when opening request page)
109109 active_requests . addClass ( "scan" ) ;
110- br_remove_session ( "txstatus" ) ; // remove cached transactions
111110 getinputs ( request_data , d_lay ) ;
112111 return
113112 }
@@ -138,19 +137,30 @@ function get_requeststates(trigger, active_requests) {
138137 return
139138 }
140139 if ( ! empty_obj ( glob_let . statuspush ) ) {
140+ const tx_states = br_get_session ( "txstatus" , true ) ;
141+ if ( tx_states ) {
142+ const txs = tx_states . requeststates ,
143+ txid = sha_sub ( JSON . stringify ( txs ) , 15 ) , // hash arrays to compare for changes
144+ new_tx_id = sha_sub ( JSON . stringify ( glob_let . statuspush ) , 15 ) ;
145+ if ( txid !== new_tx_id ) { // check for updates
146+ // Only save on status updates
147+ saverequests ( ) ;
148+ }
149+ } else {
150+ saverequests ( ) ;
151+ }
141152 const statusobject = {
142153 "timestamp" : now ( ) ,
143154 "requeststates" : glob_let . statuspush
144155 } ;
145156 br_set_session ( "txstatus" , statusobject , true ) ;
146- saverequests ( ) ;
147157 clearscan ( ) ;
148158 }
149159}
150160
151161// Retrieves input data for requests
152162function getinputs ( rd , dl ) {
153- const rdo = tx_data ( rd ) ; // fetchblocks.js
163+ const rdo = tx_data ( rd ) ;
154164 if ( rdo . pending === "scanning" || rdo . pending === "polling" ) {
155165 if ( dl ) {
156166 const delay = 10000 ,
@@ -174,7 +184,7 @@ function getinputs(rd, dl) {
174184 const transactionlist = rdo . transactionlist ;
175185 if ( transactionlist ) {
176186 transactionlist . find ( "li" ) . each ( function ( i ) {
177- glob_let . tx_list . push ( $ ( this ) . data ( "txhash" ) ) ;
187+ glob_let . tx_list . push ( $ ( this ) . data ( "txhash" ) ) ; //index transaction id's
178188 } ) ;
179189 api_callback ( rdo ) ;
180190 }
@@ -221,6 +231,11 @@ function continue_select(rd, api_data, rdo) {
221231
222232function continue_select_api ( rd , api_data , rdo ) {
223233 const api_name = api_data . name ;
234+ if ( rdo . source === "addr_polling" ) {
235+ glob_let . rpc_attempts = { }
236+ continue_select ( rd , api_data , rdo ) ;
237+ return
238+ }
224239 if ( api_name === "mymonero api" ) {
225240 monero_fetch_init ( rd , api_data , rdo ) ;
226241 return
@@ -265,11 +280,6 @@ function continue_select_api(rd, api_data, rdo) {
265280 insight_fetch_dash ( rd , api_data , rdo ) ;
266281 return
267282 }
268- if ( rdo . source === "addr_polling" ) {
269- glob_let . rpc_attempts = { }
270- continue_select ( rd , api_data , rdo ) ;
271- return
272- }
273283 api_callback ( rdo ) ;
274284}
275285
@@ -417,6 +427,7 @@ function handle_rpc_fails(rd, rdo, error_obj, api_data, l2) {
417427 error_data = get_api_error_data ( error_obj ) ,
418428 timeout = rdo . timeout ,
419429 cachetime = rdo . cachetime ;
430+
420431 function next_proxy ( type ) { // try next proxy
421432 if ( type === "api_fail" && ( error_data . apikey || glob_let . apikey_fails ) ) return false ; // only try next proxy if api key is expired or missing
422433 if ( get_next_proxy ( ) ) {
@@ -745,8 +756,9 @@ function data_title(dat) {
745756 lc_val = dat . ccval * lc_ccrate ,
746757 cc_upper = dat . ccsymbol ? dat . ccsymbol . toUpperCase ( ) : dat . ccsymbol ,
747758 lc_upper = lcsymbol ? lcsymbol . toUpperCase ( ) : lcsymbol ,
748- localrate = lc_upper === "USD" ? "" : cc_upper + "-" + lc_upper + ": " + lc_ccrate . toFixed ( 6 ) + "\n" + lc_upper + "-USD: " + lc_usd_rate . toFixed ( 2 ) ,
749- historic_dat = "Historic data (" + fulldateformat ( new Date ( timestamp - glob_const . timezone ) , langcode ) + "):\n" +
759+ localrate = lc_upper === "USD" ? "" : cc_upper + "-" + lc_upper + ": " + lc_ccrate . toFixed ( 6 ) + "\n" + lc_upper + "-USD: " + lc_usd_rate . toFixed ( 2 ) ;
760+ // set historic data
761+ historic_dat = "Historic data (" + fulldateformat ( new Date ( timestamp - glob_const . timezone ) , langcode ) + "):\n" +
750762 "Fiatvalue: " + lc_val . toFixed ( 2 ) + " " + lc_upper + "\n" +
751763 cc_upper + "-USD: " + price . toFixed ( 6 ) + "\n" +
752764 localrate + "\n" +
0 commit comments