fix: custom error handling for all wallets and cache update
This commit is contained in:
parent
145a21cc8d
commit
34704e071d
8 changed files with 61 additions and 41 deletions
|
|
@ -92,7 +92,7 @@ function buildUrl (cryptoCode, address) {
|
|||
}
|
||||
|
||||
function blockchainDir () {
|
||||
return options.blockchainDir
|
||||
return '/mnt/blockchains'
|
||||
}
|
||||
|
||||
function cryptoDir (cryptoRec) {
|
||||
|
|
|
|||
|
|
@ -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 = {}
|
||||
|
||||
|
|
|
|||
|
|
@ -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')
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ function rpcConfig () {
|
|||
port: config.rpcport || cryptoRec.defaultPort
|
||||
}
|
||||
} catch (err) {
|
||||
throw err
|
||||
throw new Error('wallet is currently not installed')
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue