Merge pull request #1354 from chaotixkilla/fix-block-xmr-zec-simultaneous-installs
Disallow ZEC and XMR being installed simultaneously
This commit is contained in:
commit
9439189c5c
1 changed files with 28 additions and 5 deletions
|
|
@ -138,19 +138,33 @@ function getBlockchainSyncStatus (cryptoList) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isInstalled (crypto) {
|
||||||
|
return isInstalledSoftware(crypto) && isInstalledVolume(crypto)
|
||||||
|
}
|
||||||
|
|
||||||
|
function isDisabled (crypto) {
|
||||||
|
switch (crypto.cryptoCode) {
|
||||||
|
case 'ETH':
|
||||||
|
return 'Use admin\'s Infura plugin'
|
||||||
|
case 'ZEC':
|
||||||
|
return isInstalled(crypto) && 'Installed' || isInstalled(_.find(it => it.code === 'monero', cryptos)) && 'Insufficient resources. Contact support.'
|
||||||
|
case 'XMR':
|
||||||
|
return isInstalled(crypto) && 'Installed' || isInstalled(_.find(it => it.code === 'zcash', cryptos)) && 'Insufficient resources. Contact support.'
|
||||||
|
default:
|
||||||
|
return isInstalled(crypto) && 'Installed'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function run () {
|
function run () {
|
||||||
const choices = _.flow([
|
const choices = _.flow([
|
||||||
_.filter(c => c.type !== 'erc-20'),
|
_.filter(c => c.type !== 'erc-20'),
|
||||||
_.map(c => {
|
_.map(c => {
|
||||||
const checked = isInstalledSoftware(c) && isInstalledVolume(c)
|
|
||||||
const name = c.code === 'ethereum' ? 'Ethereum and/or USDT' : c.display
|
const name = c.code === 'ethereum' ? 'Ethereum and/or USDT' : c.display
|
||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
value: c.code,
|
value: c.code,
|
||||||
checked,
|
checked: isInstalled(c),
|
||||||
disabled: c.cryptoCode === 'ETH'
|
disabled: isDisabled(c)
|
||||||
? 'Use admin\'s Infura plugin'
|
|
||||||
: checked && 'Installed'
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
])(cryptos)
|
])(cryptos)
|
||||||
|
|
@ -159,6 +173,15 @@ function run () {
|
||||||
|
|
||||||
const validateAnswers = async (answers) => {
|
const validateAnswers = async (answers) => {
|
||||||
if (_.size(answers) > 2) return { message: `Please insert a maximum of two coins to install.`, isValid: false }
|
if (_.size(answers) > 2) return { message: `Please insert a maximum of two coins to install.`, isValid: false }
|
||||||
|
|
||||||
|
if (
|
||||||
|
_.isEmpty(_.difference(['monero', 'zcash'], answers)) ||
|
||||||
|
(_.includes('monero', answers) && isInstalled(_.find(it => it.code === 'zcash', cryptos))) ||
|
||||||
|
(_.includes('zcash', answers) && isInstalled(_.find(it => it.code === 'monero', cryptos)))
|
||||||
|
) {
|
||||||
|
return { message: `Zcash and Monero installations are temporarily mutually exclusive, given the space needed for their blockchains. Contact support for more information.`, isValid: false }
|
||||||
|
}
|
||||||
|
|
||||||
return getBlockchainSyncStatus(cryptos)
|
return getBlockchainSyncStatus(cryptos)
|
||||||
.then(blockchainStatuses => {
|
.then(blockchainStatuses => {
|
||||||
const result = _.reduce((acc, value) => ({ ...acc, [value]: _.isNil(acc[value]) ? 1 : acc[value] + 1 }), {}, _.values(blockchainStatuses))
|
const result = _.reduce((acc, value) => ({ ...acc, [value]: _.isNil(acc[value]) ? 1 : acc[value] + 1 }), {}, _.values(blockchainStatuses))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue