From f62e65fe935d745588a2288f87f23d74b602eddd Mon Sep 17 00:00:00 2001 From: Josh Harvey Date: Mon, 26 Sep 2016 17:22:46 +0300 Subject: [PATCH] WIPP --- jsconfig.json | 16 +++++++++++++ lib/plugins.js | 3 +++ todo.txt | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 jsconfig.json diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 00000000..0136d6f2 --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,16 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=759670 + // for the documentation about the jsconfig.json format + "compilerOptions": { + "target": "es6", + "module": "commonjs", + "allowSyntheticDefaultImports": true + }, + "exclude": [ + "node_modules", + "bower_components", + "jspm_packages", + "tmp", + "temp" + ] +} diff --git a/lib/plugins.js b/lib/plugins.js index ab634258..a315a039 100644 --- a/lib/plugins.js +++ b/lib/plugins.js @@ -11,6 +11,7 @@ const db = require('./postgresql_interface') const logger = require('./logger') const notifier = require('./notifier') const T = require('./time') +const config = require('./config') const tradeIntervals = {} @@ -178,6 +179,8 @@ exports.configure = function configure (config) { cryptoCodes = config.crypto.cryptoCurrencies cryptoCodes.forEach(cryptoCode => { + cryptoScopedConfig = config.cryptoScoped(cryptoCode, cachedConfig) + // TICKER [required] configure (or load) loadOrConfigPlugin( tickerPlugins[cryptoCode], diff --git a/todo.txt b/todo.txt index 38dd2c36..02efd89a 100644 --- a/todo.txt +++ b/todo.txt @@ -25,3 +25,67 @@ schemas: v update migrate-config to match lamassu.json schema - update machine name + +--------------------------- + +- are plugins loaded globally or per machine? +- list all used plugins: + ticker, trade, wallet, info (?), idVerifier, email, sms + + +- wallet doesn't care about fiat + +- look into how each plugin is used + - info plugin not used + +- need either transitive closure of all cryptos accross machines, + or add new plugin when needed +- currently we're looking at all cryptos, so this is probably easier + + +- different machines can have different coins, currencies, etc + - necessitates different plugins + +- do plugins require initialization and state? + probably not + +- require caches, so probably not big penalty to require whenever a plugin is needed + +- essentially, plugins just need their account info, plus some additional + special info, such as masterSeed, fiatCurrencies, etc + +- deviceCurrency needs to be fixed. currently we're assuming one currency + globally + +load ticker plugin (not really, remove this), pollRate (can supply actual deviceCurrency), + purchase/trader (also device specific), consolidateTrades (see what calls this), + checkBalances (*check callee) + +* pollRate -- this sets lastRates which is keyed by crypto only, may need + to be keyed by fiat as well; probably better to fetch on demand, with throttle + see: https://github.com/sindresorhus/mem + +* consolidateTrades: one trader for each crypto, or separate per crypto/fiat? + does consolidateTrades need fiat currency at all? even so, shouldn't this + be in the trade record? + +example: operator may have machines in US and China; might want different exchanges + for china machines; same for ticker + +options: configure per machine; configure per crypto/fiat + - crypto/fiat requires more admin dev work design + - also restricts configurability + - but global ticker/exchange doesn't make sense if fiats are different + - which means it would be required to define ticker/exchange for each + machine, even if they all have the same crypto/fiat + +* checkBalances: used for notifier, to indicate if balances are too low; + how to do this generalized across all machines/currencies? + +* possibly configure home currency for admin; probably a good idea for + transactions, statistics, etc + +-> For now, keep it as is -- one exchange per crypto, see how we handle fiat + currencies now. (passed in on trade -- we assume that we're using machine currency, which may not be true) + +- consider defining exchange fiat currency in exchange account config, we don't pass in fiat amount, anyway