Skip to content

Commit

Permalink
Fabo/allow single network run (#495)
Browse files Browse the repository at this point in the history
* allow running a single network

* readme

* apply fix in networks

* Update lib/apollo.js

Co-authored-by: Bitcoinera <[email protected]>
  • Loading branch information
faboweb and Bitcoinera authored Mar 23, 2020
1 parent df24c7e commit 99ae0b3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ When running you can access GraphQL Playground at http://localhost:4000/. You ca
| `REDIS_URL` | Redis server URI in `<auth>@hostname:port` format |
| `ENGINE_API_KEY` | Enable Apollo GraphQL metrics through https://engine.apollographql.com/ |
| `SENTRY_DSN` | Sentry (https://sentry.io) data source name in format `https://<key>@sentry.io/<project>` |
| `RUN_ONLY_NETWORK` | Run only the network with this ID (allows scaling and better development) |

## Networks

Expand Down
2 changes: 1 addition & 1 deletion lib/controller/transaction/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ global.fetch = require('node-fetch')
let api
async function initPolkadotAPI() {
// ignore polkadot in tests for now
if (process.env.TEST) return
if (process.env.TEST || !networkMap['polkadot-testnet']) return

api = new ApiPromise({
provider: new WsProvider(networkMap['polkadot-testnet'].rpc_url)
Expand Down
5 changes: 4 additions & 1 deletion lib/networks.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ let networks = networksMain
if (config.enableTestnet || config.env === 'test') {
networks = [...networks, ...networksLocal]
}

// if the RUN_ONLY_NETWORK env variable is set, we only run the especified network
if (process.env.RUN_ONLY_NETWORK) {
networks = networks.filter(({ id }) => id === process.env.RUN_ONLY_NETWORK)
}
module.exports = {
networkList: networks,
networkMap: keyBy(networks, 'id'),
Expand Down

0 comments on commit 99ae0b3

Please sign in to comment.