mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
staticaddr/deposit: document lock ordering
Document the lock-order invariant between Manager.mu and individual deposit locks. Later changes need both locks in the same path, so make the rule explicit before the locking surface grows.
This commit is contained in:
parent
f8e9d11d04
commit
6ce13ba8a4
2 changed files with 8 additions and 0 deletions
|
|
@ -29,6 +29,10 @@ func (r *ID) FromByteSlice(b []byte) error {
|
|||
|
||||
// Deposit bundles an utxo at a static address together with manager-relevant
|
||||
// data.
|
||||
//
|
||||
// Lock order: if both Manager.mu and a Deposit lock are needed, acquire
|
||||
// Manager.mu before Deposit.Lock. Never acquire Manager.mu while holding a
|
||||
// Deposit lock.
|
||||
type Deposit struct {
|
||||
sync.Mutex
|
||||
|
||||
|
|
|
|||
|
|
@ -58,6 +58,10 @@ type ManagerConfig struct {
|
|||
}
|
||||
|
||||
// Manager manages the address state machines.
|
||||
//
|
||||
// Lock order: if both Manager.mu and a Deposit lock are needed, acquire
|
||||
// Manager.mu before Deposit.Lock. Never acquire Manager.mu while holding a
|
||||
// Deposit lock.
|
||||
type Manager struct {
|
||||
cfg *ManagerConfig
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue