fix startup bug where rates weren't available
This commit is contained in:
parent
5418498d06
commit
c4cbe0f6bb
3 changed files with 31 additions and 17 deletions
|
|
@ -17,3 +17,4 @@ function register (errorName) {
|
|||
}
|
||||
|
||||
register('BadNumberError')
|
||||
register('NoDataError')
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
var BigNumber = require('bignumber.js')
|
||||
var logger = require('./logger')
|
||||
|
||||
var E = require('./error')
|
||||
|
||||
var mock = false
|
||||
|
||||
var plugins
|
||||
|
|
@ -34,7 +36,7 @@ function buildRates () {
|
|||
var rates = {}
|
||||
cryptoCodes.forEach(function (cryptoCode) {
|
||||
var _rate = plugins.getDeviceRate(cryptoCode)
|
||||
if (!_rate) return
|
||||
if (!_rate) throw new E.NoDataError('No rate for ' + cryptoCode + ' yet')
|
||||
var rate = _rate.rates
|
||||
rates[cryptoCode] = {
|
||||
cashIn: rate.ask.times(cashInCommission),
|
||||
|
|
@ -51,6 +53,7 @@ function buildBalances () {
|
|||
var _balances = {}
|
||||
cryptoCodes.forEach(function (cryptoCode) {
|
||||
var balance = plugins.fiatBalance(cryptoCode)
|
||||
if (!balance) throw new E.NoDataError('No balance for ' + cryptoCode + ' yet')
|
||||
_balances[cryptoCode] = balance
|
||||
})
|
||||
|
||||
|
|
@ -65,8 +68,18 @@ function poll (req, res) {
|
|||
|
||||
logger.debug('poll request from: %s', fingerprint)
|
||||
|
||||
var rates = buildRates()
|
||||
var balances = buildBalances()
|
||||
var rates
|
||||
var balances
|
||||
|
||||
try {
|
||||
rates = buildRates()
|
||||
balances = buildBalances()
|
||||
} catch (e) {
|
||||
if (e instanceof E.NoDataError) {
|
||||
logger.debug(e)
|
||||
return res.send(500)
|
||||
}
|
||||
}
|
||||
|
||||
var config = plugins.getConfig()
|
||||
var settings = config.exchanges.settings
|
||||
|
|
|
|||
28
todo.txt
28
todo.txt
|
|
@ -1,19 +1,19 @@
|
|||
- change satoshis to crypto_atoms in db (ask neal about this)
|
||||
|
||||
- on upgrade, make sure we're not sending out lots of notifications
|
||||
- on upgrade, make sure we're not sending out lots of notifications to users
|
||||
- set notified to true on all transactions before running
|
||||
|
||||
-----------------
|
||||
- handle redeems
|
||||
- if fetchPhoneTx fails for trader, try raqia. Use record to update l-s db, and take it from there.
|
||||
- should be safe because:
|
||||
- impossible to dispense via raqia, we don't allow access anymore
|
||||
- each new fetch will hit l-s db as usual
|
||||
|
||||
If machine is polling when server starts:
|
||||
----
|
||||
|
||||
TypeError: Cannot read property 'cashIn' of undefined
|
||||
at /Users/josh/projects/lamassu-server/lib/routes.js:83:22
|
||||
at /Users/josh/projects/lamassu-server/lib/plugins.js:271:12
|
||||
at /Users/josh/projects/lamassu-server/lib/postgresql_interface.js:619:7
|
||||
at null.callback (/Users/josh/projects/lamassu-server/lib/postgresql_interface.js:129:5)
|
||||
at Query.handleReadyForQuery (/Users/josh/projects/lamassu-server/node_modules/pg/lib/query.js:89:10)
|
||||
at null.<anonymous> (/Users/josh/projects/lamassu-server/node_modules/pg/lib/client.js:163:19)
|
||||
at emitOne (events.js:82:20)
|
||||
at emit (events.js:169:7)
|
||||
at Socket.<anonymous> (/Users/josh/projects/lamassu-server/node_modules/pg/lib/connection.js:109:12)
|
||||
at emitOne (events.js:77:13)
|
||||
UTC:
|
||||
http://justatheory.com/computers/databases/postgresql/use-timestamptz.html
|
||||
|
||||
Upgrade instructions:
|
||||
|
||||
AFTER migrating, set timezone in config to 'UTC', then restart server
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue