Browse Source

Handle sqlite gaps while scanning accounts

LL-329
gre-patch-1
meriadec 6 years ago
parent
commit
0010442d30
No known key found for this signature in database GPG Key ID: 1D2FC2305E2CB399
  1. 17
      src/helpers/libcore.js

17
src/helpers/libcore.js

@ -111,7 +111,6 @@ async function scanAccountsOnDeviceBySegwit({
// retrieve or create the wallet // retrieve or create the wallet
const wallet = await getOrCreateWallet(core, walletName, { currency, derivationMode }) const wallet = await getOrCreateWallet(core, walletName, { currency, derivationMode })
const accountsCount = await wallet.getAccountCount()
// recursively scan all accounts on device on the given app // recursively scan all accounts on device on the given app
// new accounts will be created in sqlite, existing ones will be updated // new accounts will be created in sqlite, existing ones will be updated
@ -121,7 +120,6 @@ async function scanAccountsOnDeviceBySegwit({
walletName, walletName,
devicePath, devicePath,
currency, currency,
accountsCount,
accountIndex: 0, accountIndex: 0,
accounts: [], accounts: [],
onAccountScanned, onAccountScanned,
@ -202,7 +200,6 @@ async function scanNextAccount(props: {
currency: CryptoCurrency, currency: CryptoCurrency,
seedIdentifier: string, seedIdentifier: string,
derivationMode: string, derivationMode: string,
accountsCount: number,
accountIndex: number, accountIndex: number,
accounts: AccountRaw[], accounts: AccountRaw[],
onAccountScanned: AccountRaw => void, onAccountScanned: AccountRaw => void,
@ -215,7 +212,6 @@ async function scanNextAccount(props: {
walletName, walletName,
devicePath, devicePath,
currency, currency,
accountsCount,
accountIndex, accountIndex,
accounts, accounts,
onAccountScanned, onAccountScanned,
@ -225,13 +221,12 @@ async function scanNextAccount(props: {
isUnsubscribed, isUnsubscribed,
} = props } = props
// create account only if account has not been scanned yet let njsAccount
// if it has already been created, we just need to get it, and sync it try {
const hasBeenScanned = accountIndex < accountsCount njsAccount = await wallet.getAccount(accountIndex)
} catch (err) {
const njsAccount = hasBeenScanned njsAccount = await createAccount(wallet, devicePath)
? await wallet.getAccount(accountIndex) }
: await createAccount(wallet, devicePath)
if (isUnsubscribed()) return [] if (isUnsubscribed()) return []

Loading…
Cancel
Save