Merge pull request #12 from avishkarabhishek786/master_hotfix_polishing_for_production_updated

Master hotfix polishing for production updated. Fixed backing data of all left side Supernodes that are dead to serve their users when needed.
This commit is contained in:
Abhishek Sinha 2019-10-18 18:17:56 +05:30 committed by GitHub
commit ba1edc83f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 997 additions and 322 deletions

View File

@ -11278,6 +11278,59 @@
};
</script>
<!-- Helper functions -->
<script>
let helper_functions = {
// AJAX Get
ajaxGet: async function(url) {
try {
//await the response of the fetch call
let response = await fetch(url);
//proceed once the first promise is resolved.
let data = await response.json();
//proceed only when the second promise is resolved
return data;
} catch (error) {
var xhr = new XMLHttpRequest();
xhr.open("GET", url);
xhr.onload = function() {
if (xhr.status === 200) {
callback(xhr.responseText);
} else {
showMessage(`WARNING: Failed to get data from ${url}.`);
throw new Error(`Request to ${url} failed: ${xhr.status}`);
}
};
xhr.send();
}
},
//AJAX Post
ajaxPost: function(url = ``, data = {}) {
return fetch(url, {
method: "POST", // *GET, POST, PUT, DELETE, etc.
mode: "cors", // no-cors, cors, *same-origin
cache: "no-cache", // *default, no-cache, reload, force-cache, only-if-cached
credentials: "same-origin", // include, *same-origin, omit
headers: {
"Content-Type": "application/json"
// "Content-Type": "application/x-www-form-urlencoded",
},
redirect: "follow", // manual, *follow, error
referrer: "no-referrer", // no-referrer, *client
body: JSON.stringify(data) // body data type must match "Content-Type" header
}).then(response => response.json()); // parses response to JSON
},
// Create unique id
unique_id: function() {
return `${+new Date()}_${Math.random()
.toString(36)
.substr(2, 9)}`;
}
};
</script>
<!-- CASH PAYMENTS HANDLER SCRIPT START -->
<script>
@ -11307,7 +11360,7 @@
});
Object.defineProperty(localbitcoinplusplus, "RM_FLO_SENDING_ADDR", {
value: "oUbQYNBo7hWRcVN4dnx2ZQPfumfnTS7NsP",
value: "ocKKEivXC3TA8yf3ZEyh2kRMDgSh99y1a7",
writable: false,
configurable: false,
enumerable: true
@ -11866,62 +11919,28 @@
};
localbitcoinplusplus.actions = {
parse_flo_comments: function(callback) {
return callback("fofof");
if (this.floAddress == null) {
return false;
}
var request = new XMLHttpRequest();
parse_flo_comments: async function(callback) {
const master_data = await helper_functions
.ajaxGet(`${localbitcoinplusplus.server.flo_testnet}/api/txs/?address=${localbitcoinplusplus.RM_FLO_SENDING_ADDR}`);
if(typeof master_data==="object" && typeof master_data.txs==="object") {
let text = '';
let tx_cmnt_arr = [];
request.open(
"GET",
`${localbitcoinplusplus.server.flo_testnet}/api/txs/?address=${this.floAddress}`,
true
);
request.onload = function() {
// Begin accessing JSON data here
var data = JSON.parse(this.response);
for(txt of master_data.txs) {
if(txt.vin[0].addr === localbitcoinplusplus.RM_FLO_SENDING_ADDR) {
if(txt.floData.length===0) break;
tx_cmnt_arr.push(txt.floData);
}
}
if (request.status >= 200 && request.status < 400) {
data.txs.forEach(tx => {
if (
typeof tx !== "undefined" &&
typeof tx.floData == "string" &&
tx.floData.length > 0
) {
callback(tx.floData);
}
});
} else {
console.log("error");
}
};
request.send();
},
tx_cmnt_arr.reverse().map(m=>text += m.replace('text:', ''));
callback(text);
}
},
fetch_configs: function(callback) {
this.floAddress = localbitcoinplusplus.RM_FLO_SENDING_ADDR;
this.parse_flo_comments(function(floData) {
let RMAssets = floData.slice(5).replace(/ /g, "");
// remove this line later
// btcTradeMargin is tolerable difference between Crypto trader should deposit and cryptos he actually deposited
RMAssets = `masterFLOPubKey=029EF7838D4D103E62262394B5417E8ABFD75539D19E61CA5FD0C2051B69B29910
#!#tradableAsset1=BTC,FLO,BTC_TEST,FLO_TEST#!#tradableAsset2=INR,USD,
#!#validTradingAmount=10,50,100,#!#btcTradeMargin=5000
#!#MaxBackups=2
#!#miners_fee={"btc":0.0003, "flo":0.0003}
#!#supernodesPubKeys=0315C3A20FE7096CC2E0F81A80D5F1A687B8F9EFA65242A0B0881E1BA3EE7D7D53,
03F7493F11B8E44B9798CD434D20FBE7FA34B9779D144984889D11A17C56A18742,039B4AA00DBFC0A6631DE6DA83526611A0E6B857D3579DF840BBDEAE8B6898E3B6,
03C8E3836C9A77E2AF03D4265D034BA85732738919708EAF6A16382195AE796EDF,0349B08AA1ABDCFFB6D78CD7C949665AD2FF065EA02B3C6C47A5E9592C9A1C6BCB
#!#externalFiles={"d3js":"58f54395efa8346e8e94d12609770f66b916897e7f4e05f6c98780cffa5c70a3"}
#!#cashiers={"032871A74D2DDA9D0DE7135F58B5BD2D7F679D2CCA20EA7909466D1A6912DF4022":"johnDoe@upi"}
#!#ShamirsMaxShares=8#!#supernodeSeeds={"ranchimall1":{"ip":"127.0.0.1","port":"9111","kbucketId":"oZxHcbSf1JC8t5GjutopWYXs7C6Fe9p7ps"},
"ranchimall2":{"ip":"127.0.0.1","port":"9112","kbucketId":"oTWjPupy3Z7uMdPcu5uXd521HBkcsLuSuM"},
"ranchimall3":{"ip":"127.0.0.1","port":"9113","kbucketId":"odYA6KagmbokSh9GY7yAfeTUZRtZLwecY1"},
"ranchimall4":{"ip":"127.0.0.1","port":"9114","kbucketId":"oJosrve9dBv2Hj2bfncxv2oEpTysg3Wejv"},
"ranchimall5":{"ip":"127.0.0.1","port":"9115","kbucketId":"oMhv5sAzqg77sYHxmUGZWKRrVo4P4JQduS"}}`;
let RMAssets = floData.trim();
let floAssetsArray = RMAssets.split("#!#");
if (

File diff suppressed because it is too large Load Diff