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('BadNumberError')
|
||||||
|
register('NoDataError')
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
var BigNumber = require('bignumber.js')
|
var BigNumber = require('bignumber.js')
|
||||||
var logger = require('./logger')
|
var logger = require('./logger')
|
||||||
|
|
||||||
|
var E = require('./error')
|
||||||
|
|
||||||
var mock = false
|
var mock = false
|
||||||
|
|
||||||
var plugins
|
var plugins
|
||||||
|
|
@ -34,7 +36,7 @@ function buildRates () {
|
||||||
var rates = {}
|
var rates = {}
|
||||||
cryptoCodes.forEach(function (cryptoCode) {
|
cryptoCodes.forEach(function (cryptoCode) {
|
||||||
var _rate = plugins.getDeviceRate(cryptoCode)
|
var _rate = plugins.getDeviceRate(cryptoCode)
|
||||||
if (!_rate) return
|
if (!_rate) throw new E.NoDataError('No rate for ' + cryptoCode + ' yet')
|
||||||
var rate = _rate.rates
|
var rate = _rate.rates
|
||||||
rates[cryptoCode] = {
|
rates[cryptoCode] = {
|
||||||
cashIn: rate.ask.times(cashInCommission),
|
cashIn: rate.ask.times(cashInCommission),
|
||||||
|
|
@ -51,6 +53,7 @@ function buildBalances () {
|
||||||
var _balances = {}
|
var _balances = {}
|
||||||
cryptoCodes.forEach(function (cryptoCode) {
|
cryptoCodes.forEach(function (cryptoCode) {
|
||||||
var balance = plugins.fiatBalance(cryptoCode)
|
var balance = plugins.fiatBalance(cryptoCode)
|
||||||
|
if (!balance) throw new E.NoDataError('No balance for ' + cryptoCode + ' yet')
|
||||||
_balances[cryptoCode] = balance
|
_balances[cryptoCode] = balance
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -65,8 +68,18 @@ function poll (req, res) {
|
||||||
|
|
||||||
logger.debug('poll request from: %s', fingerprint)
|
logger.debug('poll request from: %s', fingerprint)
|
||||||
|
|
||||||
var rates = buildRates()
|
var rates
|
||||||
var balances = buildBalances()
|
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 config = plugins.getConfig()
|
||||||
var settings = config.exchanges.settings
|
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)
|
- 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
|
UTC:
|
||||||
at /Users/josh/projects/lamassu-server/lib/routes.js:83:22
|
http://justatheory.com/computers/databases/postgresql/use-timestamptz.html
|
||||||
at /Users/josh/projects/lamassu-server/lib/plugins.js:271:12
|
|
||||||
at /Users/josh/projects/lamassu-server/lib/postgresql_interface.js:619:7
|
Upgrade instructions:
|
||||||
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)
|
AFTER migrating, set timezone in config to 'UTC', then restart server
|
||||||
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)
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue