mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-15 12:50:28 +02:00
liquidity: fail suggest swaps when no rules are set
In an effort to surface more information about why autoloop is not executing, we add an error when suggest swaps is called with no rules. In other cases we can surface a reason enum with each rule that is set, but in the case where we have no rules, there are no results to accompany with reasons.
This commit is contained in:
parent
67f417188d
commit
7ba1821696
5 changed files with 44 additions and 7 deletions
|
|
@ -21,6 +21,8 @@ import (
|
|||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
"github.com/lightningnetwork/lnd/queue"
|
||||
"github.com/lightningnetwork/lnd/routing/route"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -703,7 +705,13 @@ func (s *swapClientServer) SuggestSwaps(ctx context.Context,
|
|||
_ *looprpc.SuggestSwapsRequest) (*looprpc.SuggestSwapsResponse, error) {
|
||||
|
||||
swaps, err := s.liquidityMgr.SuggestSwaps(ctx, false)
|
||||
if err != nil {
|
||||
switch err {
|
||||
case liquidity.ErrNoRules:
|
||||
return nil, status.Error(codes.FailedPrecondition, err.Error())
|
||||
|
||||
case nil:
|
||||
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue