fix sanctions db updating in app.js
This commit is contained in:
parent
5ba164e566
commit
5cc2d63d0a
4 changed files with 22 additions and 19 deletions
19
lib/app.js
19
lib/app.js
|
|
@ -9,6 +9,7 @@ const poller = require('./poller')
|
|||
const settingsLoader = require('./settings-loader')
|
||||
const options = require('./options')
|
||||
const ofac = require('./ofac/index')
|
||||
const ofacUpdate = require('./ofac/update')
|
||||
|
||||
const devMode = argv.dev || options.http
|
||||
|
||||
|
|
@ -17,6 +18,7 @@ logger.info('Version: %s', version)
|
|||
|
||||
function run () {
|
||||
let count = 0
|
||||
let handler
|
||||
|
||||
const errorHandler = err => {
|
||||
count += 1
|
||||
|
|
@ -28,14 +30,21 @@ function run () {
|
|||
.then(() => clearInterval(handler))
|
||||
.catch(errorHandler)
|
||||
|
||||
const handler = setInterval(runner, 10000)
|
||||
return runner()
|
||||
return loadSanctions()
|
||||
.then(() => { handler = setInterval(runner, 10000) })
|
||||
.then(runner)
|
||||
}
|
||||
|
||||
function loadSanctions () {
|
||||
logger.info('Loading sanctions DB...')
|
||||
return ofacUpdate.update()
|
||||
.then(() => logger.info('Sanctions DB updated'))
|
||||
.then(ofac.load)
|
||||
.then(() => logger.info('Sanctions DB loaded'))
|
||||
}
|
||||
|
||||
function runOnce () {
|
||||
logger.info('Loading sanctions DB...')
|
||||
return ofac.load()
|
||||
.then(settingsLoader.loadLatest)
|
||||
return settingsLoader.loadLatest()
|
||||
.then(settings => {
|
||||
poller.start(settings)
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ 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)
|
||||
|
|
|
|||
19
package-lock.json
generated
19
package-lock.json
generated
|
|
@ -1154,7 +1154,7 @@
|
|||
"bitcore-lib": {
|
||||
"version": "0.15.0",
|
||||
"resolved": "https://registry.npmjs.org/bitcore-lib/-/bitcore-lib-0.15.0.tgz",
|
||||
"integrity": "sha1-+SS+E4afKqt+BK7sVkKtM1m2zsI=",
|
||||
"integrity": "sha512-AeXLWhiivF6CDFzrABZHT4jJrflyylDWTi32o30rF92HW9msfuKpjzrHtFKYGa9w0kNVv5HABQjCB3OEav4PhQ==",
|
||||
"requires": {
|
||||
"bn.js": "4.11.8",
|
||||
"bs58": "4.0.1",
|
||||
|
|
@ -6404,7 +6404,7 @@
|
|||
"pg": {
|
||||
"version": "7.4.1",
|
||||
"resolved": "https://registry.npmjs.org/pg/-/pg-7.4.1.tgz",
|
||||
"integrity": "sha1-80Ecjd+faSMi/gXnAXoYiOR/ePE=",
|
||||
"integrity": "sha512-Pi5qYuXro5PAD9xXx8h7bFtmHgAQEG6/SCNyi7gS3rvb/ZQYDmxKchfB0zYtiSJNWq9iXTsYsHjrM+21eBcN1A==",
|
||||
"requires": {
|
||||
"buffer-writer": "1.0.1",
|
||||
"js-string-escape": "1.0.1",
|
||||
|
|
@ -6447,7 +6447,7 @@
|
|||
"pg-int8": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz",
|
||||
"integrity": "sha1-lDvUY79bcbQXARX4D478mgwOt4w="
|
||||
"integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw=="
|
||||
},
|
||||
"pg-native": {
|
||||
"version": "2.2.0",
|
||||
|
|
@ -6497,7 +6497,7 @@
|
|||
"pg-promise": {
|
||||
"version": "7.4.1",
|
||||
"resolved": "https://registry.npmjs.org/pg-promise/-/pg-promise-7.4.1.tgz",
|
||||
"integrity": "sha1-uyDjnS0ObUXZLwu6szidHmEXlxo=",
|
||||
"integrity": "sha512-WlELd86G2ucrFbomdn+UfOeLMeFuPd/v8qXvn0rXgcxWfuxkn1fU3nKmaEnNFuDaOykDnO4bkxL6O0vnJi+HHg==",
|
||||
"requires": {
|
||||
"manakin": "0.5.1",
|
||||
"pg": "7.4.1",
|
||||
|
|
@ -6866,11 +6866,6 @@
|
|||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz",
|
||||
"integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM="
|
||||
},
|
||||
"ramda": {
|
||||
"version": "0.22.1",
|
||||
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.22.1.tgz",
|
||||
"integrity": "sha1-Ax2gw99BfFszyWI0dX6zcDPzag4="
|
||||
},
|
||||
"randomatic": {
|
||||
"version": "1.1.7",
|
||||
"resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz",
|
||||
|
|
@ -8423,9 +8418,9 @@
|
|||
"integrity": "sha1-+OGqHuWlPsW/FR/6CXQqatdpeHY="
|
||||
},
|
||||
"winston": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/winston/-/winston-2.3.1.tgz",
|
||||
"integrity": "sha1-C0hCDZeMAYBM8CMLZIhhWYIloRk=",
|
||||
"version": "2.4.2",
|
||||
"resolved": "https://registry.npmjs.org/winston/-/winston-2.4.2.tgz",
|
||||
"integrity": "sha512-4S/Ad4ZfSNl8OccCLxnJmNISWcm2joa6Q0YGDxlxMzH0fgSwWsjMt+SmlNwCqdpaPg3ev1HKkMBsIiXeSUwpbA==",
|
||||
"requires": {
|
||||
"async": "1.0.0",
|
||||
"colors": "1.0.3",
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@
|
|||
"twilio": "^3.6.1",
|
||||
"uuid": "^3.1.0",
|
||||
"web3": "^0.19.1",
|
||||
"winston": "^2.3.0",
|
||||
"winston": "^2.4.2",
|
||||
"ws": "^3.1.0",
|
||||
"xml-stream": "^0.4.5"
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue