From 285839a554dfb2c6c706df7beff7804a35130e41 Mon Sep 17 00:00:00 2001 From: kvhnuke Date: Sat, 3 Dec 2016 09:29:36 -0800 Subject: [PATCH] added loadbalancer --- app/scripts/ajaxReq.js | 20 +- chrome-extension/js/etherwallet-master.js | 96129 +++++++++++--------- dist/js/etherwallet-master.js | 96129 +++++++++++--------- json_relay_node/index.js | 2 +- json_relay_node/nodeIP.json | 1 + json_relay_node/response.js | 75 +- 6 files changed, 101351 insertions(+), 91005 deletions(-) create mode 100644 json_relay_node/nodeIP.json diff --git a/app/scripts/ajaxReq.js b/app/scripts/ajaxReq.js index 0e60c11d..3e59d2c1 100644 --- a/app/scripts/ajaxReq.js +++ b/app/scripts/ajaxReq.js @@ -5,7 +5,6 @@ ajaxReq.http = null; ajaxReq.postSerializer = null; ajaxReq.SERVERURL = "https://rpc.myetherwallet.com/api.mew"; ajaxReq.COINMARKETCAPAPI = "https://coinmarketcap-nexuist.rhcloud.com/api/"; -ajaxReq.pendingPosts = []; ajaxReq.config = { headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' @@ -53,25 +52,10 @@ ajaxReq.getTraceCall = function(txobj, isClassic, callback) { isClassic: isClassic }, callback); } -ajaxReq.queuePost = function() { - var data = this.pendingPosts[0].data; - var callback = this.pendingPosts[0].callback; - this.http.post(this.SERVERURL, this.postSerializer(data), this.config).then(function(data) { - callback(data.data); - ajaxReq.pendingPosts.splice(0, 1); - if (ajaxReq.pendingPosts.length > 0) ajaxReq.queuePost(); - }); -} ajaxReq.post = function(data, callback) { - this.pendingPosts.push({ - data: data, - callback: function(_data) { - if (_data && _data.error) - _data.msg = globalFuncs.getEthNodeMsg(_data.msg); - callback(_data); - } + this.http.post(this.SERVERURL, this.postSerializer(data), this.config).then(function(data) { + callback(data.data); }); - if (this.pendingPosts.length == 1) this.queuePost(); } ajaxReq.getETHvalue = function(callback) { var prefix = "eth"; diff --git a/chrome-extension/js/etherwallet-master.js b/chrome-extension/js/etherwallet-master.js index bf3c6737..4c2788d3 100644 --- a/chrome-extension/js/etherwallet-master.js +++ b/chrome-extension/js/etherwallet-master.js @@ -2,12 +2,11 @@ 'use strict'; var http; -var ajaxReq = function ajaxReq() {}; +var ajaxReq = function () {}; ajaxReq.http = null; ajaxReq.postSerializer = null; ajaxReq.SERVERURL = "https://rpc.myetherwallet.com/api.mew"; ajaxReq.COINMARKETCAPAPI = "https://coinmarketcap-nexuist.rhcloud.com/api/"; -ajaxReq.pendingPosts = []; ajaxReq.config = { headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' @@ -55,25 +54,11 @@ ajaxReq.getTraceCall = function (txobj, isClassic, callback) { isClassic: isClassic }, callback); }; -ajaxReq.queuePost = function () { - var data = this.pendingPosts[0].data; - var callback = this.pendingPosts[0].callback; +ajaxReq.post = function (data, callback) { this.http.post(this.SERVERURL, this.postSerializer(data), this.config).then(function (data) { callback(data.data); - ajaxReq.pendingPosts.splice(0, 1); - if (ajaxReq.pendingPosts.length > 0) ajaxReq.queuePost(); }); }; -ajaxReq.post = function (data, _callback) { - this.pendingPosts.push({ - data: data, - callback: function callback(_data) { - if (_data && _data.error) _data.msg = globalFuncs.getEthNodeMsg(_data.msg); - _callback(_data); - } - }); - if (this.pendingPosts.length == 1) this.queuePost(); -}; ajaxReq.getETHvalue = function (callback) { var prefix = "eth"; this.http.get(this.COINMARKETCAPAPI + prefix).then(function (data) { @@ -91,7 +76,7 @@ module.exports = ajaxReq; },{}],2:[function(require,module,exports){ 'use strict'; -var addWalletCtrl = function addWalletCtrl($scope, $sce) { +var addWalletCtrl = function ($scope, $sce) { $scope.showBtnGen = $scope.showBtnUnlock = $scope.showBtnAdd = $scope.showBtnAddWallet = $scope.showAddWallet = $scope.requireFPass = $scope.requirePPass = $scope.showPassTxt = false; $scope.nickNames = []; $scope.filePassword = $scope.fileContent = ""; @@ -301,7 +286,7 @@ module.exports = addWalletCtrl; },{}],3:[function(require,module,exports){ 'use strict'; -var cxDecryptWalletCtrl = function cxDecryptWalletCtrl($scope, $sce, walletService) { +var cxDecryptWalletCtrl = function ($scope, $sce, walletService) { $scope.allWallets = []; $scope.selectedWallet = $scope.password = ""; $scope.setAllWallets = function () { @@ -352,7 +337,7 @@ module.exports = cxDecryptWalletCtrl; },{}],4:[function(require,module,exports){ 'use strict'; -var mainPopCtrl = function mainPopCtrl($scope, $sce) { +var mainPopCtrl = function ($scope, $sce) { $scope.allWallets = []; $scope.allWatchOnly = []; $scope.setAllWallets = function () { @@ -388,7 +373,7 @@ module.exports = mainPopCtrl; },{}],5:[function(require,module,exports){ 'use strict'; -var myWalletsCtrl = function myWalletsCtrl($scope, $sce) { +var myWalletsCtrl = function ($scope, $sce) { $scope.editModal = new Modal(document.getElementById('editWallet')); $scope.viewModal = new Modal(document.getElementById('viewWalletDetails')); $scope.removeModal = new Modal(document.getElementById('removeWallet')); @@ -552,7 +537,7 @@ module.exports = myWalletsCtrl; },{}],6:[function(require,module,exports){ 'use strict'; -var quickSendCtrl = function quickSendCtrl($scope, $sce) { +var quickSendCtrl = function ($scope, $sce) { $scope.allWallets = []; $scope.selectedWallet = ""; $scope.showConfirm = false; @@ -651,7 +636,7 @@ module.exports = quickSendCtrl; },{}],7:[function(require,module,exports){ 'use strict'; -var bulkGenCtrl = function bulkGenCtrl($scope) { +var bulkGenCtrl = function ($scope) { $scope.showWallets = false; $scope.genWallets = function () { if ($scope.amount == '' || $scope.amount != parseInt($scope.amount, 10)) alert(globalFuncs.errorMsgs[0]);else { @@ -684,7 +669,7 @@ module.exports = bulkGenCtrl; (function (Buffer){ 'use strict'; -var decryptWalletCtrl = function decryptWalletCtrl($scope, $sce, walletService) { +var decryptWalletCtrl = function ($scope, $sce, walletService) { $scope.walletType = ""; $scope.requireFPass = $scope.requirePPass = $scope.showFDecrypt = $scope.showPDecrypt = $scope.showAOnly = false; $scope.filePassword = ""; @@ -807,10 +792,10 @@ var decryptWalletCtrl = function decryptWalletCtrl($scope, $sce, walletService) $scope.wallet = { type: "addressOnly", address: $scope.addressOnly, - getAddressString: function getAddressString() { + getAddressString: function () { return this.address; }, - getChecksumAddressString: function getChecksumAddressString() { + getChecksumAddressString: function () { return ethUtil.toChecksumAddress(this.getAddressString()); } }; @@ -842,7 +827,7 @@ module.exports = decryptWalletCtrl; },{"buffer":118}],9:[function(require,module,exports){ 'use strict'; -var deployContractCtrl = function deployContractCtrl($scope, $sce, walletService) { +var deployContractCtrl = function ($scope, $sce, walletService) { $scope.sendTxModal = new Modal(document.getElementById('sendTransaction')); $scope.tx = { gasLimit: '', @@ -925,7 +910,7 @@ module.exports = deployContractCtrl; },{}],10:[function(require,module,exports){ 'use strict'; -var digixCtrl = function digixCtrl($scope, $sce, walletService) { +var digixCtrl = function ($scope, $sce, walletService) { $scope.usdBalance = "loading"; $scope.eurBalance = "loading"; $scope.btcBalance = "loading"; @@ -1045,7 +1030,7 @@ module.exports = digixCtrl; },{}],11:[function(require,module,exports){ 'use strict'; -var footerCtrl = function footerCtrl($scope) { +var footerCtrl = function ($scope) { $scope.footerModal = new Modal(document.getElementById('disclaimerModal')); $scope.ethBlockNumber = "loading"; $scope.etcBlockNumber = "loading"; @@ -1067,7 +1052,7 @@ module.exports = footerCtrl; },{}],12:[function(require,module,exports){ 'use strict'; -var sendOfflineTxCtrl = function sendOfflineTxCtrl($scope, $sce, walletService) { +var sendOfflineTxCtrl = function ($scope, $sce, walletService) { walletService.wallet = null; walletService.password = ''; $scope.unitReadable = "ETH"; @@ -1222,7 +1207,7 @@ module.exports = sendOfflineTxCtrl; },{}],13:[function(require,module,exports){ 'use strict'; -var sendTxCtrl = function sendTxCtrl($scope, $sce, walletService) { +var sendTxCtrl = function ($scope, $sce, walletService) { $scope.unitReadable = ""; $scope.unitTranslation = "TRANS_eth"; $scope.sendTxModal = new Modal(document.getElementById('sendTransaction')); @@ -1253,10 +1238,7 @@ var sendTxCtrl = function sendTxCtrl($scope, $sce, walletService) { donate: false, tokenSymbol: globalFuncs.urlGet('tokenSymbol') == null ? false : globalFuncs.urlGet('tokenSymbol') }; - $scope.setSendMode = function (sendMode) { - var tokenId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; - var tokenSymbol = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ''; - + $scope.setSendMode = function (sendMode, tokenId = '', tokenSymbol = '') { $scope.tx.sendMode = sendMode; $scope.unitReadable = ''; if (sendMode == 0) { @@ -1422,7 +1404,7 @@ module.exports = sendTxCtrl; (function (Buffer){ 'use strict'; -var signMsgCtrl = function signMsgCtrl($scope, $sce, walletService) { +var signMsgCtrl = function ($scope, $sce, walletService) { $scope.visibility = "signView"; $scope.$watch(function () { if (walletService.wallet == null) return null; @@ -1480,7 +1462,7 @@ module.exports = signMsgCtrl; },{"buffer":118}],15:[function(require,module,exports){ 'use strict'; -var tabsCtrl = function tabsCtrl($scope, globalService, $translate) { +var tabsCtrl = function ($scope, globalService, $translate) { $scope.tabNames = globalService.tabs; $scope.curLang = "English"; var hval = window.location.hash; @@ -1527,11 +1509,8 @@ var tabsCtrl = function tabsCtrl($scope, globalService, $translate) { }; $scope.setErrorMsgLanguage = function () { - for (var i = 0; i < globalFuncs.errorMsgs.length; i++) { - $scope.setLanguageVal('ERROR_' + (i + 1), 'errorMsgs', i); - }for (var i = 0; i < globalFuncs.successMsgs.length; i++) { - $scope.setLanguageVal('SUCCESS_' + (i + 1), 'successMsgs', i); - } + for (var i = 0; i < globalFuncs.errorMsgs.length; i++) $scope.setLanguageVal('ERROR_' + (i + 1), 'errorMsgs', i); + for (var i = 0; i < globalFuncs.successMsgs.length; i++) $scope.setLanguageVal('SUCCESS_' + (i + 1), 'successMsgs', i); }; $scope.setGethErrMsgLanguage = function () { @@ -1619,7 +1598,7 @@ module.exports = tabsCtrl; },{}],16:[function(require,module,exports){ 'use strict'; -var theDaoCtrl = function theDaoCtrl($scope, $sce, walletService) { +var theDaoCtrl = function ($scope, $sce, walletService) { $scope.etherBalance = "loading"; $scope.usdBalance = "loading"; $scope.eurBalance = "loading"; @@ -1796,7 +1775,7 @@ module.exports = theDaoCtrl; },{}],17:[function(require,module,exports){ 'use strict'; -var viewCtrl = function viewCtrl($scope, globalService) { +var viewCtrl = function ($scope, globalService) { $scope.globalService = globalService; }; module.exports = viewCtrl; @@ -1804,7 +1783,7 @@ module.exports = viewCtrl; },{}],18:[function(require,module,exports){ 'use strict'; -var viewWalletCtrl = function viewWalletCtrl($scope, walletService) { +var viewWalletCtrl = function ($scope, walletService) { $scope.usdBalance = "loading"; $scope.eurBalance = "loading"; $scope.btcBalance = "loading"; @@ -1864,19 +1843,16 @@ var viewWalletCtrl = function viewWalletCtrl($scope, walletService) { var storedTokens = localStorage.getItem("localTokens") != null ? JSON.parse(localStorage.getItem("localTokens")) : []; // remove from localstorage so it doesn't show up on refresh - for (var i = 0; i < storedTokens.length; i++) { - if (storedTokens[i].symbol === tokenSymbol) { - storedTokens.splice(i, 1); - break; - } - }localStorage.setItem("localTokens", JSON.stringify(storedTokens)); + for (var i = 0; i < storedTokens.length; i++) if (storedTokens[i].symbol === tokenSymbol) { + storedTokens.splice(i, 1); + break; + } + localStorage.setItem("localTokens", JSON.stringify(storedTokens)); // remove from tokenObj so it removes from display - for (var i = 0; i < $scope.tokenObjs.length; i++) { - if ($scope.tokenObjs[i].symbol === tokenSymbol) { - $scope.tokenObjs.splice(i, 1); - break; - } + for (var i = 0; i < $scope.tokenObjs.length; i++) if ($scope.tokenObjs[i].symbol === tokenSymbol) { + $scope.tokenObjs.splice(i, 1); + break; } }; @@ -1892,7 +1868,7 @@ module.exports = viewWalletCtrl; },{}],19:[function(require,module,exports){ 'use strict'; -var walletBalanceCtrl = function walletBalanceCtrl($scope, $sce) { +var walletBalanceCtrl = function ($scope, $sce) { $scope.localToken = { contractAdd: "", symbol: "", @@ -1926,7 +1902,7 @@ module.exports = walletBalanceCtrl; },{}],20:[function(require,module,exports){ 'use strict'; -var walletGenCtrl = function walletGenCtrl($scope) { +var walletGenCtrl = function ($scope) { $scope.password = ""; $scope.wallet = null; $scope.showWallet = false; @@ -1965,7 +1941,7 @@ module.exports = walletGenCtrl; },{}],21:[function(require,module,exports){ 'use strict'; -var cxFuncs = function cxFuncs() {}; +var cxFuncs = function () {}; cxFuncs.storage = chrome.storage.sync; cxFuncs.getAllNickNames = function (callback) { var nickNames = []; @@ -2053,7 +2029,7 @@ module.exports = cxFuncs; },{}],22:[function(require,module,exports){ 'use strict'; -var QRCodeDrtv = function QRCodeDrtv() { +var QRCodeDrtv = function () { return function (scope, element, attrs) { var watchVar = attrs.watchVar; scope.$watch(watchVar, function () { @@ -2079,67 +2055,67 @@ module.exports = QRCodeDrtv; },{}],23:[function(require,module,exports){ 'use strict'; -var balanceDrtv = function balanceDrtv() { +var balanceDrtv = function () { return { restrict: "E", - template: '

\n \ - Account Information: <\/h4>\n \ -
\n \ -Account Address: <\/div>\n \ -