mirror of
https://github.com/lightninglabs/pool.git
synced 2026-08-18 13:08:33 +02:00
account: ensure only one outstanding account reservation exists
The auctioneer only expects one outstanding account reservation to exist per trader LSAT, so we should enforce this on the trader's side as well.
This commit is contained in:
parent
3d20736cc1
commit
84b841a9cf
1 changed files with 12 additions and 0 deletions
|
|
@ -140,6 +140,12 @@ type Manager struct {
|
|||
// Finalize message for.
|
||||
pendingBatchMtx sync.Mutex
|
||||
|
||||
// reservationMtx prevents a trader from attempting to have more than
|
||||
// once active reservation at a time when creating new accounts. This is
|
||||
// done to ensure an account picks up the correct reservation once its
|
||||
// time to fund it.
|
||||
reservationMtx sync.Mutex
|
||||
|
||||
wg sync.WaitGroup
|
||||
quit chan struct{}
|
||||
}
|
||||
|
|
@ -260,6 +266,12 @@ func (m *Manager) QuoteAccount(ctx context.Context, value btcutil.Amount,
|
|||
func (m *Manager) InitAccount(ctx context.Context, value btcutil.Amount,
|
||||
expiry, bestHeight, confTarget uint32) (*Account, error) {
|
||||
|
||||
// We'll make sure to acquire the reservation lock throughout the
|
||||
// account funding process to ensure we use the same reservation, as
|
||||
// only one can be active per trader LSAT.
|
||||
m.reservationMtx.Lock()
|
||||
defer m.reservationMtx.Unlock()
|
||||
|
||||
// First, make sure we have a valid amount to create the account. We
|
||||
// need to ask the auctioneer for the maximum as it dynamically defines
|
||||
// that value.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue