mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
liquidity: rename ticker and default to autoloop
This commit is contained in:
parent
71ace95ac8
commit
24aa429aa0
3 changed files with 15 additions and 15 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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():
|
||||
|
|
|
|||
|
|
@ -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…
Add table
Add a link
Reference in a new issue