chore: use monorepo organization
This commit is contained in:
parent
deaf7d6ecc
commit
a687827f7e
1099 changed files with 8184 additions and 11535 deletions
|
|
@ -0,0 +1,44 @@
|
|||
const _ = require('lodash/fp')
|
||||
var db = require('../lib/db')
|
||||
const settingsLoader = require('../lib/new-settings-loader')
|
||||
const configManager = require('../lib/new-config-manager')
|
||||
|
||||
exports.up = function (next) {
|
||||
return db.tx(async t => {
|
||||
const settingsPromise = settingsLoader.loadLatestConfig()
|
||||
const machinesPromise = t.any('SELECT device_id FROM devices')
|
||||
const [config, machines] = await Promise.all([settingsPromise, machinesPromise])
|
||||
const cryptoCodes = configManager.getCryptosFromWalletNamespace(config)
|
||||
|
||||
const deviceIds = _.map(_.get('device_id'))(machines)
|
||||
const getZeroConfLimit = _.compose(_.get('zeroConfLimit'), it => configManager.getCashOut(it, config))
|
||||
const zeroConfLimits = _.map(getZeroConfLimit)(deviceIds)
|
||||
|
||||
const configMin = _.min(zeroConfLimits)
|
||||
const smallerZeroConf = _.isFinite(configMin) ? Number(configMin) : 0
|
||||
|
||||
_.forEach(cryptoCode => {
|
||||
const walletConfig = configManager.getWalletSettings(cryptoCode, config)
|
||||
const zeroConfLimit = _.get('zeroConfLimit', walletConfig)
|
||||
|
||||
if (_.isNil(zeroConfLimit)) {
|
||||
config[`wallets_${cryptoCode}_zeroConfLimit`] = smallerZeroConf
|
||||
}
|
||||
}, cryptoCodes)
|
||||
|
||||
_.forEach(deviceId => {
|
||||
const key = `cashOut_${deviceId}_zeroConfLimit`
|
||||
if (_.has(key, config)) {
|
||||
config[key] = null
|
||||
}
|
||||
})(deviceIds)
|
||||
|
||||
return settingsLoader.migrationSaveConfig(config)
|
||||
})
|
||||
.then(() => next())
|
||||
.catch(err => next(err))
|
||||
}
|
||||
|
||||
exports.down = function (next) {
|
||||
next()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue