Skip to content

Commit

Permalink
rpcserver: add debug lines
Browse files Browse the repository at this point in the history
  • Loading branch information
dajohi authored and matheusd committed Apr 22, 2024
1 parent a49df7d commit ae2a7c7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions kvdb/debug.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build dev
// +build dev

package kvdb
Expand Down
1 change: 1 addition & 0 deletions kvdb/etcd/debug.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build dev
// +build dev

package etcd
Expand Down
11 changes: 11 additions & 0 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -5357,13 +5357,16 @@ func (r *rpcServer) checkCanReceiveInvoice(ctx context.Context,

// Loop through all available channels, check for liveliness and capacity.
var maxInbound dcrutil.Amount
var debugErrs []string
for _, channel := range openChannels {
// Ensure the channel is active and the remote peer is online, which is
// required to receive from this channel.
chanPoint := &channel.FundingOutpoint
if _, err := r.server.FindPeer(channel.IdentityPub); err != nil {
// We're not connected to the peer, therefore can't receive htlcs
// from it.
debugErrs = append(debugErrs,
fmt.Sprintf("unable to find peer for chanpoint %s: %v", chanPoint, err))
continue
}

Expand All @@ -5372,12 +5375,16 @@ func (r *rpcServer) checkCanReceiveInvoice(ctx context.Context,
channelID := lnwire.NewChanIDFromOutPoint(chanPoint)
var link htlcswitch.ChannelUpdateHandler
if link, err = r.server.htlcSwitch.GetLink(channelID); err != nil {
debugErrs = append(debugErrs,
fmt.Sprintf("failed to get link for chanpoint %s: %v", chanPoint, err))
continue
}

// If this link isn' eligible for htcl forwarding, it means we can't
// receive from it.
if !link.EligibleToForward() {
debugErrs = append(debugErrs,
fmt.Sprintf("link is not eligable to forward chanpoint %s -- skipping", chanPoint))
continue
}

Expand All @@ -5402,6 +5409,10 @@ func (r *rpcServer) checkCanReceiveInvoice(ctx context.Context,
return errors.New("no online channels found")
}

for _, debugErr := range debugErrs {
rpcsLog.Debugf("addinvoice(amt %d): %v", amt, debugErr)
}

missingCap := amt - maxInbound
return fmt.Errorf("not enough inbound capacity (missing %d atoms)",
missingCap)
Expand Down

0 comments on commit ae2a7c7

Please sign in to comment.