Merge pull request #608 from wpaulino/manager-oncommit-lock

waddrmgr: use methods that do not hold the manager's lock
This commit is contained in:
Olaoluwa Osuntokun 2019-03-18 18:05:15 -07:00 committed by GitHub
commit 89ab2044f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -337,6 +337,14 @@ func (m *Manager) WatchOnly() bool {
m.mtx.RLock()
defer m.mtx.RUnlock()
return m.watchOnly()
}
// watchOnly returns true if the root manager is in watch only mode, and false
// otherwise.
//
// NOTE: This method requires the Manager's lock to be held.
func (m *Manager) watchOnly() bool {
return m.watchingOnly
}

View file

@ -842,7 +842,7 @@ func (s *ScopedKeyManager) nextAddresses(ns walletdb.ReadWriteBucket,
// Add the new managed address to the list of addresses
// that need their private keys derived when the
// address manager is next unlocked.
if s.rootManager.IsLocked() && !s.rootManager.WatchOnly() {
if s.rootManager.isLocked() && !s.rootManager.watchOnly() {
s.deriveOnUnlock = append(s.deriveOnUnlock, info)
}
}