Skip to content

Keystore event fix #2311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions backend/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ func (backend *Backend) RenameAccount(accountCode accountsTypes.Code, name strin
if err != nil {
return err
}
backend.emitAccountsStatusChanged()
backend.emitAccountsListChanged()
return nil
}

Expand Down Expand Up @@ -566,7 +566,7 @@ func (backend *Backend) createAndAddAccount(coin coinpkg.Coin, persistedConfig *
}
}

func (backend *Backend) emitAccountsStatusChanged() {
func (backend *Backend) emitAccountsListChanged() {
backend.Notify(observable.Event{
Subject: "accounts",
Action: action.Reload,
Expand Down Expand Up @@ -904,7 +904,7 @@ func (backend *Backend) initAccounts() {

backend.initPersistedAccounts()

backend.emitAccountsStatusChanged()
backend.emitAccountsListChanged()

// The updater fetches rates only for active accounts, so this seems the most
// appropriate place to update exchange rate configuration.
Expand All @@ -931,6 +931,7 @@ func (backend *Backend) uninitAccounts() {
backend.onAccountUninit(account)
}
account.Close()
backend.emitAccountsListChanged()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at this stage backend.accounts has not changed at all though, so why fire an event here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I guess I'd have to remove the single accounts from the slice after each iteration and then firing the event. Agree?

}
backend.accounts = []accounts.Interface{}
}
Expand Down Expand Up @@ -1057,7 +1058,7 @@ func (backend *Backend) maybeAddHiddenUnusedAccounts() {
continue
}
backend.createAndAddAccount(coin, accountConfig)
backend.emitAccountsStatusChanged()
backend.emitAccountsListChanged()
}
}
}
Expand Down Expand Up @@ -1098,6 +1099,6 @@ func (backend *Backend) checkAccountUsed(account accounts.Interface) {
log.WithError(err).Error("checkAccountUsed")
return
}
backend.emitAccountsStatusChanged()
backend.emitAccountsListChanged()
backend.maybeAddHiddenUnusedAccounts()
}
3 changes: 1 addition & 2 deletions backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ func (backend *Backend) Start() <-chan interface{} {

defer backend.accountsAndKeystoreLock.Lock()()
backend.initPersistedAccounts()
backend.emitAccountsStatusChanged()
backend.emitAccountsListChanged()

backend.ratesUpdater.StartCurrentRates()
backend.configureHistoryExchangeRates()
Expand Down Expand Up @@ -558,7 +558,6 @@ func (backend *Backend) DeregisterKeystore() {
// TODO: classify accounts by keystore, remove only the ones belonging to the deregistered
// keystore. For now we just remove all, then re-add the rest.
backend.initPersistedAccounts()
backend.emitAccountsStatusChanged()
}

// Register registers the given device at this backend.
Expand Down