Browse Source
Merge pull request #488 from gre/remove-libcore-queue
Libcore no longer need to run in queue
master
Meriadec Pillet
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
13 additions and
14 deletions
-
src/bridge/BridgeSyncContext.js
-
src/bridge/LibcoreBridge.js
-
src/config/constants.js
-
src/helpers/withLibcore.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<BridgeSyncProviderOwnProps, Sync> { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
const syncQueue = priorityQueue(synchronize, 2) |
|
|
|
const syncQueue = priorityQueue(synchronize, SYNC_MAX_CONCURRENT) |
|
|
|
|
|
|
|
let skipUnderPriority: number = -1 |
|
|
|
|
|
|
|
|
|
@ -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<Transaction> = { |
|
|
|
})() |
|
|
|
return { |
|
|
|
unsubscribe() { |
|
|
|
logger.warn('LibcoreBridge: unsub sync not implemented') |
|
|
|
// LibcoreBridge: unsub sync not currently implemented
|
|
|
|
}, |
|
|
|
} |
|
|
|
}), |
|
|
|
|
|
@ -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 = 500 |
|
|
|
export const DEVICE_DISCONNECT_DEBOUNCE = intFromEnv('LEDGER_DEVICE_DISCONNECT_DEBOUNCE', 500) |
|
|
|
|
|
|
|
export const MODAL_ADD_ACCOUNT = 'MODAL_ADD_ACCOUNT' |
|
|
|
export const MODAL_OPERATION_DETAILS = 'MODAL_OPERATION_DETAILS' |
|
|
|
|
|
@ -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<A> = (Object, Object) => Promise<A> |
|
|
@ -21,11 +19,5 @@ export default function withLibcore<A>(job: Job<A>): Promise<A> { |
|
|
|
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) |
|
|
|
} |
|
|
|