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
@@ -132,7 +132,7 @@ type controlTower struct {
// paymentsMtx provides synchronization on the payment level to ensure
// that no race conditions occur in between updating the database and
// sending a notification.
paymentsMtx *multimutex.HashMutex
paymentsMtx *multimutex.Mutex[lntypes.Hash]
}
// NewControlTower creates a new instance of the controlTower.
@@ -143,7 +143,7 @@ func NewControlTower(db *channeldb.PaymentControl) ControlTower {
map[uint64]*controlTowerSubscriberImpl,
),
subscribers: make(map[lntypes.Hash][]*controlTowerSubscriberImpl),
paymentsMtx: multimutex.NewHashMutex(),
paymentsMtx: multimutex.NewMutex[lntypes.Hash](),
}
}