waddrmgr: use RLock when retrieving sync info

This commit is contained in:
Wilmer Paulino 2019-05-23 14:01:05 -07:00
parent 9d95f76e99
commit 8ae8071c54
No known key found for this signature in database
GPG key ID: 6DF57B9F9514972F

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
}