Browse Source

liquidity: rename ticker and default to autoloop

pull/331/head
carla 10 months ago
parent
commit
24aa429aa0
No known key found for this signature in database GPG Key ID: 4CA7FE54A6213C91
3 changed files with 15 additions and 15 deletions
  1. +2
    -2
      liquidity/autoloop_testcontext_test.go
  2. +11
    -11
      liquidity/liquidity.go
  3. +2
    -2
      loopd/utils.go

+ 2
- 2
liquidity/autoloop_testcontext_test.go View File

@ -91,7 +91,7 @@ func newAutoloopTestCtx(t *testing.T, parameters Parameters,
testCtx.lnd.Channels = channels
cfg := &Config{
AutoOutTicker: ticker.NewForce(DefaultAutoOutTicker),
AutoloopTicker: ticker.NewForce(DefaultAutoloopTicker),
LoopOutRestrictions: func(context.Context) (*Restrictions, error) {
return <-testCtx.loopOutRestrictions, nil
},
@ -182,7 +182,7 @@ func (c *autoloopTestCtx) autoloop(minAmt, maxAmt btcutil.Amount,
expectedSwaps []loopOutRequestResp) {
// Tick our autoloop ticker to force assessing whether we want to loop.
c.manager.cfg.AutoOutTicker.Force <- testTime
c.manager.cfg.AutoloopTicker.Force <- testTime
// Send a mocked response from the server with the swap size limits.
c.loopOutRestrictions <- NewRestrictions(minAmt, maxAmt)

+ 11
- 11
liquidity/liquidity.go View File

@ -96,9 +96,9 @@ const (
// suggestions as a dry-run).
defaultMaxInFlight = 1
// DefaultAutoOutTicker is the default amount of time between automated
// loop out checks.
DefaultAutoOutTicker = time.Minute * 10
// DefaultAutoloopTicker is the default amount of time between automated
// swap checks.
DefaultAutoloopTicker = time.Minute * 10
// autoloopSwapInitiator is the value we send in the initiator field of
// a swap request when issuing an automatic swap.
@ -182,10 +182,10 @@ var (
// Config contains the external functionality required to run the
// liquidity manager.
type Config struct {
// AutoOutTicker determines how often we should check whether we want
// to dispatch an automated loop out. We use a force ticker so that
// we can trigger autoloop in itests.
AutoOutTicker *ticker.Force
// AutoloopTicker determines how often we should check whether we want
// to dispatch an automated swap. We use a force ticker so that we can
// trigger autoloop in itests.
AutoloopTicker *ticker.Force
// LoopOutRestrictions returns the restrictions that the server applies
// to loop out swaps.
@ -431,12 +431,12 @@ type Manager struct {
// We run this loop even if automated swaps are not currently enabled rather
// than managing starting and stopping the ticker as our parameters are updated.
func (m *Manager) Run(ctx context.Context) error {
m.cfg.AutoOutTicker.Resume()
defer m.cfg.AutoOutTicker.Stop()
m.cfg.AutoloopTicker.Resume()
defer m.cfg.AutoloopTicker.Stop()
for {
select {
case <-m.cfg.AutoOutTicker.Ticks():
case <-m.cfg.AutoloopTicker.Ticks():
if err := m.autoloop(ctx); err != nil {
log.Errorf("autoloop failed: %v", err)
}
@ -528,7 +528,7 @@ func (m *Manager) autoloop(ctx context.Context) error {
// ForceAutoLoop force-ticks our auto-out ticker.
func (m *Manager) ForceAutoLoop(ctx context.Context) error {
select {
case m.cfg.AutoOutTicker.Force <- m.cfg.Clock.Now():
case m.cfg.AutoloopTicker.Force <- m.cfg.Clock.Now():
return nil
case <-ctx.Done():

+ 2
- 2
loopd/utils.go View File

@ -36,8 +36,8 @@ func getClient(config *Config, lnd *lndclient.LndServices) (*loop.Client,
func getLiquidityManager(client *loop.Client) *liquidity.Manager {
mngrCfg := &liquidity.Config{
AutoOutTicker: ticker.NewForce(liquidity.DefaultAutoOutTicker),
LoopOut: client.LoopOut,
AutoloopTicker: ticker.NewForce(liquidity.DefaultAutoloopTicker),
LoopOut: client.LoopOut,
LoopOutRestrictions: func(ctx context.Context) (
*liquidity.Restrictions, error) {

Loading…
Cancel
Save