From d8c9ad3c9f3c868ec35a458bb19b0e29bd189541 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Tue, 14 Jan 2025 10:56:11 +0800 Subject: [PATCH] all: replace RWMutex with Mutex in places where RLock is not used (#21622) --- accounts/keystore/file_cache.go | 2 +- core/chain_indexer.go | 2 +- eth/downloader/downloader.go | 2 +- les/txrelay.go | 2 +- miner/unconfirmed.go | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/accounts/keystore/file_cache.go b/accounts/keystore/file_cache.go index 08a4ca1c59..cd1306d32a 100644 --- a/accounts/keystore/file_cache.go +++ b/accounts/keystore/file_cache.go @@ -31,7 +31,7 @@ import ( type fileCache struct { all mapset.Set // Set of all files from the keystore folder lastMod time.Time // Last time instance when a file was modified - mu sync.RWMutex + mu sync.Mutex } // scan performs a new scan on the given directory, compares against the already diff --git a/core/chain_indexer.go b/core/chain_indexer.go index d089bc2082..d497d760f6 100644 --- a/core/chain_indexer.go +++ b/core/chain_indexer.go @@ -86,7 +86,7 @@ type ChainIndexer struct { throttling time.Duration // Disk throttling to prevent a heavy upgrade from hogging resources log log.Logger - lock sync.RWMutex + lock sync.Mutex } // NewChainIndexer creates a new chain indexer to do background processing on diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go index 9f25fc905f..9276392e78 100644 --- a/eth/downloader/downloader.go +++ b/eth/downloader/downloader.go @@ -145,7 +145,7 @@ type Downloader struct { cancelLock sync.RWMutex // Lock to protect the cancel channel and peer in delivers quitCh chan struct{} // Quit channel to signal termination - quitLock sync.RWMutex // Lock to prevent double closes + quitLock sync.Mutex // Lock to prevent double closes // Testing hooks syncInitHook func(uint64, uint64) // Method to call upon initiating a new sync run diff --git a/les/txrelay.go b/les/txrelay.go index b5488a8ad5..cda4de6f0e 100644 --- a/les/txrelay.go +++ b/les/txrelay.go @@ -34,7 +34,7 @@ type LesTxRelay struct { ps *peerSet peerList []*peer peerStartPos int - lock sync.RWMutex + lock sync.Mutex reqDist *requestDistributor } diff --git a/miner/unconfirmed.go b/miner/unconfirmed.go index 49bc2dfc16..f5fdf019e7 100644 --- a/miner/unconfirmed.go +++ b/miner/unconfirmed.go @@ -47,7 +47,7 @@ type unconfirmedBlocks struct { chain headerRetriever // Blockchain to verify canonical status through depth uint // Depth after which to discard previous blocks blocks *ring.Ring // Block infos to allow canonical chain cross checks - lock sync.RWMutex // Protects the fields from concurrent access + lock sync.Mutex // Protects the fields from concurrent access } // newUnconfirmedBlocks returns new data structure to track currently unconfirmed blocks.