Skip to content

Commit

Permalink
Merge pull request #118 from thanhson1085/master
Browse files Browse the repository at this point in the history
try to hanldle the connection error
  • Loading branch information
thanhson1085 committed Jul 25, 2018
2 parents 390eb4c + ea73e11 commit dab199a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion models/blockchain/chain.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
const Web3 = require('web3')
const config = require('config')

const chain = new Web3(new Web3.providers.HttpProvider(config.get('blockchain.rpc')))
const provider = new Web3.providers.HttpProvider(config.get('blockchain.rpc'))
const chain = new Web3(provider)
if (!provider.isConnected()) {
console.error('RPC connection lost - shut down service')
process.exit()
}

module.exports = chain

0 comments on commit dab199a

Please sign in to comment.