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
@@ -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](),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user