WIP
This commit is contained in:
parent
7055104218
commit
98e863d31d
4 changed files with 109 additions and 199 deletions
|
|
@ -373,7 +373,7 @@ exports.cashOut = function cashOut (session, tx, cb) {
|
|||
}
|
||||
|
||||
exports.dispenseAck = function dispenseAck (session, rec) {
|
||||
db.addDispense(session, rec.tx, rec.cartridges)
|
||||
return db.addDispense(session, rec.tx, rec.cartridges)
|
||||
}
|
||||
|
||||
exports.fiatBalance = function fiatBalance (cryptoCode) {
|
||||
|
|
@ -413,10 +413,7 @@ function processTxStatus (tx) {
|
|||
if (tx.status === status) return resolve()
|
||||
const confirm = (status === 'instant' && tx.status !== 'confirmed') ||
|
||||
(status === 'confirmed' && tx.status !== 'instant')
|
||||
db.updateTxStatus(tx, status, confirm, function (_err) {
|
||||
if (_err) logger.error(err)
|
||||
resolve()
|
||||
})
|
||||
db.updateTxStatus(tx, status, confirm).then(resolve).catch(reject)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
@ -438,25 +435,22 @@ function notifyConfirmation (tx) {
|
|||
|
||||
function monitorLiveIncoming () {
|
||||
const statuses = ['notSeen', 'published', 'insufficientFunds']
|
||||
db.fetchOpenTxs(statuses, STALE_INCOMING_TX_AGE, function (err, txs) {
|
||||
if (err) return
|
||||
txs.forEach(processTxStatus)
|
||||
})
|
||||
db.fetchOpenTxs(statuses, STALE_INCOMING_TX_AGE)
|
||||
.then(txs => txs.forEach(processTxStatus))
|
||||
.catch(err => logger.error(err))
|
||||
}
|
||||
|
||||
function monitorIncoming () {
|
||||
const statuses = ['notSeen', 'published', 'authorized', 'instant', 'rejected', 'insufficientFunds']
|
||||
db.fetchOpenTxs(statuses, STALE_INCOMING_TX_AGE, function (err, txs) {
|
||||
if (err) return
|
||||
txs.forEach(processTxStatus)
|
||||
})
|
||||
db.fetchOpenTxs(statuses, STALE_INCOMING_TX_AGE)
|
||||
.then(txs => txs.forEach(processTxStatus))
|
||||
.catch(err => logger.error(err))
|
||||
}
|
||||
|
||||
function monitorUnnotified () {
|
||||
db.fetchUnnotifiedTxs(MAX_NOTIFY_AGE, MIN_NOTIFY_AGE, function (err, txs) {
|
||||
if (err) return
|
||||
txs.forEach(notifyConfirmation)
|
||||
})
|
||||
db.fetchUnnotifiedTxs(MAX_NOTIFY_AGE, MIN_NOTIFY_AGE)
|
||||
.then(txs => txs.forEach(notifyConfirmation))
|
||||
.catch(err => logger.error(err))
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -776,8 +770,8 @@ exports.fetchTx = function fetchTx (session) {
|
|||
return db.fetchTx(session)
|
||||
}
|
||||
|
||||
exports.requestDispense = function requestDispense (session, tx) {
|
||||
return db.addDispenseRequest(session, tx)
|
||||
exports.requestDispense = function requestDispense (tx) {
|
||||
return db.addDispenseRequest(tx)
|
||||
}
|
||||
|
||||
exports.cachedResponse = function (session, path, method) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue