fix promise stuff; fix db crypto/fiat bug
This commit is contained in:
parent
a0961ce2e2
commit
f17cfdfaa9
3 changed files with 30 additions and 24 deletions
|
|
@ -398,6 +398,7 @@ function processTxStatus (tx) {
|
|||
const cryptoCode = tx.cryptoCode
|
||||
const walletPlugin = walletPlugins[cryptoCode]
|
||||
|
||||
if (!walletPlugin) throw new Error('No wallet plugins for: ' + cryptoCode)
|
||||
walletPlugin.getStatus(tx.toAddress, tx.cryptoAtoms, function (err, res) {
|
||||
if (err) {
|
||||
logger.error(err)
|
||||
|
|
@ -406,6 +407,7 @@ function processTxStatus (tx) {
|
|||
|
||||
var status = res.status
|
||||
if (tx.status === status) return resolve()
|
||||
|
||||
const confirm = (status === 'instant' && tx.status !== 'confirmed') ||
|
||||
(status === 'confirmed' && tx.status !== 'instant')
|
||||
db.updateTxStatus(tx, status, confirm).then(resolve).catch(reject)
|
||||
|
|
@ -431,20 +433,20 @@ function notifyConfirmation (tx) {
|
|||
function monitorLiveIncoming () {
|
||||
const statuses = ['notSeen', 'published', 'insufficientFunds']
|
||||
db.fetchOpenTxs(statuses, STALE_INCOMING_TX_AGE)
|
||||
.then(txs => txs.forEach(processTxStatus))
|
||||
.then(txs => Promise.all(txs.map(processTxStatus)))
|
||||
.catch(err => logger.error(err))
|
||||
}
|
||||
|
||||
function monitorIncoming () {
|
||||
const statuses = ['notSeen', 'published', 'authorized', 'instant', 'rejected', 'insufficientFunds']
|
||||
db.fetchOpenTxs(statuses, STALE_INCOMING_TX_AGE)
|
||||
.then(txs => txs.forEach(processTxStatus))
|
||||
.then(txs => Promise.all(txs.map(processTxStatus)))
|
||||
.catch(err => logger.error(err))
|
||||
}
|
||||
|
||||
function monitorUnnotified () {
|
||||
db.fetchUnnotifiedTxs(MAX_NOTIFY_AGE, MIN_NOTIFY_AGE)
|
||||
.then(txs => txs.forEach(notifyConfirmation))
|
||||
.then(txs => Promise.all(txs.map(notifyConfirmation)))
|
||||
.catch(err => logger.error(err))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue