Skip to content

Commit

Permalink
x - more logsZZ
Browse files Browse the repository at this point in the history
  • Loading branch information
yyforyongyu committed Jan 15, 2025
1 parent dda368f commit 79959b0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
6 changes: 3 additions & 3 deletions discovery/gossiper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3039,9 +3039,9 @@ func (d *AuthenticatedGossiper) handleChanUpdate(nMsg *networkMsg,
edgeToUpdate = e2
}

log.Debugf("Validating ChannelUpdate: channel=%v, from node=%x, has "+
"edge=%v", chanInfo.ChannelID, pubKey.SerializeCompressed(),
edgeToUpdate != nil)
log.Debugf("Validating ChannelUpdate: channel=%v, for node=%x, has "+
"edge policy=%v", chanInfo.ChannelID,
pubKey.SerializeCompressed(), edgeToUpdate != nil)

// Validate the channel announcement with the expected public key and
// channel capacity. In the case of an invalid channel update, we'll
Expand Down
15 changes: 8 additions & 7 deletions graph/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1359,8 +1359,7 @@ func (b *Builder) processUpdate(msg interface{},
}

case *models.ChannelEdgePolicy:
log.Debugf("Received ChannelEdgePolicy for channel %v",
msg.ChannelID)
log.Debugf("Received ChannelEdgePolicy %v", msg)

// We make sure to hold the mutex for this channel ID,
// such that no other goroutine is concurrently doing
Expand Down Expand Up @@ -1400,16 +1399,18 @@ func (b *Builder) processUpdate(msg interface{},
msg.ChannelID)
}

log.Debugf("Found edge1Timestamp=%v, edge2Timestamp=%v",
edge1Timestamp, edge2Timestamp)

// As edges are directional edge node has a unique policy for
// the direction of the edge they control. Therefore, we first
// check if we already have the most up-to-date information for
// that edge. If this message has a timestamp not strictly
// newer than what we already know of we can exit early.
switch {
switch msg.ChannelFlags & lnwire.ChanUpdateDirection {
// A flag set of 0 indicates this is an announcement for the
// "first" node in the channel.
case msg.ChannelFlags&lnwire.ChanUpdateDirection == 0:

case 0:
// Ignore outdated message.
if !edge1Timestamp.Before(msg.LastUpdate) {
return NewErrf(ErrOutdated, "Ignoring "+
Expand All @@ -1420,8 +1421,7 @@ func (b *Builder) processUpdate(msg interface{},

// Similarly, a flag set of 1 indicates this is an announcement
// for the "second" node in the channel.
case msg.ChannelFlags&lnwire.ChanUpdateDirection == 1:

case 1:
// Ignore outdated message.
if !edge2Timestamp.Before(msg.LastUpdate) {
return NewErrf(ErrOutdated, "Ignoring "+
Expand All @@ -1442,6 +1442,7 @@ func (b *Builder) processUpdate(msg interface{},

log.Tracef("New channel update applied: %v",
lnutils.SpewLogClosure(msg))

b.stats.incNumChannelUpdates()

default:
Expand Down
8 changes: 8 additions & 0 deletions graph/db/models/channel_edge_policy.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package models

import (
"fmt"
"time"

"github.com/btcsuite/btcd/btcec/v2/ecdsa"
Expand Down Expand Up @@ -113,3 +114,10 @@ func (c *ChannelEdgePolicy) ComputeFee(

return c.FeeBaseMSat + (amt*c.FeeProportionalMillionths)/feeRateParts
}

// String returns a human-readable version of the channel edge policy.
func (c *ChannelEdgePolicy) String() string {
return fmt.Sprintf("ChannelID=%v, MessageFlags=%v, ChannelFlags=%v, "+
"LastUpdate=%v", c.ChannelID, c.MessageFlags, c.ChannelFlags,
c.LastUpdate)
}
2 changes: 1 addition & 1 deletion lntest/node/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (cfg *BaseNodeConfig) GenArgs() []string {

nodeArgs := []string{
"--nobootstrap",
"--debuglevel=debug,DISC=trace",
"--debuglevel=debug,DISC=trace,GRPH=trace",
"--bitcoin.defaultchanconfs=1",
"--accept-keysend",
"--keep-failed-payment-attempts",
Expand Down
2 changes: 1 addition & 1 deletion routing/unified_edges.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (u *nodeEdgeUnifier) addGraphPolicies(g Graph) error {
// Note that we are searching backwards so this node would have
// come prior to the pivot node in the route.
if channel.InPolicy == nil {
log.Debugf("Skipped adding graph policy for channel %v",
log.Debugf("Skipped adding edge %v due to nil policy",
channel.ChannelID)

return nil
Expand Down

0 comments on commit 79959b0

Please sign in to comment.