diff --git a/shell-scripts/local-external-ipfs-node.sh b/shell-scripts/local-external-ipfs-node.sh index cf3f13f..7be8641 100755 --- a/shell-scripts/local-external-ipfs-node.sh +++ b/shell-scripts/local-external-ipfs-node.sh @@ -30,4 +30,7 @@ export DBURL=mongodb://localhost:27017/ipfs-service-dev export CONSUMER_ENV=production +# Lock the consumer into a preferred service provider. +#export PREFERRED_PROVIDER=12D3KooWEzE3HNH86WCb2Xocu6PgBCnSGUD7myJmuTHvoedMwp7K + npm start diff --git a/src/controllers/rest-api/bch/controller.js b/src/controllers/rest-api/bch/controller.js index 68eed4d..b9b03b0 100644 --- a/src/controllers/rest-api/bch/controller.js +++ b/src/controllers/rest-api/bch/controller.js @@ -3,6 +3,7 @@ */ const { wlogger } = require('../../../adapters/wlogger') +const config = require('../../../../config') // let _this @@ -23,10 +24,7 @@ class BchRESTControllerLib { } // Encapsulate dependencies - // this.UserModel = this.adapters.localdb.Users - // this.userUseCases = this.useCases.user - - // _this = this + this.config = config } /** @@ -66,6 +64,11 @@ class BchRESTControllerLib { try { const providerId = ctx.request.body.provider + // Throw an error, if the provider has been set by an environment variable. + if(this.config.preferredProvider) { + throw new Error(`Consumer has preferredProvider set in environment variable. Refusing to switch providers.`) + } + await this.adapters.bch.selectProvider(providerId) const body = {