@@ -904,14 +904,13 @@ function update_transaction_count(status_panel, count) {
904904
905905// Triggers historical fiat data retrieval for transactions based on confirmation status
906906function init_fiat_history ( rd , rdo , latestconf , latest_input , firstinput ) {
907- const cache_value = latest_input + latestconf . toString ( ) , // only update on change
907+ const cache_value = latest_input + latestconf , // only update on change
908908 cache_prefix = "historic_" + rd . requestid ,
909909 cache_timestamp = br_get_session ( cache_prefix ) , // set to small amount to trigger lookup exchange rates
910- cache_session = cache_timestamp || 1 ,
911- latest_input_slice = cache_timestamp ? cache_session . slice ( 0 , 13 ) : latest_input ,
912- latestinput = parseInt ( latest_input_slice ) ,
913- historic_cache = parseInt ( cache_session ) ;
910+ historic_cache = parseInt ( cache_timestamp ) || 1 ;
914911 if ( cache_value > historic_cache ) { //new input detected; call historic api
912+ const time_past = cache_value - historic_cache ,
913+ latestinput = ( time_past > 600000 ) ? latest_input : historic_cache ; // refresh cache only every 10 minutes
915914 br_remove_session ( cache_prefix ) ; // remove historic price cache
916915 const historic_payload = $ . extend ( rd , {
917916 latestinput,
@@ -1160,8 +1159,7 @@ function fetch_crypto_rates(rd, rdo, fiat_api, api_list, api, currency_rate, usd
11601159 "lightning" : rd . lightning
11611160 } , false ) ;
11621161 if ( pending !== "no" ) {
1163- const cache_value = latest_input + latest_confirm . toString ( ) ;
1164- br_set_session ( "historic_" + rd . requestid , cache_value ) ; // 'cache' historic data
1162+ br_set_session ( "historic_" + rd . requestid , latest_input + latest_confirm ) ; // 'cache' historic data
11651163 }
11661164 finalize_request_state ( rdo ) ;
11671165 return
@@ -1349,25 +1347,25 @@ function check_api(payment) {
13491347
13501348// Formats and normalizes request data for transaction processing
13511349function tx_data ( rd ) {
1352- const request_id = rd . requestid ,
1353- request_list = $ ( "#" + request_id ) ,
1350+ const requestid = rd . requestid ,
1351+ thislist = $ ( "#" + requestid ) ,
13541352 request_date = rd . inout === "incoming" ? rd . timestamp : rd . requestdate ,
13551353 request_timestamp = request_date - 30000 , // 30 seconds compensation for unexpected results
13561354 get_confirmations = rd . set_confirmations ,
1357- set_confirmations = get_confirmations ? parseInt ( get_confirmations ) : 1 ,
1358- is_canceled = rd . status === "canceled" ,
1359- pending_status = is_canceled ? "scanning" : rd . pending ,
1360- status_panel = request_list . find ( ".pmetastatus" ) ,
1361- transaction_list = request_list . find ( "ul.transactionlist" ) ;
1355+ setconfirmations = get_confirmations ? parseInt ( get_confirmations ) : 1 ,
1356+ canceled = rd . status === "canceled" ,
1357+ pending = canceled ? "scanning" : rd . pending ,
1358+ statuspanel = thislist . find ( ".pmetastatus" ) ,
1359+ transactionlist = thislist . find ( "ul.transactionlist" ) ;
13621360 return {
1363- " requestid" : request_id ,
1364- " thislist" : request_list ,
1365- "request_timestamp" : request_timestamp ,
1366- " setconfirmations" : set_confirmations ,
1367- " canceled" : is_canceled ,
1368- " pending" : pending_status ,
1369- " statuspanel" : status_panel ,
1370- " transactionlist" : transaction_list ,
1361+ requestid,
1362+ thislist,
1363+ request_timestamp,
1364+ setconfirmations,
1365+ canceled,
1366+ pending,
1367+ statuspanel,
1368+ transactionlist,
13711369 "source" : "requests" ,
13721370 "cachetime" : 25
13731371 }
0 commit comments