Skip to content

Commit

Permalink
Apothem v2.0 Network Added
Browse files Browse the repository at this point in the history
  • Loading branch information
AnilChinchawale committed Jun 15, 2019
1 parent 7d61f92 commit 596e0a7
Show file tree
Hide file tree
Showing 14 changed files with 183 additions and 177 deletions.
2 changes: 1 addition & 1 deletion interface/i18n/mist.en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"openRemix": "Open Remix IDE",
"ethereumNode": "XinFin Node",
"network": "Network",
"mainNetwork": " XinFin Main Network",
"mainNetwork": "XinFin - Main Network",
"startMining": "⛏ Start mining",
"stopMining": "⛏ Stop mining",
"enableSwarm": "Enable Swarm",
Expand Down
2 changes: 1 addition & 1 deletion interface/i18n/mist.fa.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"logFiles": "Show log file",
"ethereumNode": "XinFin Node",
"network": "Network",
"mainNetwork": " XinFin Main Network",
"mainNetwork": "XinFin Main Network",
"startMining": "⛏ Start Mining",
"stopMining": "⛏ Stop Mining",
"openRemix": "Open Remix IDE"
Expand Down
4 changes: 2 additions & 2 deletions meteor-dapp-wallet/app/client/templates/layout/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
<span class="private-chain" title="{{i18n 'wallet.app.texts.testnetExplain'}}">Test-net</span> &nbsp;&nbsp;
{{/if}}
{{#if $eq ($.Session.get "network") "apothem"}}
<span class="private-chain" title="{{i18n 'wallet.app.texts.testnetExplain'}}">XinFin MainNet</span> &nbsp;&nbsp;
<span class="private-chain" title="{{i18n 'wallet.app.texts.testnetExplain'}}">XinFin Network</span> &nbsp;&nbsp;
{{/if}}
{{#if $eq ($.Session.get "network") "private"}}
<span class="private-chain" title="{{i18n 'wallet.app.texts.testnetExplain'}}">XinFin MainNet</span> &nbsp;&nbsp;
<span class="private-chain" title="{{i18n 'wallet.app.texts.testnetExplain'}}">XinFin Network</span> &nbsp;&nbsp;
{{/if}}

{{#with TemplateVar.get "syncing"}}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"name": "standard-minifier-js",
"version": "2.3.2"
},
"totalMinifiedBytes": 2927054,
"totalMinifiedGzipBytes": 743692,
"totalMinifiedBytes": 2927074,
"totalMinifiedGzipBytes": 743700,
"minifiedBytesByPackage": {
"packages/meteor.js": 8962,
"packages/standard-minifiers.js": 38,
Expand All @@ -14,7 +14,7 @@
"packages/ecmascript.js": 30,
"packages/modules-runtime.js": 4023,
"packages/modules.js": [
109293,
109313,
{
"node_modules": {
"meteor": {
Expand All @@ -40,7 +40,7 @@
},
"@babel": {
"runtime": {
"package.json": 1219,
"package.json": 1239,
"helpers": {
"typeof.js": 500,
"toConsumableArray.js": 148,
Expand Down
2 changes: 1 addition & 1 deletion meteor-dapp-wallet/build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<link rel="stylesheet" type="text/css" class="__meteor-css__" href="b5c0100a3fba3970004889019e9de74240e11f74.css?meteor_css_resource=true">
<script type="text/javascript">__meteor_runtime_config__ = JSON.parse(decodeURIComponent("%7B%22meteorRelease%22%3A%22METEOR%401.6.1%22%2C%22ROOT_URL_PATH_PREFIX%22%3A%22%22%2C%22meteorEnv%22%3A%7B%22NODE_ENV%22%3A%22production%22%7D%2C%22ROOT_URL%22%3A%22%22%7D"));</script>
<script type="text/javascript" src="b1a9b7ecbe26425e6c6efaa70acd1d4bff36021d.js"></script>
<script type="text/javascript" src="680caff91e4afafdab62b24260699a0fa6d5601c.js"></script>
<script type="text/javascript">Meteor.disconnect();</script>
<meta charset="utf-8">
<title>XinFin Network</title>
Expand Down
4 changes: 2 additions & 2 deletions modules/constants.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
export const InfuraEndpoints = {
ethereum: {
http: {
Main: 'https://rpc.xinfin.network',
Main: 'https://mainnet.infura.io/mist',
ropsten: 'https://ropsten.infura.io/mist',
Rinkeby: 'https://rinkeby.infura.io/mist',
Kovan: 'https://kovan.infura.io/mist'
},
websockets: {
Main: 'ws://62.233.65.7:8555',
Main: 'wss://mainnet.infura.io/ws/mist',
ropsten: 'wss://ropsten.infura.io/ws/mist',
Rinkeby: 'wss://rinkeby.infura.io/ws/mist',
Kovan: 'wss://kovan.infura.io/ws/mist'
Expand Down
18 changes: 9 additions & 9 deletions modules/core/nodes/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ export function changeNetwork(network) {
return dispatch => {
dispatch({ type: '[MAIN]:NODES:CHANGE_NETWORK_START' });

try {
ethereumNodeRemote.setNetwork(network);
dispatch({
type: '[MAIN]:NODES:CHANGE_NETWORK_SUCCESS',
payload: { network }
});
} catch (e) {
dispatch({ type: '[MAIN]:NODES:CHANGE_NETWORK_FAILURE', error: e });
}
// try {
// ethereumNodeRemote.setNetwork(network);
// dispatch({
// type: '[MAIN]:NODES:CHANGE_NETWORK_SUCCESS',
// payload: { network }
// });
// } catch (e) {
// dispatch({ type: '[MAIN]:NODES:CHANGE_NETWORK_FAILURE', error: e });
// }
};
}

Expand Down
6 changes: 3 additions & 3 deletions modules/ethereumNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,17 +453,17 @@ class EthereumNode extends EventEmitter {
case 'test':
args = [
'--bootnodes',
'enode://1c20e6b46ce608c1fe739e78611225b94e663535b74a1545b1667eac8ff75ed43216306d123306c10e043f228e42cc53cb2728655019292380313393eaaf6e23@78.129.229.96:30301,enode://1c20e6b46ce608c1fe739e78611225b94e663535b74a1545b1667eac8ff75ed43216306d123306c10e043f228e42cc53cb2728655019292380313393eaaf6e23@5.152.223.199:30301',
'enode://1c20e6b46ce608c1fe739e78611225b94e663535b74a1545b1667eac8ff75ed43216306d123306c10e043f228e42cc53cb2728655019292380313393eaaf6e23@127.0.0.1:30301,enode://1c20e6b46ce608c1fe739e78611225b94e663535b74a1545b1667eac8ff75ed43216306d123306c10e043f228e42cc53cb2728655019292380313393eaaf6e23@188.227.164.51:30301',
'--ws',
'--rpc',
'--minerthreads',
'1',
'--targetgaslimit',
'420000000',
'--networkid',
'50',
'51',
'--ethstats',
`${os.hostname()}-${os.type()}-XinFin-Network-One-Click:xinfin_xdpos_hybrid_network_stats@stats.xinfin.network:3000`,
`${os.hostname()}-${os.type()}-XinFin-Apothem-Network-One-Click:xdc_xinfin_apothem_network_stats@stats.apothem.network:2000`,
'--mine'
];
if (syncMode === 'nosync') {
Expand Down
28 changes: 14 additions & 14 deletions modules/ipc/ipcProviderBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ class IpcProviderBackend {
log.info('Ethereum node stopping, disconnecting sockets');

// Unsubscribe remote subscriptions
_.each(this._remoteSubscriptions, remoteSubscriptionId => {
ethereumNodeRemote.send('eth_unsubscribe', [remoteSubscriptionId]);
});
// _.each(this._remoteSubscriptions, remoteSubscriptionId => {
// ethereumNodeRemote.send('eth_unsubscribe', [remoteSubscriptionId]);
// });
this._remoteSubscriptions = {};
this._subscriptionOwners = {};

Expand Down Expand Up @@ -579,11 +579,11 @@ class IpcProviderBackend {
if (result.method === 'eth_unsubscribe') {
const subscriptionId = result.params[0];
const localSubscriptionId = this._remoteSubscriptions[subscriptionId];
if (localSubscriptionId) {
ethereumNodeRemote.send('eth_unsubscribe', [localSubscriptionId]);
delete this._remoteSubscriptions[subscriptionId];
delete this._subscriptionOwners[subscriptionId];
}
// if (localSubscriptionId) {
// ethereumNodeRemote.send('eth_unsubscribe', [localSubscriptionId]);
// delete this._remoteSubscriptions[subscriptionId];
// delete this._subscriptionOwners[subscriptionId];
// }
}

return result;
Expand All @@ -603,12 +603,12 @@ class IpcProviderBackend {
);

var remoteSubscriptionId;
const requestId = await ethereumNodeRemote.send('eth_subscribe', params);
// const requestId = await ethereumNodeRemote.send('eth_subscribe', params);

if (!requestId) {
log.error('No return id for request');
return;
}
// if (!requestId) {
// log.error('No return id for request');
// return;
// }

const callback = data => {
if (!data) {
Expand Down Expand Up @@ -637,7 +637,7 @@ class IpcProviderBackend {
}
};

ethereumNodeRemote.ws.on('message', callback);
// ethereumNodeRemote.ws.on('message', callback);
});
}

Expand Down
188 changes: 97 additions & 91 deletions modules/ipc/methods/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,99 +83,105 @@ module.exports = class BaseProcessor {
}

async _sendPayload(payload, conn) {
if (this._shouldSendToRemote(payload, conn)) {
this._log.trace(`Sending request to remote node: ${payload.method}`);
const result = await this._sendToRemote(payload);
this._log.trace(
`Result from remote node: ${payload.method} (id: ${payload.id})`
);
return result;
} else {
this._log.trace(`Sending request to local node: ${payload.method}`);
const result = await conn.socket.send(payload, { fullResult: true });
this._log.trace(
`Result from local node: ${payload.method} (id: ${payload.id})`
);
return result.result;
}
}

_shouldSendToRemote(payload, conn) {
// Do NOT send to the remote node if: (all conditions must be satisfied)
// 1. the local node is synced
const isRemote = store.getState().nodes.active === 'remote';
if (!isRemote) {
return false;
}

// 2. method is on the ignore list
const method = payload.method;
if (this.remoteIgnoreMethods.includes(method)) {
return false;
}

// 3. the method is
// net_peerCount | eth_syncing | eth_subscribe[syncing]
// and is originating from the mist interface
// dev: localhost:3000, production: app.asar/interface/index.html
if (
conn &&
conn.owner &&
conn.owner.history &&
(conn.owner.history[0].startsWith('http://localhost:3000') ||
conn.owner.history[0].indexOf('app.asar/interface/index.html') > -1)
) {
if (
method === 'net_peerCount' ||
method === 'eth_syncing' ||
(method === 'eth_subscribe' && payload.params[0] === 'syncing')
) {
return false;
}
}

return true;
// if (this._shouldSendToRemote(payload, conn)) {
// this._log.trace(`Sending request to remote node: ${payload.method}`);
// const result = await this._sendToRemote(payload);
// this._log.trace(
// `Result from remote node: ${payload.method} (id: ${payload.id})`
// );
// return result;
// } else {
// this._log.trace(`Sending request to local node: ${payload.method}`);
// const result = await conn.socket.send(payload, { fullResult: true });
// this._log.trace(
// `Result from local node: ${payload.method} (id: ${payload.id})`
// );
// return result.result;
// }
this._log.trace(`Sending request to local node: ${payload.method}`);
const result = await conn.socket.send(payload, { fullResult: true });
this._log.trace(
`Result from local node: ${payload.method} (id: ${payload.id})`
);
return result.result;
}

_sendToRemote(payload, retry = false) {
return new Promise(async (resolve, reject) => {
const requestId = await ethereumNodeRemote.send(
payload.method,
payload.params
);

if (!requestId) {
const errorMessage = `No request id for method ${payload.method} (${
payload.params
})`;
reject(errorMessage);
this._log.error(errorMessage);
return;
}

const callback = data => {
if (!data) {
return;
}

try {
data = JSON.parse(data);
} catch (error) {
const errorMessage = `Error parsing data: ${data}`;
this._log.trace(errorMessage);
reject(errorMessage);
}

if (data.id === requestId) {
resolve(data);
// TODO: remove listener
// ethereumNodeRemote.ws.removeListener('message', callback);
}
};

ethereumNodeRemote.ws.on('message', callback);
});
}
// _shouldSendToRemote(payload, conn) {
// // Do NOT send to the remote node if: (all conditions must be satisfied)
// // 1. the local node is synced
// const isRemote = store.getState().nodes.active === 'remote';
// if (!isRemote) {
// return false;
// }

// // 2. method is on the ignore list
// const method = payload.method;
// if (this.remoteIgnoreMethods.includes(method)) {
// return false;
// }

// // 3. the method is
// // net_peerCount | eth_syncing | eth_subscribe[syncing]
// // and is originating from the mist interface
// // dev: localhost:3000, production: app.asar/interface/index.html
// if (
// conn &&
// conn.owner &&
// conn.owner.history &&
// (conn.owner.history[0].startsWith('http://localhost:3000') ||
// conn.owner.history[0].indexOf('app.asar/interface/index.html') > -1)
// ) {
// if (
// method === 'net_peerCount' ||
// method === 'eth_syncing' ||
// (method === 'eth_subscribe' && payload.params[0] === 'syncing')
// ) {
// return false;
// }
// }

// return true;
// }

// _sendToRemote(payload, retry = false) {
// return new Promise(async (resolve, reject) => {
// const requestId = await ethereumNodeRemote.send(
// payload.method,
// payload.params
// );

// if (!requestId) {
// const errorMessage = `No request id for method ${payload.method} (${
// payload.params
// })`;
// reject(errorMessage);
// this._log.error(errorMessage);
// return;
// }

// const callback = data => {
// if (!data) {
// return;
// }

// try {
// data = JSON.parse(data);
// } catch (error) {
// const errorMessage = `Error parsing data: ${data}`;
// this._log.trace(errorMessage);
// reject(errorMessage);
// }

// if (data.id === requestId) {
// resolve(data);
// // TODO: remove listener
// // ethereumNodeRemote.ws.removeListener('message', callback);
// }
// };

// // ethereumNodeRemote.ws.on('message', callback);
// });
// }

_isAdminConnection(conn) {
// main window or popupwindows - always allow requests
Expand Down
Loading

0 comments on commit 596e0a7

Please sign in to comment.