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:
Olaoluwa Osuntokun committed 2023-06-01 17:39:49 -07:00
1 parent f9d4600ff8
commit a7d6826f60
7 files changed
+45 -142

No files matched your search

+2 -2
View File
@@ -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](),
}
}