fix: custom error handling for all wallets and cache update

This commit is contained in:
José Oliveira 2021-02-26 16:30:20 +00:00 committed by Josh Harvey
parent 145a21cc8d
commit 34704e071d
8 changed files with 61 additions and 41 deletions

View file

@ -92,7 +92,7 @@ function buildUrl (cryptoCode, address) {
}
function blockchainDir () {
return options.blockchainDir
return '/mnt/blockchains'
}
function cryptoDir (cryptoRec) {

View file

@ -31,7 +31,7 @@ const mapValuesWithKey = _.mapValues.convert({
const TRADE_TTL = 2 * T.minutes
const STALE_TICKER = 3 * T.minutes
const STALE_BALANCE = 3 * T.minutes
const STALE_BALANCE = 15 * T.seconds
const PONG_TTL = '1 week'
const tradesQueues = {}

View file

@ -48,7 +48,6 @@ function split (str) {
}
function parseConf (confPath) {
try {
const conf = fs.readFileSync(confPath)
const lines = conf.toString().split('\n')
@ -61,8 +60,6 @@ function parseConf (confPath) {
res[keyVal[0]] = keyVal[1]
}
return res
} catch (e) {
throw new Error('wallet is currently not installed')
}
}

View file

@ -8,16 +8,22 @@ const coinUtils = require('../../../coin-utils')
const cryptoRec = coinUtils.getCryptoCurrency('BCH')
const configPath = coinUtils.configPath(cryptoRec)
const unitScale = cryptoRec.unitScale
const config = jsonRpc.parseConf(configPath)
const rpcConfig = {
function rpcConfig () {
try {
const config = jsonRpc.parseConf(configPath)
return {
username: config.rpcuser,
password: config.rpcpassword,
port: config.rpcport || cryptoRec.defaultPort
}
} catch (err) {
throw new Error('wallet is currently not installed')
}
}
function fetch (method, params) {
return jsonRpc.fetch(rpcConfig, method, params)
return jsonRpc.fetch(rpcConfig(), method, params)
}
function checkCryptoCode (cryptoCode) {

View file

@ -8,16 +8,22 @@ const coinUtils = require('../../../coin-utils')
const cryptoRec = coinUtils.getCryptoCurrency('BTC')
const configPath = coinUtils.configPath(cryptoRec)
const unitScale = cryptoRec.unitScale
const config = jsonRpc.parseConf(configPath)
const rpcConfig = {
function rpcConfig () {
try {
const config = jsonRpc.parseConf(configPath)
return {
username: config.rpcuser,
password: config.rpcpassword,
port: config.rpcport || cryptoRec.defaultPort
}
} catch (err) {
throw new Error('wallet is currently not installed')
}
}
function fetch (method, params) {
return jsonRpc.fetch(rpcConfig, method, params)
return jsonRpc.fetch(rpcConfig(), method, params)
}
function checkCryptoCode (cryptoCode) {

View file

@ -9,16 +9,22 @@ const E = require('../../../error')
const cryptoRec = coinUtils.getCryptoCurrency('DASH')
const configPath = coinUtils.configPath(cryptoRec)
const unitScale = cryptoRec.unitScale
const config = jsonRpc.parseConf(configPath)
const rpcConfig = {
function rpcConfig () {
try {
const config = jsonRpc.parseConf(configPath)
return {
username: config.rpcuser,
password: config.rpcpassword,
port: config.rpcport || cryptoRec.defaultPort
}
} catch (err) {
throw new Error('wallet is currently not installed')
}
}
function fetch (method, params) {
return jsonRpc.fetch(rpcConfig, method, params)
return jsonRpc.fetch(rpcConfig(), method, params)
}
function checkCryptoCode (cryptoCode) {

View file

@ -9,16 +9,21 @@ const E = require('../../../error')
const cryptoRec = coinUtils.getCryptoCurrency('LTC')
const configPath = coinUtils.configPath(cryptoRec)
const unitScale = cryptoRec.unitScale
const config = jsonRpc.parseConf(configPath)
const rpcConfig = {
function rpcConfig () {
try {
const config = jsonRpc.parseConf(configPath)
return {
username: config.rpcuser,
password: config.rpcpassword,
port: config.rpcport || cryptoRec.defaultPort
}
} catch (err) {
throw new Error('wallet is currently not installed')
}
}
function fetch (method, params) {
return jsonRpc.fetch(rpcConfig, method, params)
return jsonRpc.fetch(rpcConfig(), method, params)
}
function checkCryptoCode (cryptoCode) {

View file

@ -19,7 +19,7 @@ function rpcConfig () {
port: config.rpcport || cryptoRec.defaultPort
}
} catch (err) {
throw err
throw new Error('wallet is currently not installed')
}
}