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 () {
|
function blockchainDir () {
|
||||||
return options.blockchainDir
|
return '/mnt/blockchains'
|
||||||
}
|
}
|
||||||
|
|
||||||
function cryptoDir (cryptoRec) {
|
function cryptoDir (cryptoRec) {
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ const mapValuesWithKey = _.mapValues.convert({
|
||||||
|
|
||||||
const TRADE_TTL = 2 * T.minutes
|
const TRADE_TTL = 2 * T.minutes
|
||||||
const STALE_TICKER = 3 * 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 PONG_TTL = '1 week'
|
||||||
const tradesQueues = {}
|
const tradesQueues = {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,21 +48,18 @@ function split (str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseConf (confPath) {
|
function parseConf (confPath) {
|
||||||
try {
|
const conf = fs.readFileSync(confPath)
|
||||||
const conf = fs.readFileSync(confPath)
|
const lines = conf.toString().split('\n')
|
||||||
const lines = conf.toString().split('\n')
|
|
||||||
|
|
||||||
const res = {}
|
const res = {}
|
||||||
for (let i = 0; i < lines.length; i++) {
|
for (let i = 0; i < lines.length; i++) {
|
||||||
const keyVal = split(lines[i])
|
const keyVal = split(lines[i])
|
||||||
|
|
||||||
// skip when value is empty
|
// skip when value is empty
|
||||||
if (!keyVal[1]) continue
|
if (!keyVal[1]) continue
|
||||||
|
|
||||||
res[keyVal[0]] = keyVal[1]
|
res[keyVal[0]] = keyVal[1]
|
||||||
}
|
|
||||||
return res
|
|
||||||
} catch (e) {
|
|
||||||
throw new Error('wallet is currently not installed')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,16 +8,22 @@ const coinUtils = require('../../../coin-utils')
|
||||||
const cryptoRec = coinUtils.getCryptoCurrency('BCH')
|
const cryptoRec = coinUtils.getCryptoCurrency('BCH')
|
||||||
const configPath = coinUtils.configPath(cryptoRec)
|
const configPath = coinUtils.configPath(cryptoRec)
|
||||||
const unitScale = cryptoRec.unitScale
|
const unitScale = cryptoRec.unitScale
|
||||||
const config = jsonRpc.parseConf(configPath)
|
|
||||||
|
|
||||||
const rpcConfig = {
|
function rpcConfig () {
|
||||||
username: config.rpcuser,
|
try {
|
||||||
password: config.rpcpassword,
|
const config = jsonRpc.parseConf(configPath)
|
||||||
port: config.rpcport || cryptoRec.defaultPort
|
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) {
|
function fetch (method, params) {
|
||||||
return jsonRpc.fetch(rpcConfig, method, params)
|
return jsonRpc.fetch(rpcConfig(), method, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkCryptoCode (cryptoCode) {
|
function checkCryptoCode (cryptoCode) {
|
||||||
|
|
|
||||||
|
|
@ -8,16 +8,22 @@ const coinUtils = require('../../../coin-utils')
|
||||||
const cryptoRec = coinUtils.getCryptoCurrency('BTC')
|
const cryptoRec = coinUtils.getCryptoCurrency('BTC')
|
||||||
const configPath = coinUtils.configPath(cryptoRec)
|
const configPath = coinUtils.configPath(cryptoRec)
|
||||||
const unitScale = cryptoRec.unitScale
|
const unitScale = cryptoRec.unitScale
|
||||||
const config = jsonRpc.parseConf(configPath)
|
|
||||||
|
|
||||||
const rpcConfig = {
|
function rpcConfig () {
|
||||||
username: config.rpcuser,
|
try {
|
||||||
password: config.rpcpassword,
|
const config = jsonRpc.parseConf(configPath)
|
||||||
port: config.rpcport || cryptoRec.defaultPort
|
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) {
|
function fetch (method, params) {
|
||||||
return jsonRpc.fetch(rpcConfig, method, params)
|
return jsonRpc.fetch(rpcConfig(), method, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkCryptoCode (cryptoCode) {
|
function checkCryptoCode (cryptoCode) {
|
||||||
|
|
|
||||||
|
|
@ -9,16 +9,22 @@ const E = require('../../../error')
|
||||||
const cryptoRec = coinUtils.getCryptoCurrency('DASH')
|
const cryptoRec = coinUtils.getCryptoCurrency('DASH')
|
||||||
const configPath = coinUtils.configPath(cryptoRec)
|
const configPath = coinUtils.configPath(cryptoRec)
|
||||||
const unitScale = cryptoRec.unitScale
|
const unitScale = cryptoRec.unitScale
|
||||||
const config = jsonRpc.parseConf(configPath)
|
|
||||||
|
|
||||||
const rpcConfig = {
|
function rpcConfig () {
|
||||||
username: config.rpcuser,
|
try {
|
||||||
password: config.rpcpassword,
|
const config = jsonRpc.parseConf(configPath)
|
||||||
port: config.rpcport || cryptoRec.defaultPort
|
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) {
|
function fetch (method, params) {
|
||||||
return jsonRpc.fetch(rpcConfig, method, params)
|
return jsonRpc.fetch(rpcConfig(), method, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkCryptoCode (cryptoCode) {
|
function checkCryptoCode (cryptoCode) {
|
||||||
|
|
|
||||||
|
|
@ -9,16 +9,21 @@ const E = require('../../../error')
|
||||||
const cryptoRec = coinUtils.getCryptoCurrency('LTC')
|
const cryptoRec = coinUtils.getCryptoCurrency('LTC')
|
||||||
const configPath = coinUtils.configPath(cryptoRec)
|
const configPath = coinUtils.configPath(cryptoRec)
|
||||||
const unitScale = cryptoRec.unitScale
|
const unitScale = cryptoRec.unitScale
|
||||||
const config = jsonRpc.parseConf(configPath)
|
|
||||||
|
|
||||||
const rpcConfig = {
|
function rpcConfig () {
|
||||||
username: config.rpcuser,
|
try {
|
||||||
password: config.rpcpassword,
|
const config = jsonRpc.parseConf(configPath)
|
||||||
port: config.rpcport || cryptoRec.defaultPort
|
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) {
|
function fetch (method, params) {
|
||||||
return jsonRpc.fetch(rpcConfig, method, params)
|
return jsonRpc.fetch(rpcConfig(), method, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkCryptoCode (cryptoCode) {
|
function checkCryptoCode (cryptoCode) {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ function rpcConfig () {
|
||||||
port: config.rpcport || cryptoRec.defaultPort
|
port: config.rpcport || cryptoRec.defaultPort
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw err
|
throw new Error('wallet is currently not installed')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue