feat: add blockchain status getter to all daemons
This commit is contained in:
parent
75cb094476
commit
2819b8a519
11 changed files with 107 additions and 16 deletions
|
|
@ -9,6 +9,8 @@ const _ = require('lodash/fp')
|
|||
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
const options = require('../options')
|
||||
const settingsLoader = require('../new-settings-loader')
|
||||
const wallet = require('../wallet')
|
||||
|
||||
const common = require('./common')
|
||||
const doVolume = require('./do-volume')
|
||||
|
|
@ -112,9 +114,19 @@ function plugin (crypto) {
|
|||
return plugin
|
||||
}
|
||||
|
||||
function getSyncedBlockchains (cryptoList) {
|
||||
function getBlockchainSyncStatus (cryptoList) {
|
||||
const installedCryptos = _.reduce((acc, value) => ({ ...acc, [value.cryptoCode]: isInstalledSoftware(value) && isInstalledVolume(value) }), {}, cryptoList)
|
||||
const syncedBlockchains = plugin()
|
||||
|
||||
return settingsLoader.loadLatest()
|
||||
.then(settings => {
|
||||
const blockchainStatuses = _.reduce((acc, value) =>
|
||||
_.includes(value.cryptoCode, _.keys(installedCryptos) ? ({ ...acc, [value.cryptoCode]: wallet.checkBlockchainStatus(settings, value.cryptoCode) }) : ({ ...acc })),
|
||||
{},
|
||||
cryptoList
|
||||
)
|
||||
|
||||
return blockchainStatuses
|
||||
})
|
||||
}
|
||||
|
||||
function run () {
|
||||
|
|
@ -137,14 +149,17 @@ function run () {
|
|||
questions.push({
|
||||
type: 'checkbox',
|
||||
name: 'crypto',
|
||||
message: 'Which cryptocurrencies would you like to install?\nTo prevent server resource overloading, only TWO coins should be installed simultaneously.\nMore coins can be installed after this process is over.',
|
||||
message: 'Which cryptocurrencies would you like to install?\nTo prevent server resource overloading, only TWO coins should be syncing simultaneously.\nMore coins can be installed after this process is over.',
|
||||
choices,
|
||||
validate: (a) => {
|
||||
getSyncedBlockchains(cryptos)
|
||||
return _.size(a) > 0 && _.size(a) <= 2
|
||||
return getBlockchainSyncStatus(cryptos)
|
||||
.then(chains => {
|
||||
const result = _.reduce((acc, value) => ({ ...acc, [value]: _.isNil() ? 1 : acc[value] + 1 }), {}, _.values(chains))
|
||||
return result.syncing > 0 || _.size(a) > 0 && _.size(a) <= 2
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
inquirer.prompt(questions)
|
||||
.then(answers => console.log('answers', answers) /* processCryptos(answers.crypto) */)
|
||||
.then(answers => processCryptos(answers.crypto))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue