routing: add missing GlobalFeatures to NetworkNodeUpdate

This commit is contained in:
Andras Banki-Horvath committed 2020-12-07 15:47:09 +01:00
1 parent c58589db3b
commit 98c61be342
6 files changed
+832 -789

No files matched your search

+793 -779
View File
File diff suppressed because it is too large. Load diff
+7 -1
View File
@@ -2694,9 +2694,15 @@ message GraphTopologyUpdate {
message NodeUpdate { message NodeUpdate {
repeated string addresses = 1; repeated string addresses = 1;
string identity_key = 2; string identity_key = 2;
bytes global_features = 3; bytes global_features = 3 [deprecated = true];
string alias = 4; string alias = 4;
string color = 5; string color = 5;
/*
Features that the node has advertised in the init message, node
announcements and invoices.
*/
map<uint32, Feature> features = 6;
} }
message ChannelEdgeUpdate { message ChannelEdgeUpdate {
/* /*
+7
View File
@@ -4550,6 +4550,13 @@
}, },
"color": { "color": {
"type": "string" "type": "string"
},
"features": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/lnrpcFeature"
},
"description": "Features that the node has advertised in the init message, node\nannouncements and invoices."
} }
} }
}, },
+5 -4
View File
@@ -238,15 +238,14 @@ type NetworkNodeUpdate struct {
// updates. // updates.
IdentityKey *btcec.PublicKey IdentityKey *btcec.PublicKey
// GlobalFeatures is a set of opaque bytes that describe the set of
// features supported by the node.
GlobalFeatures []byte
// Alias is the alias or nick name of the node. // Alias is the alias or nick name of the node.
Alias string Alias string
// Color is the node's color in hex code format. // Color is the node's color in hex code format.
Color string Color string
// Features holds the set of features the node supports.
Features *lnwire.FeatureVector
} }
// ChannelEdgeUpdate is an update for a new channel within the ChannelGraph. // ChannelEdgeUpdate is an update for a new channel within the ChannelGraph.
@@ -318,11 +317,13 @@ func addToTopologyChange(graph *channeldb.ChannelGraph, update *TopologyChange,
if err != nil { if err != nil {
return err return err
} }
nodeUpdate := &NetworkNodeUpdate{ nodeUpdate := &NetworkNodeUpdate{
Addresses: m.Addresses, Addresses: m.Addresses,
IdentityKey: pubKey, IdentityKey: pubKey,
Alias: m.Alias, Alias: m.Alias,
Color: EncodeHexColor(m.Color), Color: EncodeHexColor(m.Color),
Features: m.Features.Clone(),
} }
nodeUpdate.IdentityKey.Curve = nil nodeUpdate.IdentityKey.Curve = nil
+13
View File
@@ -1,6 +1,7 @@
package routing package routing
import ( import (
"bytes"
"fmt" "fmt"
"image/color" "image/color"
"net" "net"
@@ -21,6 +22,7 @@ import (
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/chainview" "github.com/lightningnetwork/lnd/routing/chainview"
"github.com/lightningnetwork/lnd/routing/route" "github.com/lightningnetwork/lnd/routing/route"
"github.com/stretchr/testify/require"
) )
var ( var (
@@ -572,6 +574,9 @@ func TestNodeUpdateNotification(t *testing.T) {
t.Fatalf("unable to create test node: %v", err) t.Fatalf("unable to create test node: %v", err)
} }
testFeaturesBuf := new(bytes.Buffer)
require.NoError(t, testFeatures.Encode(testFeaturesBuf))
edge := &channeldb.ChannelEdgeInfo{ edge := &channeldb.ChannelEdgeInfo{
ChannelID: chanID.ToUint64(), ChannelID: chanID.ToUint64(),
NodeKey1Bytes: node1.PubKeyBytes, NodeKey1Bytes: node1.PubKeyBytes,
@@ -623,6 +628,14 @@ func TestNodeUpdateNotification(t *testing.T) {
"got %x", nodeKey.SerializeCompressed(), "got %x", nodeKey.SerializeCompressed(),
nodeUpdate.IdentityKey.SerializeCompressed()) nodeUpdate.IdentityKey.SerializeCompressed())
} }
featuresBuf := new(bytes.Buffer)
require.NoError(t, nodeUpdate.Features.Encode(featuresBuf))
require.Equal(
t, testFeaturesBuf.Bytes(), featuresBuf.Bytes(),
)
if nodeUpdate.Alias != ann.Alias { if nodeUpdate.Alias != ann.Alias {
t.Fatalf("node alias doesn't match: expected %v, got %v", t.Fatalf("node alias doesn't match: expected %v, got %v",
ann.Alias, nodeUpdate.Alias) ann.Alias, nodeUpdate.Alias)
+7 -5
View File
@@ -5509,11 +5509,13 @@ func marshallTopologyChange(topChange *routing.TopologyChange) *lnrpc.GraphTopol
} }
nodeUpdates[i] = &lnrpc.NodeUpdate{ nodeUpdates[i] = &lnrpc.NodeUpdate{
Addresses: addrs, Addresses: addrs,
IdentityKey: encodeKey(nodeUpdate.IdentityKey), IdentityKey: encodeKey(nodeUpdate.IdentityKey),
GlobalFeatures: nodeUpdate.GlobalFeatures, Alias: nodeUpdate.Alias,
Alias: nodeUpdate.Alias, Color: nodeUpdate.Color,
Color: nodeUpdate.Color, Features: invoicesrpc.CreateRPCFeatures(
nodeUpdate.Features,
),
} }
} }