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
2023-06-01 17:38:37 -07:00
parent f9d4600ff8
commit a7d6826f60
7 changed files with 45 additions and 142 deletions

View File

@@ -450,7 +450,7 @@ type AuthenticatedGossiper struct {
// goroutine per channel ID. This is done to ensure that when
// the gossiper is handling an announcement, the db state stays
// consistent between when the DB is first read until it's written.
channelMtx *multimutex.Mutex
channelMtx *multimutex.Mutex[uint64]
recentRejects *lru.Cache[rejectCacheKey, *cachedReject]
@@ -496,7 +496,7 @@ func New(cfg Config, selfKeyDesc *keychain.KeyDescriptor) *AuthenticatedGossiper
prematureChannelUpdates: lru.NewCache[uint64, *cachedNetworkMsg]( //nolint: lll
maxPrematureUpdates,
),
channelMtx: multimutex.NewMutex(),
channelMtx: multimutex.NewMutex[uint64](),
recentRejects: lru.NewCache[rejectCacheKey, *cachedReject](
maxRejectedUpdates,
),