Skip to content

Commit

Permalink
routing: update ChannelUpdate handling to recognize lnwire.ChanUpdate…
Browse files Browse the repository at this point in the history
…Flag
  • Loading branch information
Roasbeef committed Dec 1, 2017
1 parent 5e3dbfc commit 73ccb76
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion routing/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func addToTopologyChange(graph *channeldb.ChannelGraph, update *TopologyChange,
// the second node.
sourceNode := edgeInfo.NodeKey1
connectingNode := edgeInfo.NodeKey2
if m.Flags == 1 {
if m.Flags&lnwire.ChanUpdateDirection == 1 {
sourceNode = edgeInfo.NodeKey2
connectingNode = edgeInfo.NodeKey1
}
Expand Down
2 changes: 1 addition & 1 deletion routing/pathfind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func parseTestGraph(path string) (*channeldb.ChannelGraph, func(), aliasMap, err

edgePolicy := &channeldb.ChannelEdgePolicy{
Signature: testSig,
Flags: edge.Flags,
Flags: lnwire.ChanUpdateFlag(edge.Flags),
ChannelID: edge.ChannelID,
LastUpdate: time.Now(),
TimeLockDelta: edge.Expiry,
Expand Down
6 changes: 3 additions & 3 deletions routing/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -940,11 +940,11 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {
// 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 so, then we can exit early.
switch msg.Flags {
switch {

// A flag set of 0 indicates this is an announcement for the
// "first" node in the channel.
case 0:
case msg.Flags&lnwire.ChanUpdateDirection == 0:
if edge1Timestamp.After(msg.LastUpdate) ||
edge1Timestamp.Equal(msg.LastUpdate) {
return newErrf(ErrIgnored, "Ignoring update "+
Expand All @@ -955,7 +955,7 @@ func (r *ChannelRouter) processUpdate(msg interface{}) error {

// Similarly, a flag set of 1 indicates this is an announcement
// for the "second" node in the channel.
case 1:
case msg.Flags&lnwire.ChanUpdateDirection == 1:
if edge2Timestamp.After(msg.LastUpdate) ||
edge2Timestamp.Equal(msg.LastUpdate) {

Expand Down

0 comments on commit 73ccb76

Please sign in to comment.