From 8ae8071c541fe31306e0ac0c48314f0a914b9c47 Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Thu, 23 May 2019 14:01:05 -0700 Subject: [PATCH] waddrmgr: use RLock when retrieving sync info --- waddrmgr/sync.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/waddrmgr/sync.go b/waddrmgr/sync.go index 308812e..1163c6f 100644 --- a/waddrmgr/sync.go +++ b/waddrmgr/sync.go @@ -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 }