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:
Slyghtning 2026-07-01 12:05:14 +02:00
parent f8e9d11d04
commit 6ce13ba8a4
No known key found for this signature in database
GPG key ID: F82D456EA023C9BF
2 changed files with 8 additions and 0 deletions

View file

@ -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

View file

@ -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