refactor: save CCXT ticker instance
This commit is contained in:
parent
7ddda20364
commit
4747e0b7f6
1 changed files with 6 additions and 1 deletions
|
|
@ -6,8 +6,13 @@ const { getRate } = require('../../../lib/forex')
|
|||
|
||||
const RETRIES = 2
|
||||
|
||||
const tickerObjects = {}
|
||||
|
||||
function ticker (fiatCode, cryptoCode, tickerName) {
|
||||
const ticker = new ccxt[tickerName]({ timeout: 3000 })
|
||||
const ticker = tickerObjects[tickerName] ?
|
||||
tickerObjects[tickerName] :
|
||||
tickerObjects[tickerName] = new ccxt[tickerName]({ timeout: 3000 })
|
||||
|
||||
if (verifyFiatSupport(fiatCode, tickerName)) {
|
||||
return getCurrencyRates(ticker, fiatCode, cryptoCode)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue