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
|
|
@ -123,6 +123,12 @@ function supportsBatching (cryptoCode) {
|
|||
.then(() => SUPPORTS_BATCHING)
|
||||
}
|
||||
|
||||
function checkBlockchainStatus (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => fetch('getblockchaininfo'))
|
||||
.then(res => !!res['initialblockdownload'] ? 'ready' : 'syncing')
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
balance,
|
||||
sendCoins,
|
||||
|
|
@ -130,5 +136,6 @@ module.exports = {
|
|||
getStatus,
|
||||
newFunding,
|
||||
cryptoNetwork,
|
||||
supportsBatching
|
||||
supportsBatching,
|
||||
checkBlockchainStatus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,5 +192,6 @@ module.exports = {
|
|||
fetchRBF,
|
||||
estimateFee,
|
||||
sendCoinsBatch,
|
||||
supportsBatching
|
||||
supportsBatching,
|
||||
checkBlockchainStatus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,6 +164,11 @@ function supportsBatching (cryptoCode) {
|
|||
.then(() => SUPPORTS_BATCHING)
|
||||
}
|
||||
|
||||
function checkBlockchainStatus (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => Promise.resolve('ready'))
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
NAME,
|
||||
balance,
|
||||
|
|
@ -172,5 +177,6 @@ module.exports = {
|
|||
getStatus,
|
||||
newFunding,
|
||||
cryptoNetwork,
|
||||
supportsBatching
|
||||
supportsBatching,
|
||||
checkBlockchainStatus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,11 +118,18 @@ function supportsBatching (cryptoCode) {
|
|||
.then(() => SUPPORTS_BATCHING)
|
||||
}
|
||||
|
||||
function checkBlockchainStatus (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => fetch('getblockchaininfo'))
|
||||
.then(res => !!res['initialblockdownload'] ? 'ready' : 'syncing')
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
balance,
|
||||
sendCoins,
|
||||
newAddress,
|
||||
getStatus,
|
||||
newFunding,
|
||||
supportsBatching
|
||||
supportsBatching,
|
||||
checkBlockchainStatus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ module.exports = {
|
|||
privateKey,
|
||||
isStrictAddress,
|
||||
connect,
|
||||
supportsBatching
|
||||
supportsBatching,
|
||||
checkBlockchainStatus
|
||||
}
|
||||
|
||||
function connect (url) {
|
||||
|
|
@ -230,3 +231,9 @@ function supportsBatching (cryptoCode) {
|
|||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => SUPPORTS_BATCHING)
|
||||
}
|
||||
|
||||
function checkBlockchainStatus (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(pify(web3.eth.isSyncing))
|
||||
.then(res => _.isObject(res) ? 'syncing' : 'ready')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,11 +118,18 @@ function supportsBatching (cryptoCode) {
|
|||
.then(() => SUPPORTS_BATCHING)
|
||||
}
|
||||
|
||||
function checkBlockchainStatus (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => fetch('getblockchaininfo'))
|
||||
.then(res => !!res['initialblockdownload'] ? 'ready' : 'syncing')
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
balance,
|
||||
sendCoins,
|
||||
newAddress,
|
||||
getStatus,
|
||||
newFunding,
|
||||
supportsBatching
|
||||
supportsBatching,
|
||||
checkBlockchainStatus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,6 +115,11 @@ function supportsBatching (cryptoCode) {
|
|||
return Promise.resolve(_.includes(cryptoCode, BATCHABLE_COINS))
|
||||
}
|
||||
|
||||
function checkBlockchainStatus (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => Promise.resolve('ready'))
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
NAME,
|
||||
balance,
|
||||
|
|
@ -123,5 +128,6 @@ module.exports = {
|
|||
newAddress,
|
||||
getStatus,
|
||||
newFunding,
|
||||
supportsBatching
|
||||
supportsBatching,
|
||||
checkBlockchainStatus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -205,6 +205,27 @@ function supportsBatching (cryptoCode) {
|
|||
.then(() => SUPPORTS_BATCHING)
|
||||
}
|
||||
|
||||
function checkBlockchainStatus (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => {
|
||||
try {
|
||||
const config = jsonRpc.parseConf(configPath)
|
||||
|
||||
// Daemon uses a different connection of the wallet
|
||||
const rpcConfig = {
|
||||
username: config['rpc-login'].split(':')[0],
|
||||
password: config['rpc-login'].split(':')[1],
|
||||
port: cryptoRec.defaultPort
|
||||
}
|
||||
|
||||
return jsonRpc.fetchDigest(rpcConfig, 'get_info')
|
||||
.then(res => !!res.synchronized ? 'ready' : 'syncing')
|
||||
} catch (err) {
|
||||
throw new Error('XMR daemon is currently not installed')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
balance,
|
||||
sendCoins,
|
||||
|
|
@ -212,5 +233,6 @@ module.exports = {
|
|||
getStatus,
|
||||
newFunding,
|
||||
cryptoNetwork,
|
||||
supportsBatching
|
||||
supportsBatching,
|
||||
checkBlockchainStatus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -144,11 +144,18 @@ function supportsBatching (cryptoCode) {
|
|||
.then(() => SUPPORTS_BATCHING)
|
||||
}
|
||||
|
||||
function checkBlockchainStatus (cryptoCode) {
|
||||
return checkCryptoCode(cryptoCode)
|
||||
.then(() => fetch('getblockchaininfo'))
|
||||
.then(res => !!res['initial_block_download_complete'] ? 'ready' : 'syncing')
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
balance,
|
||||
sendCoins,
|
||||
newAddress,
|
||||
getStatus,
|
||||
newFunding,
|
||||
supportsBatching
|
||||
supportsBatching,
|
||||
checkBlockchainStatus
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue