Skip to content

Commit

Permalink
Merge pull request #126 from symbol/fix/gh_125-preferred-nodes-settin…
Browse files Browse the repository at this point in the history
…g-fix

fix: preferred filter fix, Config.PREFERRED_NODES is empty by default
  • Loading branch information
yilmazbahadir authored Jan 11, 2022
2 parents 214b8a8 + c9a6928 commit db056ff
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "",
"scripts": {
"dev": "nodemon",
"debug": "node --inspect-brk=0.0.0.0:9229 --require ts-node/register src/app.ts",
"build": "shx rm -rf ./dist/ && tsc && shx cp -r openapi dist/openapi",
"build:clients": "bash scripts/build-clients.sh",
"start": "node dist/app.js",
Expand Down
2 changes: 1 addition & 1 deletion src/config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
"NUMBER_OF_NODE_REQUEST_CHUNK": 10,
"NODE_PEERS_REQUEST_CHUNK_SIZE": 50,
"CHAIN_HEIGHT_REQUEST_CHUNK_SIZE": 10,
"PREFERRED_NODES": ["*.symboldev.network"],
"PREFERRED_NODES": [],
"MIN_PARTNER_NODE_VERSION": 16777728
}
2 changes: 0 additions & 2 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ export const verifyConfig = (cfg: Config): boolean => {
error = 'Invalid "NODES"';
}

if (cfg.symbol.PREFERRED_NODES.length === 0) error = 'Invalid "PREFERRED NODES"';

if (isNaN(cfg.monitor.NODE_MONITOR_SCHEDULE_INTERVAL) || cfg.monitor.NODE_MONITOR_SCHEDULE_INTERVAL < 0)
error = 'Invalid "NODE_MONITOR_SCHEDULE_INTERVAL"';

Expand Down
7 changes: 5 additions & 2 deletions src/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ export class Routes {
}

// ?filter=preferred
// it filter by host / domain name config by admin.
// it filters by host / domain name config by admin.
if (filter === NodeFilter.Preferred) {
if (!symbol.PREFERRED_NODES?.length) {
return Promise.resolve(res.send([]));
}
Object.assign(searchCriteria.filter, {
host: { $in: symbol.PREFERRED_NODES.map((node) => new RegExp(`^.${node}`, 'i')) },
host: { $in: symbol.PREFERRED_NODES.map((node) => new RegExp(`^${node}`, 'i')) },
'apiStatus.isAvailable': true,
'apiStatus.nodeStatus.apiNode': 'up',
'apiStatus.nodeStatus.db': 'up',
Expand Down

0 comments on commit db056ff

Please sign in to comment.