Fix: remove unnecessary variables
This commit is contained in:
parent
a521b679c4
commit
7210406a8a
7 changed files with 14 additions and 34 deletions
|
|
@ -3,7 +3,6 @@ var db = require('../lib/db')
|
|||
const settingsLoader = require('../lib/new-settings-loader')
|
||||
const configManager = require('../lib/new-config-manager')
|
||||
|
||||
const isNil = val => val == null
|
||||
const curriedGetCashout = _.curry(configManager.getCashOut)
|
||||
|
||||
exports.up = function (next) {
|
||||
|
|
@ -12,24 +11,25 @@ exports.up = function (next) {
|
|||
const machinesPromise = t.any('SELECT device_id FROM devices')
|
||||
const [{ config }, machines] = await Promise.all([settingsPromise, machinesPromise])
|
||||
const cryptoCodes = configManager.getCryptosFromWalletNamespace(config)
|
||||
|
||||
const zeroConfLimits = _.map(_.flow(_.get('device_id'), curriedGetCashout(_, config), _.get('zeroConfLimit')), machines)
|
||||
const minArr = _.min(zeroConfLimits)
|
||||
const min = !isNil(minArr) && minArr < Infinity ? Number(minArr) : 0
|
||||
const min = !_.isNil(minArr) && minArr < Infinity ? Number(minArr) : 0
|
||||
|
||||
_.forEach(cryptoCode => {
|
||||
const walletConfig = configManager.getWalletSettings(cryptoCode, config)
|
||||
const zeroConfLimit = _.get('zeroConfLimit', walletConfig)
|
||||
const key = `wallets_${cryptoCode}_zeroConfLimit`
|
||||
if (isNil(zeroConfLimit)) {
|
||||
if (_.isNil(zeroConfLimit)) {
|
||||
config[key] = min
|
||||
}
|
||||
}, cryptoCodes)
|
||||
|
||||
const regexp = /^cashOut_[0-9a-z]+_zeroConfLimit$/
|
||||
const keysToErase = _.keys(config).filter(key => key.match(regexp))
|
||||
const keysToErase = machines.map(machine =>
|
||||
config[`cashOut_${machine.device_id}_zeroConfLimit`] ? `cashOut_${machine.device_id}_zeroConfLimit` : null
|
||||
)
|
||||
|
||||
_.forEach(key => {
|
||||
if (_.isNil(key)) return
|
||||
config[key] = null
|
||||
}, keysToErase)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue