routing: update ChannelUpdate handling to recognize lnwire.ChanUpdateFlag

This commit is contained in:
Olaoluwa Osuntokun 2017-11-30 22:24:27 -08:00
parent 5e3dbfcd78
commit 73ccb76853
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
3 changed files with 5 additions and 5 deletions

@ -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
}

@ -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,

@ -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) {