Merge pull request #620 from wpaulino/waddrmgr-rlock-sync

waddrmgr: use RLock when retrieving sync info
This commit is contained in:
Olaoluwa Osuntokun 2019-05-23 17:35:33 -07:00 committed by GitHub
commit 2c05240dff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -74,8 +74,8 @@ func (m *Manager) SetSyncedTo(ns walletdb.ReadWriteBucket, bs *BlockStamp) error
// can use this information for intelligently initiating rescans to sync back to
// the best chain from the last known good block.
func (m *Manager) SyncedTo() BlockStamp {
m.mtx.Lock()
defer m.mtx.Unlock()
m.mtx.RLock()
defer m.mtx.RUnlock()
return m.syncState.syncedTo
}
@ -85,8 +85,6 @@ func (m *Manager) SyncedTo() BlockStamp {
// reorg is taking place and how far back it goes.
func (m *Manager) BlockHash(ns walletdb.ReadBucket, height int32) (
*chainhash.Hash, error) {
m.mtx.Lock()
defer m.mtx.Unlock()
return fetchBlockHash(ns, height)
}
@ -94,8 +92,8 @@ func (m *Manager) BlockHash(ns walletdb.ReadBucket, height int32) (
// Birthday returns the birthday, or earliest time a key could have been used,
// for the manager.
func (m *Manager) Birthday() time.Time {
m.mtx.Lock()
defer m.mtx.Unlock()
m.mtx.RLock()
defer m.mtx.RUnlock()
return m.birthday
}