diff --git a/src/bridge/BridgeSyncContext.js b/src/bridge/BridgeSyncContext.js index c469e20a..08b94f50 100644 --- a/src/bridge/BridgeSyncContext.js +++ b/src/bridge/BridgeSyncContext.js @@ -15,7 +15,7 @@ import { setAccountSyncState } from 'actions/bridgeSync' import { bridgeSyncSelector, syncStateLocalSelector } from 'reducers/bridgeSync' import type { BridgeSyncState } from 'reducers/bridgeSync' import { accountsSelector } from 'reducers/accounts' -import { SYNC_BOOT_DELAY, SYNC_ALL_INTERVAL } from 'config/constants' +import { SYNC_BOOT_DELAY, SYNC_ALL_INTERVAL, SYNC_MAX_CONCURRENT } from 'config/constants' import { getBridgeForCurrency } from '.' type BridgeSyncProviderProps = { @@ -87,7 +87,7 @@ class Provider extends Component { }) } - const syncQueue = priorityQueue(synchronize, 2) + const syncQueue = priorityQueue(synchronize, SYNC_MAX_CONCURRENT) let skipUnderPriority: number = -1 diff --git a/src/bridge/LibcoreBridge.js b/src/bridge/LibcoreBridge.js index ffe8f8b5..9823a762 100644 --- a/src/bridge/LibcoreBridge.js +++ b/src/bridge/LibcoreBridge.js @@ -1,5 +1,4 @@ // @flow -import logger from 'logger' import React from 'react' import { Observable } from 'rxjs' import { map } from 'rxjs/operators' @@ -101,7 +100,7 @@ const LibcoreBridge: WalletBridge = { })() return { unsubscribe() { - logger.warn('LibcoreBridge: unsub sync not implemented') + // LibcoreBridge: unsub sync not currently implemented }, } }), diff --git a/src/config/constants.js b/src/config/constants.js index 90be4ff9..5b69bf85 100644 --- a/src/config/constants.js +++ b/src/config/constants.js @@ -1,12 +1,20 @@ // @flow +const intFromEnv = (key: string, def: number) => { + const v = process.env[key] + if (!isNaN(v)) return parseInt(v, 10) + return def +} + +export const SYNC_MAX_CONCURRENT = intFromEnv('LEDGER_SYNC_MAX_CONCURRENT', 2) export const SYNC_BOOT_DELAY = 2 * 1000 export const SYNC_ALL_INTERVAL = 60 * 1000 + export const CHECK_APP_INTERVAL_WHEN_INVALID = 600 export const CHECK_APP_INTERVAL_WHEN_VALID = 1200 export const CHECK_UPDATE_DELAY = 5e3 -export const DEVICE_DISCONNECT_DEBOUNCE = 1000 +export const DEVICE_DISCONNECT_DEBOUNCE = intFromEnv('LEDGER_DEVICE_DISCONNECT_DEBOUNCE', 1000) export const MODAL_ADD_ACCOUNT = 'MODAL_ADD_ACCOUNT' export const MODAL_OPERATION_DETAILS = 'MODAL_OPERATION_DETAILS' diff --git a/src/helpers/withLibcore.js b/src/helpers/withLibcore.js index 37a9c49d..a2c966a5 100644 --- a/src/helpers/withLibcore.js +++ b/src/helpers/withLibcore.js @@ -1,12 +1,10 @@ // @flow import invariant from 'invariant' -import logger from 'logger' const core = require('@ledgerhq/ledger-core') let walletPoolInstance: ?Object = null -let queue = Promise.resolve() // TODO: `core` and `NJSWalletPool` should be typed type Job = (Object, Object) => Promise @@ -21,11 +19,5 @@ export default function withLibcore(job: Job): Promise { const walletPool = walletPoolInstance invariant(walletPool, 'core.instanciateWalletPool returned null !!') - const p = queue.then(() => job(core, walletPool)) - - queue = p.catch(e => { - logger.warn(`withLibCore: Error in job`, e) - }) - - return p + return job(core, walletPool) }