improve transaction expiration

This commit is contained in:
Josh Harvey 2016-05-10 14:03:13 +03:00
parent 7f33e87c21
commit 996ebd395b
3 changed files with 27 additions and 14 deletions

View file

@ -25,6 +25,7 @@ var STALE_INCOMING_TX_AGE = 7 * 24 * 60 * 60 * 1000
var UNNOTIFIED_INTERVAL = 60 * 1000
var MAX_NOTIFY_AGE = 48 * 60 * 60 * 1000
var MIN_NOTIFY_AGE = 5 * 60 * 1000
var TRANSACTION_EXPIRATION = 48 * 60 * 60 * 1000
if (argv.timeout) PENDING_TIMEOUT = argv.timeout / 1000
@ -457,8 +458,9 @@ function processTxStatus (tx) {
var status = res.status
if (tx.status === status) return resolve()
db.updateTxStatus(tx, status, function (_err) {
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()
})
@ -804,7 +806,7 @@ exports.registerRedeem = function registerRedeem (session) {
}
exports.fetchPhoneTx = function fetchPhoneTx (phone) {
db.fetchPhoneTxs(phone)
db.fetchPhoneTxs(phone, TRANSACTION_EXPIRATION)
.then(txs => {
const authorizedTxs = txs.filter(tx => tx.authorized)
if (authorizedTxs.length > 0) {