kraken plugin WIP

This commit is contained in:
Josh Harvey 2016-03-28 00:52:15 +02:00
parent fd4e5b5f34
commit 7be7c3f8e6
3 changed files with 74 additions and 9 deletions

View file

@ -63,8 +63,12 @@ function loadPlugin (name, config) {
try {
plugin = require('lamassu-' + name)
} catch (_) {
throw new Error(name + ' module is not installed. ' +
'Try running \'npm install --save lamassu-' + name + '\' first')
try {
require('plugins/' + name)
} catch (_) {
throw new Error(name + ' module is not installed. ' +
'Try running \'npm install --save lamassu-' + name + '\' first')
}
}
// each plugin MUST implement those
@ -116,8 +120,7 @@ function loadOrConfigPlugin (pluginHandle, pluginType, cryptoCoin, currency,
if (!currentName) pluginHandle = null
else { // some plugins may be disabled
var pluginConfig = cachedConfig.exchanges.plugins.settings[currentName] ||
{}
var pluginConfig = cachedConfig.exchanges.plugins.settings[currentName] || {}
if (currency) pluginConfig.currency = currency
@ -448,7 +451,14 @@ function pollRate (cryptoCoin, cb) {
logger.debug('[%s] polling for rates (%s)', cryptoCoin, tickerPlugin.NAME)
var tickerPlugin = tickerPlugins[cryptoCoin]
tickerPlugin.ticker(deviceCurrency, function (err, resRates) {
var currencies = deviceCurrency
if (typeof currencies === 'string') currencies = [currencies]
var tickerF = cryptoCoin === 'BTC'
? async.apply(tickerPlugin.ticker, currencies)
: async.apply(tickerPlugin.ticker, currencies, cryptoCoin)
tickerF(function (err, resRates) {
if (err) {
logger.error(err)
return cb && cb(err)