diff --git a/supernode/index.html b/supernode/index.html
index 68d574e..e0a59be 100644
--- a/supernode/index.html
+++ b/supernode/index.html
@@ -13225,10 +13225,9 @@ Event information log
reactor.registerEvent("shift_ws_connection");
reactor.registerEvent("switchToBackupWSForSuperNodesOperations");
reactor.registerEvent("user_flo_keys_active");
+ reactor.registerEvent("backup_supernode_down");
reactor.registerEvent("remove_extra_backup_connections");
- reactor.registerEvent(
- "request_to_modify_user_balance_on_successfull_fiat_deposit"
- );
+
reactor.addEventListener("fireNodeWelcomeBackEvent", function(evt) {
let getFLOId = bitjs.FLO_TEST.pubkey2address(evt.flo_public_key);
@@ -13738,21 +13737,23 @@ Event information log
localbitcoinplusplus.backupWS[getFLOId].ws_connection
.readyState >= 2
) {
- localbitcoinplusplus.backupWS[getFLOId] = null;
- localbitcoinplusplus.backupWS[
- getFLOId
- ] = new backupSupernodesWebSocketObject(back_ws_url);
- localbitcoinplusplus.backupWS[getFLOId].connectWS();
- /* Now in connectWS if connection fails call switchToBackupWSForSuperNodesOperations() in onClose()
+ if (getFLOId !== localbitcoinplusplus.wallets.my_local_flo_address) {
+ localbitcoinplusplus.backupWS[getFLOId] = null;
+ localbitcoinplusplus.backupWS[
+ getFLOId
+ ] = new backupSupernodesWebSocketObject(back_ws_url);
+ localbitcoinplusplus.backupWS[getFLOId].connectWS();
+ /* Now in connectWS if connection fails call switchToBackupWSForSuperNodesOperations() in onClose()
for next su node, if its success check for max baxkup connection conditon, if required
- execute 'resolve_backup_ws_connections' in onOpen() or exit */
+ execute 'resolve_backup_ws_connections' in onOpen() or exit */
+ }
}
} catch (error) {
console.error(error);
- reactor.dispatchEvent(
- "switchToBackupWSForSuperNodesOperations",
- back_ws_url
- );
+ // reactor.dispatchEvent(
+ // "switchToBackupWSForSuperNodesOperations",
+ // back_ws_url
+ // );
}
}
});
@@ -13809,15 +13810,15 @@ Event information log
continue;
// Get the highest index of connected supernodes
- const highestIndexOfConnectedSupernode = Object.keys(
- localbitcoinplusplus.backupWS
- ).reduce((acc, val) =>
- acc === undefined ||
- myClosestSupsFloList.indexOf(val) >
- myClosestSupsFloList.indexOf(acc)
- ? myClosestSupsFloList.indexOf(val)
- : myClosestSupsFloList.indexOf(acc)
- );
+ let highestIndexOfConnectedSupernode = -1;
+
+ for(let i=0; i<=currenctBackupWsList.length; i++) {
+ if(myClosestSupsFloList.indexOf(currenctBackupWsList[i])
+ >highestIndexOfConnectedSupernode) {
+ highestIndexOfConnectedSupernode
+ = myClosestSupsFloList.indexOf(currenctBackupWsList[i]);
+ }
+ }
if (
myClosestSupsFloList.indexOf(supsObj.trader_flo_address) <
@@ -13882,9 +13883,11 @@ Event information log
);
if (
- typeof nextClosestSupernodeElem == "object" &&
- nextClosestSupernodeElem[0].trader_flo_address !==
- user_data.myLocalFLOAddress
+ typeof nextClosestSupernodeElem == "object"
+ && nextClosestSupernodeElem !== null
+ && nextClosestSupernodeElem !== undefined
+ && nextClosestSupernodeElem[0].trader_flo_address
+ !== user_data.myLocalFLOAddress
) {
reactor.dispatchEvent(
"shift_ws_connection",
@@ -13956,20 +13959,23 @@ Event information log
}
});
- /*This function is used to verify a tx denoting token transfer by trusted guy to the supernode
- and to increase balance of the respective user node.*/
-
- reactor.addEventListener(
- "request_to_modify_user_balance_on_successfull_fiat_deposit",
- function(token_transfer_resp) {
- /*
- token_transfer_resp = {
- tx: ec289d40069bb4db8b633133560269004a35f834c4a146560887ac87f7789d35,
- user_action: 'deposit'
- }
- */
- }
- );
+ /* This function runs when a backup ws is down */
+ reactor.addEventListener("backup_supernode_down", async function(evt) {
+ showMessage(
+ `Disconnected to backup Supernode sever: ${evt.srcElement.url}.`
+ );
+ const switchMyWS = new backupSupernodesWebSocketObject();
+ switchMyWS.updateSupernodeAvailabilityStatus(
+ evt.srcElement.url,
+ false
+ );
+ // Request next backup server to connect
+ await reactor.dispatchEvent(
+ "switchToBackupWSForSuperNodesOperations",
+ evt.srcElement.url
+ );
+ });
+
@@ -20295,21 +20301,7 @@ Event information log
reactor.dispatchEvent("backup_supernode_up");
}.bind(this);
this.ws_connection.onclose = function(evt) {
- reactor.addEventListener("backup_supernode_down", async function() {
- showMessage(
- `Disconnected to backup Supernode sever: ${evt.srcElement.url}.`
- );
- switchMyWS.updateSupernodeAvailabilityStatus(
- evt.srcElement.url,
- false
- );
- // Request next backup server to connect
- await reactor.dispatchEvent(
- "switchToBackupWSForSuperNodesOperations",
- evt.srcElement.url
- );
- });
- reactor.dispatchEvent("backup_supernode_down");
+ reactor.dispatchEvent("backup_supernode_down", evt);
}.bind(this);
this.ws_connection.onmessage = function(evt) {
let response = evt.data;