From 73ccb76853711b7a72affe81681c5b8378185872 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 30 Nov 2017 22:24:27 -0800 Subject: [PATCH] routing: update ChannelUpdate handling to recognize lnwire.ChanUpdateFlag --- routing/notifications.go | 2 +- routing/pathfind_test.go | 2 +- routing/router.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/routing/notifications.go b/routing/notifications.go index cdb5f31c2d..6f1e59f57d 100644 --- a/routing/notifications.go +++ b/routing/notifications.go @@ -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 } diff --git a/routing/pathfind_test.go b/routing/pathfind_test.go index 8f1c3afbca..a94c99fae7 100644 --- a/routing/pathfind_test.go +++ b/routing/pathfind_test.go @@ -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, diff --git a/routing/router.go b/routing/router.go index 3ca3e30124..1a2e41ea18 100644 --- a/routing/router.go +++ b/routing/router.go @@ -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 "+ @@ -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) {