mirror of
https://github.com/lightninglabs/pool.git
synced 2026-08-16 13:00:39 +02:00
account: query auctioneer only if necessary
In case the auctioneer is offline or restarting during the initial boot up of the trader server, we get a hard failure directly if we try to query the terms when the server connection isn't ready yet. This isn't really nice as we'd never come into the auto-retry of the account subscription that way. To optimize this, we only query the terms when we actually need them. This makes it possible for confirmed, open accounts to go into the subscription connection re-try logic. We'd only hard fail on startup if there are any pending accounts and the auctioneer is offline exactly during the trader boot up.
This commit is contained in:
parent
e2cd055c30
commit
e98c465f7b
1 changed files with 14 additions and 5 deletions
|
|
@ -399,11 +399,6 @@ func (m *Manager) resumeAccount(ctx context.Context, account *Account, // nolint
|
|||
return fmt.Errorf("unable to construct account output: %v", err)
|
||||
}
|
||||
|
||||
terms, err := m.cfg.Auctioneer.Terms(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not query auctioneer terms: %v", err)
|
||||
}
|
||||
|
||||
var accountTx *wire.MsgTx
|
||||
switch account.State {
|
||||
// In StateInitiated, we'll attempt to fund our account.
|
||||
|
|
@ -534,6 +529,11 @@ func (m *Manager) resumeAccount(ctx context.Context, account *Account, // nolint
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
terms, err := m.cfg.Auctioneer.Terms(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not query auctioneer terms: "+
|
||||
"%v", err)
|
||||
}
|
||||
|
||||
// Proceed to watch for the account on-chain.
|
||||
numConfs := NumConfsForValue(
|
||||
|
|
@ -564,6 +564,15 @@ func (m *Manager) resumeAccount(ctx context.Context, account *Account, // nolint
|
|||
// and would therefore not be noticed by us. The account would stay
|
||||
// pending forever in that case.
|
||||
case StatePendingUpdate, StatePendingBatch:
|
||||
// We need to know the maximum account value to scale the number
|
||||
// of confirmations the same way the auctioneer does to avoid
|
||||
// getting the state out of sync.
|
||||
terms, err := m.cfg.Auctioneer.Terms(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not query auctioneer terms: "+
|
||||
"%v", err)
|
||||
}
|
||||
|
||||
numConfs := NumConfsForValue(
|
||||
account.Value, terms.MaxAccountValue,
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue