multimutex: remove HashMutex, make Mutex type a type param
In this commit, we eliminate some code duplication by removing the old `HashMutex` struct as it just duplicates all the code with a different type (uint64 and hash). We then make the main Mutex struct take a type param, so the key can be parametrized when the struct is instantiated.
This commit is contained in:
7 files changed
+45
-142
No files matched your search
@@ -14,7 +14,7 @@ import (
|
||||
// BlockCache is an lru cache for blocks.
|
||||
type BlockCache struct {
|
||||
Cache *lru.Cache[wire.InvVect, *neutrino.CacheableBlock]
|
||||
HashMutex *multimutex.HashMutex
|
||||
HashMutex *multimutex.Mutex[lntypes.Hash]
|
||||
}
|
||||
|
||||
// NewBlockCache creates a new BlockCache with the given maximum capacity.
|
||||
@@ -23,7 +23,7 @@ func NewBlockCache(capacity uint64) *BlockCache {
|
||||
Cache: lru.NewCache[wire.InvVect, *neutrino.CacheableBlock](
|
||||
capacity,
|
||||
),
|
||||
HashMutex: multimutex.NewHashMutex(),
|
||||
HashMutex: multimutex.NewMutex[lntypes.Hash](),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user