periodically update sanctions db

This commit is contained in:
Josh Harvey 2018-05-04 19:06:31 +03:00
parent 43ac3f5923
commit d3b7e7c2ad
3 changed files with 12 additions and 14 deletions

View file

@ -4,6 +4,8 @@ const T = require('./time')
const logger = require('./logger')
const cashOutTx = require('./cash-out/cash-out-tx')
const cashInTx = require('./cash-in/cash-in-tx')
const sanctionsUpdater = require('./ofac/update')
const sanctions = require('./ofac/index')
const INCOMING_TX_INTERVAL = 30 * T.seconds
const LIVE_INCOMING_TX_INTERVAL = 5 * T.seconds
@ -12,6 +14,7 @@ const SWEEP_HD_INTERVAL = T.minute
const TRADE_INTERVAL = 60 * T.seconds
const PONG_INTERVAL = 10 * T.seconds
const PONG_CLEAR_INTERVAL = 1 * T.day
const SANCTIONS_UPDATE_INTERVAL = 1 * T.week
const CHECK_NOTIFICATION_INTERVAL = 20 * T.seconds
@ -28,6 +31,13 @@ function reload (__settings) {
function pi () { return _pi }
function settings () { return _settings }
function updateAndLoadSanctions () {
logger.info('Updating sanctions database...')
return sanctionsUpdater.update()
.then(sanctions.load)
.then(() => logger.info('Sanctions database updated.'))
}
function start (__settings) {
reload(__settings)
@ -39,6 +49,7 @@ function start (__settings) {
cashOutTx.monitorUnnotified(settings())
pi().sweepHd()
notifier.checkNotification(pi())
updateAndLoadSanctions()
setInterval(() => pi().executeTrades(), TRADE_INTERVAL)
setInterval(() => cashOutTx.monitorLiveIncoming(settings()), LIVE_INCOMING_TX_INTERVAL)
@ -49,6 +60,7 @@ function start (__settings) {
setInterval(() => pi().pong(), PONG_INTERVAL)
setInterval(() => pi().pongClear(), PONG_CLEAR_INTERVAL)
setInterval(() => notifier.checkNotification(pi()), CHECK_NOTIFICATION_INTERVAL)
setInterval(updateAndLoadSanctions, SANCTIONS_UPDATE_INTERVAL)
}
module.exports = {start, reload}