Skip to content

Commit

Permalink
Merge branch 'dev' into symbolgh-928-address-resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyLaw authored Oct 22, 2021
2 parents 8518153 + 3efe260 commit 3d8d61a
Show file tree
Hide file tree
Showing 17 changed files with 87 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/components/fields/SoftwareVersion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div class="icon">
<span class="mdi mdi-api"/>
</div>
{{value.restVersion}}
{{value.restVersion}} {{value.isHttpsEnabled ? '(https)' : ''}}
</div>
</div>
</template>
Expand Down
1 change: 1 addition & 0 deletions src/components/tables/TableView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export default {
key === 'connectionStatus' ||
key === 'apiNodeStatus' ||
key === 'databaseStatus' ||
key === 'isHttpsEnabled' ||
key === 'isAvailable'
);
},
Expand Down
18 changes: 9 additions & 9 deletions src/config/default.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"peersApi": {
"defaultNode": "http://ngl-dual-001.testnet.symboldev.network:3000",
"defaultNode": "https://ngl-dual-001.testnet.symboldev.network:3001",
"nodes": [
"http://ngl-dual-001.testnet.symboldev.network:3000",
"http://ngl-dual-101.testnet.symboldev.network:3000",
"http://ngl-dual-201.testnet.symboldev.network:3000",
"http://ngl-dual-301.testnet.symboldev.network:3000",
"http://ngl-dual-401.testnet.symboldev.network:3000",
"http://ngl-dual-501.testnet.symboldev.network:3000",
"http://ngl-dual-601.testnet.symboldev.network:3000"
"https://ngl-dual-001.testnet.symboldev.network:3001",
"https://ngl-dual-101.testnet.symboldev.network:3001",
"https://ngl-dual-201.testnet.symboldev.network:3001",
"https://ngl-dual-301.testnet.symboldev.network:3001",
"https://ngl-dual-401.testnet.symboldev.network:3001",
"https://ngl-dual-501.testnet.symboldev.network:3001",
"https://ngl-dual-601.testnet.symboldev.network:3001"
]
},
"apiNodePort": 3000,
"apiNodePort": 3001,
"endpoints": {
"marketData": "https://min-api.cryptocompare.com/",
"statisticsService": "http://ngl-beacon-001.testnet.symboldev.network:4001"
Expand Down
3 changes: 2 additions & 1 deletion src/config/i18n/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -397,5 +397,6 @@
"linkedAddress": "Linked",
"nodeAddress": "Node",
"vrfAddress": "VRF",
"exportCSV": "Export CSV"
"exportCSV": "Export CSV",
"isHttpsEnabled": "Https"
}
3 changes: 2 additions & 1 deletion src/config/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -393,5 +393,6 @@
"linkedAddress": "Linked",
"nodeAddress": "Node",
"vrfAddress": "VRF",
"exportCSV": "Export CSV"
"exportCSV": "Export CSV",
"isHttpsEnabled": "Https"
}
3 changes: 2 additions & 1 deletion src/config/i18n/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -397,5 +397,6 @@
"linkedAddress": "Linked",
"nodeAddress": "Node",
"vrfAddress": "VRF",
"exportCSV": "Export CSV"
"exportCSV": "Export CSV",
"isHttpsEnabled": "Https"
}
3 changes: 2 additions & 1 deletion src/config/i18n/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -393,5 +393,6 @@
"linkedAddress": "Linked",
"nodeAddress": "Node",
"vrfAddress": "VRF",
"exportCSV": "Export CSV"
"exportCSV": "Export CSV",
"isHttpsEnabled": "Https"
}
3 changes: 2 additions & 1 deletion src/config/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -387,5 +387,6 @@
"linkedAddress": "Связанные",
"nodeAddress": "Нода",
"vrfAddress": "VRF",
"exportCSV": "Экспорт CSV"
"exportCSV": "Экспорт CSV",
"isHttpsEnabled": "Https"
}
3 changes: 2 additions & 1 deletion src/config/i18n/ua.json
Original file line number Diff line number Diff line change
Expand Up @@ -393,5 +393,6 @@
"linkedAddress": "Linked",
"nodeAddress": "Node",
"vrfAddress": "VRF",
"exportCSV": "Export CSV"
"exportCSV": "Export CSV",
"isHttpsEnabled": "Https"
}
3 changes: 2 additions & 1 deletion src/config/i18n/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -393,5 +393,6 @@
"linkedAddress": "Linked",
"nodeAddress": "Node",
"vrfAddress": "VRF",
"exportCSV": "Export CSV"
"exportCSV": "Export CSV",
"isHttpsEnabled": "Https"
}
10 changes: 9 additions & 1 deletion src/config/pages/node-detail.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,15 @@
"dataGetter": "node/apiStatus",
"errorMessage": "nodeDetailError",
"pagination": "none",
"hideEmptyData": true
"hideEmptyData": true,
"fields": [
"connectionStatus",
"databaseStatus",
"apiNodeStatus",
"isHttpsEnabled",
"restVersion",
"lastStatusCheck"
]
},
{
"layoutOptions": "full-width",
Expand Down
9 changes: 7 additions & 2 deletions src/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
import { NamespaceService, MosaicService, ReceiptService } from './infrastructure';
import http from './infrastructure/http';
import moment from 'moment';
import globalConfig from './config/globalConfig';

const Url = require('url-parse');

Expand Down Expand Up @@ -126,11 +127,11 @@ class helper {
return url;
}

static httpToWsUrl(str) {
static httpToWssUrl(str) {
let url = new Url(str);

if (this.validURL(url)) {
url.set('protocol', 'ws:');
url.set('protocol', url.port === '3000' ? 'ws:' : 'wss:');
return url;
}
}
Expand Down Expand Up @@ -659,6 +660,10 @@ class helper {
static getStartListIndex = (pageNumber, pageSize) => {
return pageNumber === 1 ? 0 : (pageNumber - 1) * pageSize;
}

static formatURLProcotol = (isHttpsEnabled, host) => {
return `http${isHttpsEnabled ? 's' : ''}://${host}:${isHttpsEnabled ? globalConfig.apiNodePort : '3000'}`;
}
}

export default helper;
2 changes: 1 addition & 1 deletion src/infrastructure/AnnouncerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class AnnounceService {
// const listener = repositoryFactory.createListener()
const receiptHttp = repositoryFactory.createReceiptRepository();
const transactionHttp = repositoryFactory.createTransactionRepository();
const customWsEndpoint = `${localStorage.getItem('currentNode') || globalConfig.peersApi.defaultNode |> helper.httpToWsUrl}/ws`;
const customWsEndpoint = `${localStorage.getItem('currentNode') || globalConfig.peersApi.defaultNode |> helper.httpToWssUrl}/ws`;
const listener = new Listener(customWsEndpoint, transactionHttp, WebSocket);
const transactionService = new TransactionService(transactionHttp, receiptHttp);

Expand Down
8 changes: 4 additions & 4 deletions src/infrastructure/ListenerService.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ class ListenerService {
/**
* Subscribe to new blocks announced to the chain.
* @param onAdd - Getters function
* @param wsEndpoint - WS endpoint in string format.
* @param wssEndpoint - WSS endpoint in string format.
* @returns Array object [Listener, Subscription]
*/
static subscribeNewBlock = async (onAdd, wsEndpoint) => {
static subscribeNewBlock = async (onAdd, wssEndpoint) => {
const namespaceRepository = http.createRepositoryFactory.createNamespaceRepository();
const customWsEndpoint = `${wsEndpoint}/ws`;
const customWssEndpoint = `${wssEndpoint}/ws`;

const listener = new Listener(customWsEndpoint, namespaceRepository, WebSocket);
const listener = new Listener(customWssEndpoint, namespaceRepository, WebSocket);

await listener.open();
let subscription = listener
Expand Down
51 changes: 36 additions & 15 deletions src/infrastructure/NodeService.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class NodeService {
nodeInfo.roles === 3 ||
nodeInfo.roles === 6 ||
nodeInfo.roles === 7
? 'http://' + nodeInfo.host + ':' + (globalConfig.apiNodePort || 3000)
? helper.formatURLProcotol(nodeInfo.apiStatus.isHttpsEnabled, nodeInfo.host)
: Constants.Message.UNAVAILABLE
})

Expand All @@ -138,21 +138,24 @@ class NodeService {
node['softwareVersion'] = { version: el.version };

if (el.apiStatus) {
const { chainHeight, finalization, lastStatusCheck, restVersion, isHttpsEnabled } = el.apiStatus;

node['chainInfo'] = {
chainHeight: el.apiStatus.chainHeight,
finalizationHeight: el.apiStatus.finalizationHeight,
lastStatusCheck: el.apiStatus.lastStatusCheck
chainHeight,
finalizationHeight: finalization?.height,
lastStatusCheck
};

node['softwareVersion'] = {
...node.softwareVersion,
restVersion: el.apiStatus.restVersion
restVersion,
isHttpsEnabled
};
}
else
node['chainInfo'] = {};

if (node.hostDetail) {
if (node?.hostDetail) {
node = { ...node, ...node.hostDetail };
delete node.hostDetail;
}
Expand Down Expand Up @@ -190,13 +193,31 @@ class NodeService {
formattedNode.rolesRaw === 6 ||
formattedNode.rolesRaw === 7
) {
const status = await this.getApiNodeStatus(formattedNode.apiEndpoint);

formattedNode.apiStatus = status;

const chainInfo = await this.getNodeChainInfo(formattedNode.apiEndpoint);

formattedNode.chainInfo = chainInfo;
const { finalization, chainHeight, lastStatusCheck, nodeStatus, isAvailable, isHttpsEnabled, restVersion } = formattedNode.apiStatus;

// // Api status
formattedNode.apiStatus = {
connectionStatus: isAvailable,
databaseStatus: nodeStatus?.db === 'up' || Constants.Message.UNAVAILABLE,
apiNodeStatus: nodeStatus?.apiNode === 'up' || Constants.Message.UNAVAILABLE,
isHttpsEnabled,
restVersion,
lastStatusCheck: moment(moment.utc(lastStatusCheck).format(), 'YYYY-MM-DD HH:mm:ss')
};

if (finalization && chainHeight) {
// Chain info
formattedNode.chainInfo = {
height: chainHeight,
finalizedHeight: finalization?.height,
finalizationEpoch: finalization?.epoch,
finalizationPoint: finalization?.point,
finalizedHash: finalization?.hash,
lastStatusCheck: moment(moment.utc(lastStatusCheck).format(), 'YYYY-MM-DD HH:mm:ss')
};
}
else
formattedNode.chainInfo = {};
}
if (formattedNode?.peerStatus)
formattedNode.peerStatus.lastStatusCheck = moment(formattedNode.peerStatus.lastStatusCheck).format('YYYY-MM-DD HH:mm:ss');
Expand All @@ -212,7 +233,7 @@ class NodeService {
};

try {
const nodeStatus = (await Axios.get(nodeUrl + '/node/health')).data.status;
const nodeStatus = (await Axios.get(nodeUrl + '/node/health', { timeout: 3000 })).data.status;

status.connectionStatus = true;
status.apiNodeStatus = nodeStatus.apiNode === 'up';
Expand All @@ -231,7 +252,7 @@ class NodeService {

try {
chainInfo = {};
const nodeChainInfo = (await Axios.get(nodeUrl + '/chain/info')).data;
const nodeChainInfo = (await Axios.get(nodeUrl + '/chain/info', { timeout: 3000 })).data;

chainInfo.height = nodeChainInfo.height;
chainInfo.scoreHigh = nodeChainInfo.scoreHigh;
Expand Down
8 changes: 4 additions & 4 deletions src/store/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default {
nodes: [...globalConfig.peersApi.nodes],
defaultNode: helper.parseUrl(globalConfig.peersApi.defaultNode),
currentNode: localStorage.getItem('currentNode') ? helper.parseUrl(localStorage.getItem('currentNode')) : helper.parseUrl(globalConfig.peersApi.defaultNode),
wsEndpoint: localStorage.getItem('currentNode') || globalConfig.peersApi.defaultNode |> helper.httpToWsUrl,
wssEndpoint: localStorage.getItem('currentNode') || globalConfig.peersApi.defaultNode |> helper.httpToWssUrl,
marketData: helper.parseUrl(globalConfig.endpoints.marketData),
networkType: globalConfig.networkConfig.networkIdentifier,
appVersion: version || '0'
Expand All @@ -49,7 +49,7 @@ export default {
: [],
currentNode: state => state.currentNode.origin,
currentNodeHostname: state => state.currentNode.hostname,
wsEndpoint: state => state.wsEndpoint.origin,
wssEndpoint: state => state.wssEndpoint.origin,
marketData: state => state.marketData.origin,
isTestnet: state => state.networkType === sdk.NetworkType.TEST_NET,
appVersion: state => state.appVersion
Expand All @@ -63,12 +63,12 @@ export default {
currentNode: (state, payload) => {
if (undefined !== payload) {
const currentNode = helper.parseUrl(payload);
const wsEndpoint = currentNode.origin |> helper.httpToWsUrl;
const wssEndpoint = currentNode.origin |> helper.httpToWssUrl;

localStorage.setItem('currentNode', currentNode);

Vue.set(state, 'currentNode', currentNode);
Vue.set(state, 'wsEndpoint', wsEndpoint);
Vue.set(state, 'wssEndpoint', wssEndpoint);
}
},
setNodes: (state, nodes) => {
Expand Down
2 changes: 1 addition & 1 deletion src/store/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export default {

dispatch('chain/getChainInfo', null, { root: true });
},
rootGetters['api/wsEndpoint']
rootGetters['api/wssEndpoint']
);

commit('setSubscription', subscription);
Expand Down

0 comments on commit 3d8d61a

Please sign in to comment.