cleanup
This commit is contained in:
parent
8a4b447db3
commit
e930925818
5 changed files with 15 additions and 31 deletions
|
|
@ -347,8 +347,6 @@ function reapTxs () {
|
|||
|
||||
// TODO: Run these in parallel and return success
|
||||
exports.trade = function trade (session, rawTrade, cb) {
|
||||
logger.debug('DEBUG2')
|
||||
|
||||
// TODO: move this to DB, too
|
||||
// add bill to trader queue (if trader is enabled)
|
||||
var cryptoCode = rawTrade.cryptoCode || 'BTC'
|
||||
|
|
@ -363,16 +361,12 @@ exports.trade = function trade (session, rawTrade, cb) {
|
|||
})
|
||||
}
|
||||
|
||||
logger.debug('DEBUG3')
|
||||
|
||||
if (!rawTrade.toAddress) {
|
||||
var newRawTrade = _.cloneDeep(rawTrade)
|
||||
newRawTrade.toAddress = 'remit'
|
||||
return db.recordBill(session, newRawTrade, cb)
|
||||
}
|
||||
|
||||
logger.debug('DEBUG1')
|
||||
|
||||
async.parallel([
|
||||
async.apply(db.addOutgoingPending, session, rawTrade.currency, rawTrade.cryptoCode, rawTrade.toAddress),
|
||||
async.apply(db.recordBill, session, rawTrade)
|
||||
|
|
@ -391,7 +385,6 @@ exports.stateChange = function stateChange (session, rec, cb) {
|
|||
}
|
||||
|
||||
exports.recordPing = function recordPing (session, rec, cb) {
|
||||
console.log('DEBUG4')
|
||||
var event = {
|
||||
id: uuid.v4(),
|
||||
fingerprint: session.fingerprint,
|
||||
|
|
@ -640,11 +633,7 @@ exports.getcryptoCodes = function getcryptoCodes () {
|
|||
}
|
||||
|
||||
function sendMessage (rec) {
|
||||
console.log('DEBUG50')
|
||||
console.log('%j', rec)
|
||||
console.log(cachedConfig.exchanges.plugins.current.notify)
|
||||
var pluginTypes = JSON.parse(cachedConfig.exchanges.plugins.current.notify)
|
||||
console.log(pluginTypes)
|
||||
var pluginPromises = pluginTypes.map(function (pluginType) {
|
||||
if (pluginType === 'email') return emailPlugin.sendMessage(rec)
|
||||
if (pluginType === 'sms') return smsPlugin.sendMessage(rec)
|
||||
|
|
@ -669,27 +658,20 @@ function sendNoAlerts () {
|
|||
}
|
||||
|
||||
function checkNotification () {
|
||||
console.log('DEBUG39 ******************************')
|
||||
return notifier.checkStatus()
|
||||
.then(function (alertRec) {
|
||||
console.log('DEBUG41 ******************************')
|
||||
var fingerprint = notifier.alertFingerprint(alertRec)
|
||||
if (!fingerprint) {
|
||||
console.log('DEBUG40 ******************************')
|
||||
var inAlert = !!alertFingerprint
|
||||
alertFingerprint = null
|
||||
lastAlertTime = null
|
||||
if (inAlert) return sendNoAlerts()
|
||||
}
|
||||
|
||||
console.log('DEBUG42 ******************************')
|
||||
|
||||
var alertChanged = fingerprint === alertFingerprint &&
|
||||
lastAlertTime - Date.now() < ALERT_SEND_INTERVAL
|
||||
if (alertChanged) return
|
||||
|
||||
console.log('DEBUG43 ******************************')
|
||||
|
||||
var subject = notifier.alertSubject(alertRec)
|
||||
var rec = {
|
||||
sms: {
|
||||
|
|
@ -702,6 +684,7 @@ function checkNotification () {
|
|||
}
|
||||
alertFingerprint = fingerprint
|
||||
lastAlertTime = Date.now()
|
||||
|
||||
return sendMessage(rec)
|
||||
})
|
||||
.then(function () {
|
||||
|
|
@ -727,7 +710,8 @@ function checkBalances () {
|
|||
}
|
||||
|
||||
exports.startCheckingNotification = function startCheckingNotification () {
|
||||
notifier.init(db, checkBalances)
|
||||
var config = cachedConfig.exchanges.plugins.settings.notifier
|
||||
notifier.init(db, checkBalances, config)
|
||||
checkNotification()
|
||||
setInterval(checkNotification, CHECK_NOTIFICATION_INTERVAL)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue