FIX: speedup onchain wallet creation (dont pre-fill too much cache)

This commit is contained in:
Overtorment 2020-09-03 21:01:03 +01:00
parent 899cabab8f
commit 497e38eda4
3 changed files with 6 additions and 5 deletions

View file

@ -404,10 +404,10 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet {
// its faster to pre-build hashmap of owned addresses than to query `this.weOwnAddress()`, which in turn
// iterates over all addresses in hierarchy
const ownedAddressesHashmap = {};
for (let c = 0; c < this.next_free_address_index + this.gap_limit; c++) {
for (let c = 0; c < this.next_free_address_index + 1; c++) {
ownedAddressesHashmap[this._getExternalAddressByIndex(c)] = true;
}
for (let c = 0; c < this.next_free_change_address_index + this.gap_limit; c++) {
for (let c = 0; c < this.next_free_change_address_index + 1; c++) {
ownedAddressesHashmap[this._getInternalAddressByIndex(c)] = true;
}
// hack: in case this code is called from LegacyWallet:

View file

@ -205,7 +205,7 @@ const WalletsAdd = () => {
}
BlueApp.wallets.push(w);
await BlueApp.saveToDisk();
EV(EV.enum.WALLETS_COUNT_CHANGED);
setTimeout(() => EV(EV.enum.WALLETS_COUNT_CHANGED), 500); // heavy task; hopefully will be executed while user is staring at backup screen
A(A.ENUM.CREATED_WALLET);
ReactNativeHapticFeedback.trigger('notificationSuccess', { ignoreAndroidSystemSettings: false });
if (w.type === HDSegwitP2SHWallet.type || w.type === HDSegwitBech32Wallet.type) {

View file

@ -140,6 +140,7 @@ export default class WalletsList extends Component {
}
const wallets = BlueApp.getWallets().concat(false);
const dataSource = BlueApp.getTransactions(null, 10);
if (scrollToEnd) {
scrollToEnd = wallets.length > this.state.wallets.length;
}
@ -148,8 +149,8 @@ export default class WalletsList extends Component {
{
isLoading: false,
isFlatListRefreshControlHidden: true,
dataSource: BlueApp.getTransactions(null, 10),
wallets: BlueApp.getWallets().concat(false),
dataSource,
wallets,
},
() => {
if (scrollToEnd) {