Skip to content

Commit b2f4e12

Browse files
committed
proxy management
1 parent f46caf4 commit b2f4e12

File tree

4 files changed

+38
-22
lines changed

4 files changed

+38
-22
lines changed

assets_js_bitrequest_fetchblocks.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1695,14 +1695,15 @@ function mempoolspace_rpc_blockheight(rd, api_data, rdo, rpc) {
16951695
"params": {
16961696
"method": "GET"
16971697
}
1698-
}).done(function(lb) {
1699-
const lbdat = br_result(lb);
1700-
if (lbdat) {
1701-
const latestblock = lbdat.result;
1702-
if (latestblock) {
1703-
mempoolspace_rpc(rd, api_data, rdo, rpc, latestblock);
1698+
}).done(function(e) {
1699+
const data = br_result(e).result;
1700+
if (data) {
1701+
if (data.error) {
1702+
tx_api_scan_fail(rd, api_data, rdo, data.error);
17041703
return
17051704
}
1705+
mempoolspace_rpc(rd, api_data, rdo, rpc, data);
1706+
return
17061707
}
17071708
tx_api_scan_fail(rd, api_data, rdo, default_error);
17081709
}).fail(function(xhr, stat, err) {

assets_js_bitrequest_monitors.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ $(document).ready(function() {
2222
//tx_api_scan_fail
2323
//tx_api_fail
2424
//handle_api_fails
25+
//no_results
2526
//get_next_api
2627
//api_eror_msg
2728
//get_api_error_data
@@ -461,7 +462,11 @@ function handle_api_fails(rd, rdo, error, api_data, is_proxy, l2) {
461462
}
462463
return false
463464
}
464-
if (is_proxy && next_proxy()) { // Try next proxy if proxy fails
465+
if (is_proxy) { // Try next proxy if proxy fails
466+
if (next_proxy()) {
467+
return
468+
}
469+
no_results(rdo, src, api_data, error_data);
465470
return
466471
}
467472
if (!api_data) {
@@ -525,6 +530,11 @@ function handle_api_fails(rd, rdo, error, api_data, is_proxy, l2) {
525530
if (next_proxy()) { // Try next proxy after trying all api's
526531
return
527532
}
533+
no_results(rdo, src, api_data, error_data);
534+
}
535+
536+
// Show error message if all proxies / apis fail.
537+
function no_results(rdo, src, api_data, error_data) {
528538
const rpc_id = api_data.name || api_data.url || "unknown";
529539
api_eror_msg(rpc_id, error_data);
530540
if (src === "addr_polling" || src === "tx_polling") {
@@ -756,7 +766,11 @@ function handle_rpc_fails(rd, rdo, error, api_data, is_proxy, l2) {
756766
}
757767
return false
758768
}
759-
if (is_proxy && next_proxy()) { // Try next proxy if proxy fails
769+
if (is_proxy) { // Try next proxy if proxy fails
770+
if (next_proxy()) {
771+
return
772+
}
773+
no_results(rdo, src, api_data, error_data);
760774
return
761775
}
762776
if (!api_data) {
@@ -820,14 +834,7 @@ function handle_rpc_fails(rd, rdo, error, api_data, is_proxy, l2) {
820834
if (next_proxy()) { // Try next proxy after trying all rpc's
821835
return
822836
}
823-
const rpc_id = api_data.name || api_data.url || "unknown";
824-
api_eror_msg(rpc_id, error_data);
825-
if (src === "addr_polling") {
826-
clearpinging();
827-
socket_info(api_data, false);
828-
notify(translate("websocketoffline"), 500000, "yes");
829-
}
830-
api_callback(rdo);
837+
no_results(rdo, src, api_data, error_data);
831838
}
832839

833840
// Retrieves the next available RPC for a given payment method

assets_js_bitrequest_payments.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ $(document).ready(function() {
5353
//cc_fail
5454
//initexchangerate
5555
//get_fiat_exchangerate
56+
//next_fiat_api
57+
//no_xrate_result
5658
//rendercurrencypool
5759
//getpayment
5860
//show_paymentdialog
@@ -1117,10 +1119,7 @@ function cc_fail(apilist, api, error_val, is_proxy) {
11171119
if (next_proxy()) { // Try next proxy after trying all api's
11181120
return
11191121
}
1120-
loadertext(translate("apierror"));
1121-
closeloader();
1122-
cancelpaymentdialog();
1123-
fail_dialogs(api, error_val);
1122+
no_xrate_result(api, error_val);
11241123
}
11251124

11261125
// Initializes the exchange rate process
@@ -1289,10 +1288,15 @@ function next_fiat_api(apilist, fiatapi, error_object, ccrate, currencystring, c
12891288
if (next_proxy()) { // Try next proxy after trying all api's
12901289
return
12911290
}
1292-
loadertext(translate("error"));
1291+
no_xrate_result(fiatapi, error_object);
1292+
}
1293+
1294+
// Show error message if all proxies / apis fail.
1295+
function no_xrate_result(api, error_val) {
1296+
loadertext(translate("apierror"));
12931297
closeloader();
12941298
cancelpaymentdialog();
1295-
fail_dialogs(fiatapi, error_object);
1299+
fail_dialogs(api, error_val);
12961300
}
12971301

12981302
// Renders the currency pool with exchange rates and payment details

assets_js_bitrequest_polling.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ function ping_xmr_node(cachetime, address, vk, request_ts, txhash) {
236236
}
237237
});
238238
}).fail(function() {
239+
if (get_next_proxy()) {
240+
ping_xmr_node(cachetime, address, vk, request_ts, txhash);
241+
return
242+
}
239243
clearpinging(address);
240244
notify(translate("websocketoffline"), 500000, "yes");
241245
});

0 commit comments

Comments
 (0)