Merge pull request #10185 from ellemouton/renameLightningNode
multi: Rename LightningNode to Node
This commit is contained in:
27 files changed
+354
-359
No files matched your search
+3
-3
@@ -48,7 +48,7 @@ func ChannelGraphFromDatabase(db GraphSource) ChannelGraph {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// type dbNode is a wrapper struct around a database transaction an
|
// type dbNode is a wrapper struct around a database transaction an
|
||||||
// channeldb.LightningNode. The wrapper method implement the autopilot.Node
|
// channeldb.Node. The wrapper method implement the autopilot.Node
|
||||||
// interface.
|
// interface.
|
||||||
type dbNode struct {
|
type dbNode struct {
|
||||||
pub [33]byte
|
pub [33]byte
|
||||||
@@ -84,7 +84,7 @@ func (d *dbNode) Addrs() []net.Addr {
|
|||||||
func (d *databaseChannelGraph) ForEachNode(ctx context.Context,
|
func (d *databaseChannelGraph) ForEachNode(ctx context.Context,
|
||||||
cb func(context.Context, Node) error, reset func()) error {
|
cb func(context.Context, Node) error, reset func()) error {
|
||||||
|
|
||||||
return d.db.ForEachNode(ctx, func(n *models.LightningNode) error {
|
return d.db.ForEachNode(ctx, func(n *models.Node) error {
|
||||||
// We'll skip over any node that doesn't have any advertised
|
// We'll skip over any node that doesn't have any advertised
|
||||||
// addresses. As we won't be able to reach them to actually
|
// addresses. As we won't be able to reach them to actually
|
||||||
// open any channels.
|
// open any channels.
|
||||||
@@ -161,7 +161,7 @@ func ChannelGraphFromCachedDatabase(db GraphSource) ChannelGraph {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// dbNodeCached is a wrapper struct around a database transaction for a
|
// dbNodeCached is a wrapper struct around a database transaction for a
|
||||||
// channeldb.LightningNode. The wrapper methods implement the autopilot.Node
|
// channeldb.Node. The wrapper methods implement the autopilot.Node
|
||||||
// interface.
|
// interface.
|
||||||
type dbNodeCached struct {
|
type dbNodeCached struct {
|
||||||
node route.Vertex
|
node route.Vertex
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ type GraphSource interface {
|
|||||||
// graph, executing the passed callback with each node encountered. If
|
// graph, executing the passed callback with each node encountered. If
|
||||||
// the callback returns an error, then the transaction is aborted and
|
// the callback returns an error, then the transaction is aborted and
|
||||||
// the iteration stops early.
|
// the iteration stops early.
|
||||||
ForEachNode(context.Context, func(*models.LightningNode) error,
|
ForEachNode(context.Context, func(*models.Node) error,
|
||||||
func()) error
|
func()) error
|
||||||
|
|
||||||
// ForEachNodeCached is similar to ForEachNode, but it utilizes the
|
// ForEachNodeCached is similar to ForEachNode, but it utilizes the
|
||||||
|
|||||||
@@ -403,7 +403,7 @@ func (d *testDBGraph) addRandChannel(node1, node2 *btcec.PublicKey,
|
|||||||
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
|
|
||||||
fetchNode := func(pub *btcec.PublicKey) (*models.LightningNode, error) {
|
fetchNode := func(pub *btcec.PublicKey) (*models.Node, error) {
|
||||||
if pub != nil {
|
if pub != nil {
|
||||||
vertex, err := route.NewVertexFromBytes(
|
vertex, err := route.NewVertexFromBytes(
|
||||||
pub.SerializeCompressed(),
|
pub.SerializeCompressed(),
|
||||||
@@ -412,12 +412,12 @@ func (d *testDBGraph) addRandChannel(node1, node2 *btcec.PublicKey,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
dbNode, err := d.db.FetchLightningNode(ctx, vertex)
|
dbNode, err := d.db.FetchNode(ctx, vertex)
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, graphdb.ErrGraphNodeNotFound):
|
case errors.Is(err, graphdb.ErrGraphNodeNotFound):
|
||||||
fallthrough
|
fallthrough
|
||||||
case errors.Is(err, graphdb.ErrGraphNotFound):
|
case errors.Is(err, graphdb.ErrGraphNotFound):
|
||||||
graphNode := &models.LightningNode{
|
graphNode := &models.Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
Addresses: []net.Addr{&net.TCPAddr{
|
Addresses: []net.Addr{&net.TCPAddr{
|
||||||
IP: bytes.Repeat(
|
IP: bytes.Repeat(
|
||||||
@@ -430,7 +430,7 @@ func (d *testDBGraph) addRandChannel(node1, node2 *btcec.PublicKey,
|
|||||||
AuthSigBytes: testSig.Serialize(),
|
AuthSigBytes: testSig.Serialize(),
|
||||||
}
|
}
|
||||||
graphNode.AddPubKey(pub)
|
graphNode.AddPubKey(pub)
|
||||||
err := d.db.AddLightningNode(
|
err := d.db.AddNode(
|
||||||
context.Background(), graphNode,
|
context.Background(), graphNode,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -447,7 +447,7 @@ func (d *testDBGraph) addRandChannel(node1, node2 *btcec.PublicKey,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
dbNode := &models.LightningNode{
|
dbNode := &models.Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
Addresses: []net.Addr{
|
Addresses: []net.Addr{
|
||||||
&net.TCPAddr{
|
&net.TCPAddr{
|
||||||
@@ -460,7 +460,7 @@ func (d *testDBGraph) addRandChannel(node1, node2 *btcec.PublicKey,
|
|||||||
AuthSigBytes: testSig.Serialize(),
|
AuthSigBytes: testSig.Serialize(),
|
||||||
}
|
}
|
||||||
dbNode.AddPubKey(nodeKey)
|
dbNode.AddPubKey(nodeKey)
|
||||||
if err := d.db.AddLightningNode(
|
if err := d.db.AddNode(
|
||||||
context.Background(), dbNode,
|
context.Background(), dbNode,
|
||||||
); err != nil {
|
); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -548,7 +548,7 @@ func (d *testDBGraph) addRandNode() (*btcec.PublicKey, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
dbNode := &models.LightningNode{
|
dbNode := &models.Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
Addresses: []net.Addr{
|
Addresses: []net.Addr{
|
||||||
&net.TCPAddr{
|
&net.TCPAddr{
|
||||||
@@ -561,7 +561,7 @@ func (d *testDBGraph) addRandNode() (*btcec.PublicKey, error) {
|
|||||||
AuthSigBytes: testSig.Serialize(),
|
AuthSigBytes: testSig.Serialize(),
|
||||||
}
|
}
|
||||||
dbNode.AddPubKey(nodeKey)
|
dbNode.AddPubKey(nodeKey)
|
||||||
err = d.db.AddLightningNode(context.Background(), dbNode)
|
err = d.db.AddNode(context.Background(), dbNode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -807,11 +807,11 @@ func TestFetchPermTempPeer(t *testing.T) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func createLightningNode(priv *btcec.PrivateKey) *models.LightningNode {
|
func createNode(priv *btcec.PrivateKey) *models.Node {
|
||||||
updateTime := rand.Int63()
|
updateTime := rand.Int63()
|
||||||
|
|
||||||
pub := priv.PubKey().SerializeCompressed()
|
pub := priv.PubKey().SerializeCompressed()
|
||||||
n := &models.LightningNode{
|
n := &models.Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
AuthSigBytes: testSig.Serialize(),
|
AuthSigBytes: testSig.Serialize(),
|
||||||
LastUpdate: time.Unix(updateTime, 0),
|
LastUpdate: time.Unix(updateTime, 0),
|
||||||
@@ -825,9 +825,9 @@ func createLightningNode(priv *btcec.PrivateKey) *models.LightningNode {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTestVertex(t *testing.T) *models.LightningNode {
|
func createTestVertex(t *testing.T) *models.Node {
|
||||||
priv, err := btcec.NewPrivateKey()
|
priv, err := btcec.NewPrivateKey()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
return createLightningNode(priv)
|
return createNode(priv)
|
||||||
}
|
}
|
||||||
@@ -2235,7 +2235,7 @@ func (d *AuthenticatedGossiper) processZombieUpdate(_ context.Context,
|
|||||||
func (d *AuthenticatedGossiper) fetchNodeAnn(ctx context.Context,
|
func (d *AuthenticatedGossiper) fetchNodeAnn(ctx context.Context,
|
||||||
pubKey [33]byte) (*lnwire.NodeAnnouncement, error) {
|
pubKey [33]byte) (*lnwire.NodeAnnouncement, error) {
|
||||||
|
|
||||||
node, err := d.cfg.Graph.FetchLightningNode(ctx, pubKey)
|
node, err := d.cfg.Graph.FetchNode(ctx, pubKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ type mockGraphSource struct {
|
|||||||
bestHeight uint32
|
bestHeight uint32
|
||||||
|
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
nodes []models.LightningNode
|
nodes []models.Node
|
||||||
infos map[uint64]models.ChannelEdgeInfo
|
infos map[uint64]models.ChannelEdgeInfo
|
||||||
edges map[uint64][]models.ChannelEdgePolicy
|
edges map[uint64][]models.ChannelEdgePolicy
|
||||||
zombies map[uint64][][33]byte
|
zombies map[uint64][][33]byte
|
||||||
@@ -109,7 +109,7 @@ func newMockRouter(t *testing.T, height uint32) *mockGraphSource {
|
|||||||
|
|
||||||
var _ graph.ChannelGraphSource = (*mockGraphSource)(nil)
|
var _ graph.ChannelGraphSource = (*mockGraphSource)(nil)
|
||||||
|
|
||||||
func (r *mockGraphSource) AddNode(_ context.Context, node *models.LightningNode,
|
func (r *mockGraphSource) AddNode(_ context.Context, node *models.Node,
|
||||||
_ ...batch.SchedulerOption) error {
|
_ ...batch.SchedulerOption) error {
|
||||||
|
|
||||||
r.mu.Lock()
|
r.mu.Lock()
|
||||||
@@ -206,7 +206,7 @@ func (r *mockGraphSource) AddProof(chanID lnwire.ShortChannelID,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *mockGraphSource) ForEachNode(
|
func (r *mockGraphSource) ForEachNode(
|
||||||
func(node *models.LightningNode) error) error {
|
func(node *models.Node) error) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -295,8 +295,8 @@ func (r *mockGraphSource) GetChannelByID(chanID lnwire.ShortChannelID) (
|
|||||||
return &chanInfo, edge1, edge2, nil
|
return &chanInfo, edge1, edge2, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *mockGraphSource) FetchLightningNode(_ context.Context,
|
func (r *mockGraphSource) FetchNode(_ context.Context,
|
||||||
nodePub route.Vertex) (*models.LightningNode, error) {
|
nodePub route.Vertex) (*models.Node, error) {
|
||||||
|
|
||||||
for _, node := range r.nodes {
|
for _, node := range r.nodes {
|
||||||
if bytes.Equal(nodePub[:], node.PubKeyBytes[:]) {
|
if bytes.Equal(nodePub[:], node.PubKeyBytes[:]) {
|
||||||
|
|||||||
+9
-9
@@ -873,7 +873,7 @@ func (b *Builder) assertNodeAnnFreshness(ctx context.Context, node route.Vertex,
|
|||||||
// node announcements, we will ignore such nodes. If we do know about
|
// node announcements, we will ignore such nodes. If we do know about
|
||||||
// this node, check that this update brings info newer than what we
|
// this node, check that this update brings info newer than what we
|
||||||
// already have.
|
// already have.
|
||||||
lastUpdate, exists, err := b.cfg.Graph.HasLightningNode(ctx, node)
|
lastUpdate, exists, err := b.cfg.Graph.HasNode(ctx, node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to query for the "+
|
return fmt.Errorf("unable to query for the "+
|
||||||
"existence of node: %w", err)
|
"existence of node: %w", err)
|
||||||
@@ -975,7 +975,7 @@ func (b *Builder) ApplyChannelUpdate(msg *lnwire.ChannelUpdate1) bool {
|
|||||||
// be ignored.
|
// be ignored.
|
||||||
//
|
//
|
||||||
// NOTE: This method is part of the ChannelGraphSource interface.
|
// NOTE: This method is part of the ChannelGraphSource interface.
|
||||||
func (b *Builder) AddNode(ctx context.Context, node *models.LightningNode,
|
func (b *Builder) AddNode(ctx context.Context, node *models.Node,
|
||||||
op ...batch.SchedulerOption) error {
|
op ...batch.SchedulerOption) error {
|
||||||
|
|
||||||
err := b.addNode(ctx, node, op...)
|
err := b.addNode(ctx, node, op...)
|
||||||
@@ -988,11 +988,11 @@ func (b *Builder) AddNode(ctx context.Context, node *models.LightningNode,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// addNode does some basic checks on the given LightningNode against what we
|
// addNode does some basic checks on the given Node against what we
|
||||||
// currently have persisted in the graph, and then adds it to the graph. If we
|
// currently have persisted in the graph, and then adds it to the graph. If we
|
||||||
// already know about the node, then we only update our DB if the new update
|
// already know about the node, then we only update our DB if the new update
|
||||||
// has a newer timestamp than the last one we received.
|
// has a newer timestamp than the last one we received.
|
||||||
func (b *Builder) addNode(ctx context.Context, node *models.LightningNode,
|
func (b *Builder) addNode(ctx context.Context, node *models.Node,
|
||||||
op ...batch.SchedulerOption) error {
|
op ...batch.SchedulerOption) error {
|
||||||
|
|
||||||
// Before we add the node to the database, we'll check to see if the
|
// Before we add the node to the database, we'll check to see if the
|
||||||
@@ -1003,7 +1003,7 @@ func (b *Builder) addNode(ctx context.Context, node *models.LightningNode,
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := b.cfg.Graph.AddLightningNode(ctx, node, op...); err != nil {
|
if err := b.cfg.Graph.AddNode(ctx, node, op...); err != nil {
|
||||||
return fmt.Errorf("unable to add node %x to the "+
|
return fmt.Errorf("unable to add node %x to the "+
|
||||||
"graph: %w", node.PubKeyBytes, err)
|
"graph: %w", node.PubKeyBytes, err)
|
||||||
}
|
}
|
||||||
@@ -1257,15 +1257,15 @@ func (b *Builder) GetChannelByID(chanID lnwire.ShortChannelID) (
|
|||||||
return b.cfg.Graph.FetchChannelEdgesByID(chanID.ToUint64())
|
return b.cfg.Graph.FetchChannelEdgesByID(chanID.ToUint64())
|
||||||
}
|
}
|
||||||
|
|
||||||
// FetchLightningNode attempts to look up a target node by its identity public
|
// FetchNode attempts to look up a target node by its identity public
|
||||||
// key. graphdb.ErrGraphNodeNotFound is returned if the node doesn't exist
|
// key. graphdb.ErrGraphNodeNotFound is returned if the node doesn't exist
|
||||||
// within the graph.
|
// within the graph.
|
||||||
//
|
//
|
||||||
// NOTE: This method is part of the ChannelGraphSource interface.
|
// NOTE: This method is part of the ChannelGraphSource interface.
|
||||||
func (b *Builder) FetchLightningNode(ctx context.Context,
|
func (b *Builder) FetchNode(ctx context.Context,
|
||||||
node route.Vertex) (*models.LightningNode, error) {
|
node route.Vertex) (*models.Node, error) {
|
||||||
|
|
||||||
return b.cfg.Graph.FetchLightningNode(ctx, node)
|
return b.cfg.Graph.FetchNode(ctx, node)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ForAllOutgoingChannels is used to iterate over all outgoing channels owned by
|
// ForAllOutgoingChannels is used to iterate over all outgoing channels owned by
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ func TestIgnoreNodeAnnouncement(t *testing.T) {
|
|||||||
ctx := createTestCtxFromFile(t, startingBlockHeight, basicGraphFilePath)
|
ctx := createTestCtxFromFile(t, startingBlockHeight, basicGraphFilePath)
|
||||||
|
|
||||||
pub := priv1.PubKey()
|
pub := priv1.PubKey()
|
||||||
node := &models.LightningNode{
|
node := &models.Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
LastUpdate: time.Unix(123, 0),
|
LastUpdate: time.Unix(123, 0),
|
||||||
Addresses: testAddrs,
|
Addresses: testAddrs,
|
||||||
@@ -1084,7 +1084,7 @@ func TestIsStaleNode(t *testing.T) {
|
|||||||
|
|
||||||
// With the node stub in the database, we'll add the fully node
|
// With the node stub in the database, we'll add the fully node
|
||||||
// announcement to the database.
|
// announcement to the database.
|
||||||
n1 := &models.LightningNode{
|
n1 := &models.Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
LastUpdate: updateTimeStamp,
|
LastUpdate: updateTimeStamp,
|
||||||
Addresses: testAddrs,
|
Addresses: testAddrs,
|
||||||
@@ -1392,7 +1392,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
|
|||||||
privKeyMap := make(map[string]*btcec.PrivateKey)
|
privKeyMap := make(map[string]*btcec.PrivateKey)
|
||||||
channelIDs := make(map[route.Vertex]map[route.Vertex]uint64)
|
channelIDs := make(map[route.Vertex]map[route.Vertex]uint64)
|
||||||
links := make(map[lnwire.ShortChannelID]htlcswitch.ChannelLink)
|
links := make(map[lnwire.ShortChannelID]htlcswitch.ChannelLink)
|
||||||
var source *models.LightningNode
|
var source *models.Node
|
||||||
|
|
||||||
// First we insert all the nodes within the graph as vertexes.
|
// First we insert all the nodes within the graph as vertexes.
|
||||||
for _, node := range g.Nodes {
|
for _, node := range g.Nodes {
|
||||||
@@ -1401,7 +1401,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
dbNode := &models.LightningNode{
|
dbNode := &models.Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
AuthSigBytes: testSig.Serialize(),
|
AuthSigBytes: testSig.Serialize(),
|
||||||
LastUpdate: testTime,
|
LastUpdate: testTime,
|
||||||
@@ -1475,7 +1475,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
|
|||||||
|
|
||||||
// With the node fully parsed, add it as a vertex within the
|
// With the node fully parsed, add it as a vertex within the
|
||||||
// graph.
|
// graph.
|
||||||
if err := graph.AddLightningNode(ctx, dbNode); err != nil {
|
if err := graph.AddNode(ctx, dbNode); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1787,7 +1787,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
|
|||||||
features = lnwire.EmptyFeatureVector()
|
features = lnwire.EmptyFeatureVector()
|
||||||
}
|
}
|
||||||
|
|
||||||
dbNode := &models.LightningNode{
|
dbNode := &models.Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
AuthSigBytes: testSig.Serialize(),
|
AuthSigBytes: testSig.Serialize(),
|
||||||
LastUpdate: testTime,
|
LastUpdate: testTime,
|
||||||
@@ -1806,7 +1806,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
|
|||||||
err = graph.SetSourceNode(ctx, dbNode)
|
err = graph.SetSourceNode(ctx, dbNode)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
} else {
|
} else {
|
||||||
err := graph.AddLightningNode(ctx, dbNode)
|
err := graph.AddNode(ctx, dbNode)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -350,7 +350,7 @@ func TestPopulateDBs(t *testing.T) {
|
|||||||
countNodes := func(graph *ChannelGraph) int {
|
countNodes := func(graph *ChannelGraph) int {
|
||||||
numNodes := 0
|
numNodes := 0
|
||||||
err := graph.ForEachNode(
|
err := graph.ForEachNode(
|
||||||
ctx, func(node *models.LightningNode) error {
|
ctx, func(node *models.Node) error {
|
||||||
numNodes++
|
numNodes++
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -580,12 +580,12 @@ func syncGraph(t *testing.T, src, dest *ChannelGraph) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var wgNodes sync.WaitGroup
|
var wgNodes sync.WaitGroup
|
||||||
err := src.ForEachNode(ctx, func(node *models.LightningNode) error {
|
err := src.ForEachNode(ctx, func(node *models.Node) error {
|
||||||
wgNodes.Add(1)
|
wgNodes.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer wgNodes.Done()
|
defer wgNodes.Done()
|
||||||
|
|
||||||
err := dest.AddLightningNode(ctx, node, batch.LazyAdd())
|
err := dest.AddNode(ctx, node, batch.LazyAdd())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
@@ -746,7 +746,7 @@ func BenchmarkGraphReadMethods(b *testing.B) {
|
|||||||
fn: func(b testing.TB, store V1Store) {
|
fn: func(b testing.TB, store V1Store) {
|
||||||
err := store.ForEachNode(
|
err := store.ForEachNode(
|
||||||
ctx,
|
ctx,
|
||||||
func(_ *models.LightningNode) error {
|
func(_ *models.Node) error {
|
||||||
// Increment the counter to
|
// Increment the counter to
|
||||||
// ensure the callback is doing
|
// ensure the callback is doing
|
||||||
// something.
|
// something.
|
||||||
@@ -932,10 +932,9 @@ func BenchmarkFindOptimalSQLQueryConfig(b *testing.B) {
|
|||||||
numChannels = 0
|
numChannels = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
//nolint:ll
|
|
||||||
err := store.ForEachNode(
|
err := store.ForEachNode(
|
||||||
ctx,
|
ctx,
|
||||||
func(_ *models.LightningNode) error {
|
func(_ *models.Node) error {
|
||||||
numNodes++
|
numNodes++
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
+7
-7
@@ -266,16 +266,16 @@ func (c *ChannelGraph) ForEachNodeCached(ctx context.Context, withAddrs bool,
|
|||||||
return c.V1Store.ForEachNodeCached(ctx, withAddrs, cb, reset)
|
return c.V1Store.ForEachNodeCached(ctx, withAddrs, cb, reset)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddLightningNode adds a vertex/node to the graph database. If the node is not
|
// AddNode adds a vertex/node to the graph database. If the node is not
|
||||||
// in the database from before, this will add a new, unconnected one to the
|
// in the database from before, this will add a new, unconnected one to the
|
||||||
// graph. If it is present from before, this will update that node's
|
// graph. If it is present from before, this will update that node's
|
||||||
// information. Note that this method is expected to only be called to update an
|
// information. Note that this method is expected to only be called to update an
|
||||||
// already present node from a node announcement, or to insert a node found in a
|
// already present node from a node announcement, or to insert a node found in a
|
||||||
// channel update.
|
// channel update.
|
||||||
func (c *ChannelGraph) AddLightningNode(ctx context.Context,
|
func (c *ChannelGraph) AddNode(ctx context.Context,
|
||||||
node *models.LightningNode, op ...batch.SchedulerOption) error {
|
node *models.Node, op ...batch.SchedulerOption) error {
|
||||||
|
|
||||||
err := c.V1Store.AddLightningNode(ctx, node, op...)
|
err := c.V1Store.AddNode(ctx, node, op...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -295,12 +295,12 @@ func (c *ChannelGraph) AddLightningNode(ctx context.Context,
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteLightningNode starts a new database transaction to remove a vertex/node
|
// DeleteNode starts a new database transaction to remove a vertex/node
|
||||||
// from the database according to the node's public key.
|
// from the database according to the node's public key.
|
||||||
func (c *ChannelGraph) DeleteLightningNode(ctx context.Context,
|
func (c *ChannelGraph) DeleteNode(ctx context.Context,
|
||||||
nodePub route.Vertex) error {
|
nodePub route.Vertex) error {
|
||||||
|
|
||||||
err := c.V1Store.DeleteLightningNode(ctx, nodePub)
|
err := c.V1Store.DeleteNode(ctx, nodePub)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
+96
-96
@@ -69,9 +69,9 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func createLightningNode(priv *btcec.PrivateKey) *models.LightningNode {
|
func createNode(priv *btcec.PrivateKey) *models.Node {
|
||||||
pub := priv.PubKey().SerializeCompressed()
|
pub := priv.PubKey().SerializeCompressed()
|
||||||
n := &models.LightningNode{
|
n := &models.Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
AuthSigBytes: testSig.Serialize(),
|
AuthSigBytes: testSig.Serialize(),
|
||||||
LastUpdate: nextUpdateTime(),
|
LastUpdate: nextUpdateTime(),
|
||||||
@@ -85,16 +85,16 @@ func createLightningNode(priv *btcec.PrivateKey) *models.LightningNode {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTestVertex(t testing.TB) *models.LightningNode {
|
func createTestVertex(t testing.TB) *models.Node {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
priv, err := btcec.NewPrivateKey()
|
priv, err := btcec.NewPrivateKey()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
return createLightningNode(priv)
|
return createNode(priv)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestNodeInsertionAndDeletion tests the CRUD operations for a LightningNode.
|
// TestNodeInsertionAndDeletion tests the CRUD operations for a Node.
|
||||||
func TestNodeInsertionAndDeletion(t *testing.T) {
|
func TestNodeInsertionAndDeletion(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
ctx := t.Context()
|
ctx := t.Context()
|
||||||
@@ -104,9 +104,9 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
|
|||||||
// We'd like to test basic insertion/deletion for vertexes from the
|
// We'd like to test basic insertion/deletion for vertexes from the
|
||||||
// graph, so we'll create a test vertex to start with.
|
// graph, so we'll create a test vertex to start with.
|
||||||
timeStamp := int64(1232342)
|
timeStamp := int64(1232342)
|
||||||
nodeWithAddrs := func(addrs []net.Addr) *models.LightningNode {
|
nodeWithAddrs := func(addrs []net.Addr) *models.Node {
|
||||||
timeStamp++
|
timeStamp++
|
||||||
return &models.LightningNode{
|
return &models.Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
AuthSigBytes: testSig.Serialize(),
|
AuthSigBytes: testSig.Serialize(),
|
||||||
LastUpdate: time.Unix(timeStamp, 0),
|
LastUpdate: time.Unix(timeStamp, 0),
|
||||||
@@ -122,15 +122,15 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
|
|||||||
// First, insert the node into the graph DB. This should succeed
|
// First, insert the node into the graph DB. This should succeed
|
||||||
// without any errors.
|
// without any errors.
|
||||||
node := nodeWithAddrs(testAddrs)
|
node := nodeWithAddrs(testAddrs)
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node))
|
require.NoError(t, graph.AddNode(ctx, node))
|
||||||
assertNodeInCache(t, graph, node, testFeatures)
|
assertNodeInCache(t, graph, node, testFeatures)
|
||||||
|
|
||||||
// Next, fetch the node from the database to ensure everything was
|
// Next, fetch the node from the database to ensure everything was
|
||||||
// serialized properly.
|
// serialized properly.
|
||||||
dbNode, err := graph.FetchLightningNode(ctx, testPub)
|
dbNode, err := graph.FetchNode(ctx, testPub)
|
||||||
require.NoError(t, err, "unable to locate node")
|
require.NoError(t, err, "unable to locate node")
|
||||||
|
|
||||||
_, exists, err := graph.HasLightningNode(ctx, dbNode.PubKeyBytes)
|
_, exists, err := graph.HasNode(ctx, dbNode.PubKeyBytes)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.True(t, exists)
|
require.True(t, exists)
|
||||||
|
|
||||||
@@ -151,19 +151,19 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
|
|||||||
|
|
||||||
// Next, delete the node from the graph, this should purge all data
|
// Next, delete the node from the graph, this should purge all data
|
||||||
// related to the node.
|
// related to the node.
|
||||||
require.NoError(t, graph.DeleteLightningNode(ctx, testPub))
|
require.NoError(t, graph.DeleteNode(ctx, testPub))
|
||||||
assertNodeNotInCache(t, graph, testPub)
|
assertNodeNotInCache(t, graph, testPub)
|
||||||
|
|
||||||
// Attempting to delete the node again should return an error since
|
// Attempting to delete the node again should return an error since
|
||||||
// the node is no longer known.
|
// the node is no longer known.
|
||||||
require.ErrorIs(
|
require.ErrorIs(
|
||||||
t, graph.DeleteLightningNode(ctx, testPub),
|
t, graph.DeleteNode(ctx, testPub),
|
||||||
ErrGraphNodeNotFound,
|
ErrGraphNodeNotFound,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Finally, attempt to fetch the node again. This should fail as the
|
// Finally, attempt to fetch the node again. This should fail as the
|
||||||
// node should have been deleted from the database.
|
// node should have been deleted from the database.
|
||||||
_, err = graph.FetchLightningNode(ctx, testPub)
|
_, err = graph.FetchNode(ctx, testPub)
|
||||||
require.ErrorIs(t, err, ErrGraphNodeNotFound)
|
require.ErrorIs(t, err, ErrGraphNodeNotFound)
|
||||||
|
|
||||||
// Now, we'll specifically test the updating of addresses of a node
|
// Now, we'll specifically test the updating of addresses of a node
|
||||||
@@ -182,10 +182,10 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
|
|||||||
|
|
||||||
// Add the node without any addresses.
|
// Add the node without any addresses.
|
||||||
node = nodeWithAddrs(nil)
|
node = nodeWithAddrs(nil)
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node))
|
require.NoError(t, graph.AddNode(ctx, node))
|
||||||
|
|
||||||
// Fetch the node and assert the empty addresses.
|
// Fetch the node and assert the empty addresses.
|
||||||
dbNode, err = graph.FetchLightningNode(ctx, testPub)
|
dbNode, err = graph.FetchNode(ctx, testPub)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
compareNodes(t, node, dbNode)
|
compareNodes(t, node, dbNode)
|
||||||
|
|
||||||
@@ -211,10 +211,10 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
|
|||||||
testOpaqueAddr,
|
testOpaqueAddr,
|
||||||
}
|
}
|
||||||
node = nodeWithAddrs(expAddrs)
|
node = nodeWithAddrs(expAddrs)
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node))
|
require.NoError(t, graph.AddNode(ctx, node))
|
||||||
|
|
||||||
// Fetch the node and assert the updated addresses.
|
// Fetch the node and assert the updated addresses.
|
||||||
dbNode, err = graph.FetchLightningNode(ctx, testPub)
|
dbNode, err = graph.FetchNode(ctx, testPub)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, expAddrs, dbNode.Addresses)
|
require.Equal(t, expAddrs, dbNode.Addresses)
|
||||||
|
|
||||||
@@ -232,10 +232,10 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
|
|||||||
testIPV6Addr,
|
testIPV6Addr,
|
||||||
}
|
}
|
||||||
node = nodeWithAddrs(expAddrs)
|
node = nodeWithAddrs(expAddrs)
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node))
|
require.NoError(t, graph.AddNode(ctx, node))
|
||||||
|
|
||||||
// Fetch the node and assert the updated addresses.
|
// Fetch the node and assert the updated addresses.
|
||||||
dbNode, err = graph.FetchLightningNode(ctx, testPub)
|
dbNode, err = graph.FetchNode(ctx, testPub)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, expAddrs, dbNode.Addresses)
|
require.Equal(t, expAddrs, dbNode.Addresses)
|
||||||
|
|
||||||
@@ -245,10 +245,10 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
|
|||||||
testOnionV3Addr,
|
testOnionV3Addr,
|
||||||
}
|
}
|
||||||
node = nodeWithAddrs(expAddrs)
|
node = nodeWithAddrs(expAddrs)
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node))
|
require.NoError(t, graph.AddNode(ctx, node))
|
||||||
|
|
||||||
// Fetch the node and assert the updated addresses.
|
// Fetch the node and assert the updated addresses.
|
||||||
dbNode, err = graph.FetchLightningNode(ctx, testPub)
|
dbNode, err = graph.FetchNode(ctx, testPub)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, expAddrs, dbNode.Addresses)
|
require.Equal(t, expAddrs, dbNode.Addresses)
|
||||||
|
|
||||||
@@ -271,7 +271,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestPartialNode checks that we can add and retrieve a LightningNode where
|
// TestPartialNode checks that we can add and retrieve a Node where
|
||||||
// only the pubkey is known to the database.
|
// only the pubkey is known to the database.
|
||||||
func TestPartialNode(t *testing.T) {
|
func TestPartialNode(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
@@ -281,7 +281,7 @@ func TestPartialNode(t *testing.T) {
|
|||||||
|
|
||||||
// To insert a partial node, we need to add a channel edge that has
|
// To insert a partial node, we need to add a channel edge that has
|
||||||
// node keys for nodes we are not yet aware
|
// node keys for nodes we are not yet aware
|
||||||
var node1, node2 models.LightningNode
|
var node1, node2 models.Node
|
||||||
copy(node1.PubKeyBytes[:], pubKey1Bytes)
|
copy(node1.PubKeyBytes[:], pubKey1Bytes)
|
||||||
copy(node2.PubKeyBytes[:], pubKey2Bytes)
|
copy(node2.PubKeyBytes[:], pubKey2Bytes)
|
||||||
|
|
||||||
@@ -296,18 +296,18 @@ func TestPartialNode(t *testing.T) {
|
|||||||
|
|
||||||
// Next, fetch the node2 from the database to ensure everything was
|
// Next, fetch the node2 from the database to ensure everything was
|
||||||
// serialized properly.
|
// serialized properly.
|
||||||
dbNode1, err := graph.FetchLightningNode(ctx, pubKey1)
|
dbNode1, err := graph.FetchNode(ctx, pubKey1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
dbNode2, err := graph.FetchLightningNode(ctx, pubKey2)
|
dbNode2, err := graph.FetchNode(ctx, pubKey2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
_, exists, err := graph.HasLightningNode(ctx, dbNode1.PubKeyBytes)
|
_, exists, err := graph.HasNode(ctx, dbNode1.PubKeyBytes)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.True(t, exists)
|
require.True(t, exists)
|
||||||
|
|
||||||
// The two nodes should match exactly! (with default values for
|
// The two nodes should match exactly! (with default values for
|
||||||
// LastUpdate and db set to satisfy compareNodes())
|
// LastUpdate and db set to satisfy compareNodes())
|
||||||
expectedNode1 := &models.LightningNode{
|
expectedNode1 := &models.Node{
|
||||||
HaveNodeAnnouncement: false,
|
HaveNodeAnnouncement: false,
|
||||||
LastUpdate: time.Unix(0, 0),
|
LastUpdate: time.Unix(0, 0),
|
||||||
PubKeyBytes: pubKey1,
|
PubKeyBytes: pubKey1,
|
||||||
@@ -315,13 +315,13 @@ func TestPartialNode(t *testing.T) {
|
|||||||
}
|
}
|
||||||
compareNodes(t, expectedNode1, dbNode1)
|
compareNodes(t, expectedNode1, dbNode1)
|
||||||
|
|
||||||
_, exists, err = graph.HasLightningNode(ctx, dbNode2.PubKeyBytes)
|
_, exists, err = graph.HasNode(ctx, dbNode2.PubKeyBytes)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.True(t, exists)
|
require.True(t, exists)
|
||||||
|
|
||||||
// The two nodes should match exactly! (with default values for
|
// The two nodes should match exactly! (with default values for
|
||||||
// LastUpdate and db set to satisfy compareNodes())
|
// LastUpdate and db set to satisfy compareNodes())
|
||||||
expectedNode2 := &models.LightningNode{
|
expectedNode2 := &models.Node{
|
||||||
HaveNodeAnnouncement: false,
|
HaveNodeAnnouncement: false,
|
||||||
LastUpdate: time.Unix(0, 0),
|
LastUpdate: time.Unix(0, 0),
|
||||||
PubKeyBytes: pubKey2,
|
PubKeyBytes: pubKey2,
|
||||||
@@ -331,12 +331,12 @@ func TestPartialNode(t *testing.T) {
|
|||||||
|
|
||||||
// Next, delete the node from the graph, this should purge all data
|
// Next, delete the node from the graph, this should purge all data
|
||||||
// related to the node.
|
// related to the node.
|
||||||
require.NoError(t, graph.DeleteLightningNode(ctx, pubKey1))
|
require.NoError(t, graph.DeleteNode(ctx, pubKey1))
|
||||||
assertNodeNotInCache(t, graph, testPub)
|
assertNodeNotInCache(t, graph, testPub)
|
||||||
|
|
||||||
// Finally, attempt to fetch the node again. This should fail as the
|
// Finally, attempt to fetch the node again. This should fail as the
|
||||||
// node should have been deleted from the database.
|
// node should have been deleted from the database.
|
||||||
_, err = graph.FetchLightningNode(ctx, testPub)
|
_, err = graph.FetchNode(ctx, testPub)
|
||||||
require.ErrorIs(t, err, ErrGraphNodeNotFound)
|
require.ErrorIs(t, err, ErrGraphNodeNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,7 +353,7 @@ func TestAliasLookup(t *testing.T) {
|
|||||||
|
|
||||||
// Add the node to the graph's database, this should also insert an
|
// Add the node to the graph's database, this should also insert an
|
||||||
// entry into the alias index for this node.
|
// entry into the alias index for this node.
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, testNode))
|
require.NoError(t, graph.AddNode(ctx, testNode))
|
||||||
|
|
||||||
// Next, attempt to lookup the alias. The alias should exactly match
|
// Next, attempt to lookup the alias. The alias should exactly match
|
||||||
// the one which the test node was assigned.
|
// the one which the test node was assigned.
|
||||||
@@ -484,7 +484,7 @@ func TestEdgeInsertionDeletion(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func createEdge(height, txIndex uint32, txPosition uint16, outPointIndex uint32,
|
func createEdge(height, txIndex uint32, txPosition uint16, outPointIndex uint32,
|
||||||
node1, node2 *models.LightningNode) (models.ChannelEdgeInfo,
|
node1, node2 *models.Node) (models.ChannelEdgeInfo,
|
||||||
lnwire.ShortChannelID) {
|
lnwire.ShortChannelID) {
|
||||||
|
|
||||||
shortChanID := lnwire.ShortChannelID{
|
shortChanID := lnwire.ShortChannelID{
|
||||||
@@ -724,7 +724,7 @@ func withSkipProofs() createEdgeOpt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createChannelEdge(node1, node2 *models.LightningNode,
|
func createChannelEdge(node1, node2 *models.Node,
|
||||||
options ...createEdgeOpt) (*models.ChannelEdgeInfo,
|
options ...createEdgeOpt) (*models.ChannelEdgeInfo,
|
||||||
*models.ChannelEdgePolicy, *models.ChannelEdgePolicy) {
|
*models.ChannelEdgePolicy, *models.ChannelEdgePolicy) {
|
||||||
|
|
||||||
@@ -824,12 +824,12 @@ func TestEdgeInfoUpdates(t *testing.T) {
|
|||||||
// We'd like to test the update of edges inserted into the database, so
|
// We'd like to test the update of edges inserted into the database, so
|
||||||
// we create two vertexes to connect.
|
// we create two vertexes to connect.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node1); err != nil {
|
if err := graph.AddNode(ctx, node1); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
assertNodeInCache(t, graph, node1, testFeatures)
|
assertNodeInCache(t, graph, node1, testFeatures)
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node2); err != nil {
|
if err := graph.AddNode(ctx, node2); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
assertNodeInCache(t, graph, node2, testFeatures)
|
assertNodeInCache(t, graph, node2, testFeatures)
|
||||||
@@ -982,7 +982,7 @@ func TestEdgePolicyCRUD(t *testing.T) {
|
|||||||
updateAndAssertPolicies()
|
updateAndAssertPolicies()
|
||||||
}
|
}
|
||||||
|
|
||||||
func assertNodeInCache(t *testing.T, g *ChannelGraph, n *models.LightningNode,
|
func assertNodeInCache(t *testing.T, g *ChannelGraph, n *models.Node,
|
||||||
expectedFeatures *lnwire.FeatureVector) {
|
expectedFeatures *lnwire.FeatureVector) {
|
||||||
|
|
||||||
// Let's check the internal view first.
|
// Let's check the internal view first.
|
||||||
@@ -1335,7 +1335,7 @@ func TestForEachSourceNodeChannel(t *testing.T) {
|
|||||||
// Now, we'll use the ForEachSourceNodeChannel and assert that it
|
// Now, we'll use the ForEachSourceNodeChannel and assert that it
|
||||||
// returns the expected data in the call-back.
|
// returns the expected data in the call-back.
|
||||||
err := graph.ForEachSourceNodeChannel(ctx, func(chanPoint wire.OutPoint,
|
err := graph.ForEachSourceNodeChannel(ctx, func(chanPoint wire.OutPoint,
|
||||||
havePolicy bool, otherNode *models.LightningNode) error {
|
havePolicy bool, otherNode *models.Node) error {
|
||||||
|
|
||||||
require.Contains(t, expectedSrcChans, chanPoint)
|
require.Contains(t, expectedSrcChans, chanPoint)
|
||||||
expected := expectedSrcChans[chanPoint]
|
expected := expectedSrcChans[chanPoint]
|
||||||
@@ -1468,7 +1468,7 @@ func TestGraphTraversalCacheable(t *testing.T) {
|
|||||||
// Create a map of all nodes with the iteration we know works (because
|
// Create a map of all nodes with the iteration we know works (because
|
||||||
// it is tested in another test).
|
// it is tested in another test).
|
||||||
nodeMap := make(map[route.Vertex]struct{})
|
nodeMap := make(map[route.Vertex]struct{})
|
||||||
err := graph.ForEachNode(ctx, func(n *models.LightningNode) error {
|
err := graph.ForEachNode(ctx, func(n *models.Node) error {
|
||||||
nodeMap[n.PubKeyBytes] = struct{}{}
|
nodeMap[n.PubKeyBytes] = struct{}{}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -1579,11 +1579,11 @@ func TestGraphCacheTraversal(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func fillTestGraph(t testing.TB, graph *ChannelGraph, numNodes,
|
func fillTestGraph(t testing.TB, graph *ChannelGraph, numNodes,
|
||||||
numChannels int) (map[uint64]struct{}, []*models.LightningNode) {
|
numChannels int) (map[uint64]struct{}, []*models.Node) {
|
||||||
|
|
||||||
ctx := t.Context()
|
ctx := t.Context()
|
||||||
|
|
||||||
nodes := make([]*models.LightningNode, numNodes)
|
nodes := make([]*models.Node, numNodes)
|
||||||
nodeIndex := map[string]struct{}{}
|
nodeIndex := map[string]struct{}{}
|
||||||
for i := 0; i < numNodes; i++ {
|
for i := 0; i < numNodes; i++ {
|
||||||
node := createTestVertex(t)
|
node := createTestVertex(t)
|
||||||
@@ -1595,12 +1595,12 @@ func fillTestGraph(t testing.TB, graph *ChannelGraph, numNodes,
|
|||||||
// Add each of the nodes into the graph, they should be inserted
|
// Add each of the nodes into the graph, they should be inserted
|
||||||
// without error.
|
// without error.
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node))
|
require.NoError(t, graph.AddNode(ctx, node))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate over each node as returned by the graph, if all nodes are
|
// Iterate over each node as returned by the graph, if all nodes are
|
||||||
// reached, then the map created above should be empty.
|
// reached, then the map created above should be empty.
|
||||||
err := graph.ForEachNode(ctx, func(n *models.LightningNode) error {
|
err := graph.ForEachNode(ctx, func(n *models.Node) error {
|
||||||
delete(nodeIndex, n.Alias)
|
delete(nodeIndex, n.Alias)
|
||||||
return nil
|
return nil
|
||||||
}, func() {})
|
}, func() {})
|
||||||
@@ -1710,7 +1710,7 @@ func assertNumChans(t *testing.T, graph *ChannelGraph, n int) {
|
|||||||
func assertNumNodes(t *testing.T, graph *ChannelGraph, n int) {
|
func assertNumNodes(t *testing.T, graph *ChannelGraph, n int) {
|
||||||
numNodes := 0
|
numNodes := 0
|
||||||
err := graph.ForEachNode(t.Context(),
|
err := graph.ForEachNode(t.Context(),
|
||||||
func(_ *models.LightningNode) error {
|
func(_ *models.Node) error {
|
||||||
numNodes++
|
numNodes++
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -1784,11 +1784,11 @@ func TestGraphPruning(t *testing.T) {
|
|||||||
// and enough edges to create a fully connected graph. The graph will
|
// and enough edges to create a fully connected graph. The graph will
|
||||||
// be rather simple, representing a straight line.
|
// be rather simple, representing a straight line.
|
||||||
const numNodes = 5
|
const numNodes = 5
|
||||||
graphNodes := make([]*models.LightningNode, numNodes)
|
graphNodes := make([]*models.Node, numNodes)
|
||||||
for i := 0; i < numNodes; i++ {
|
for i := 0; i < numNodes; i++ {
|
||||||
node := createTestVertex(t)
|
node := createTestVertex(t)
|
||||||
|
|
||||||
if err := graph.AddLightningNode(ctx, node); err != nil {
|
if err := graph.AddNode(ctx, node); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2039,11 +2039,11 @@ func TestChanUpdatesInHorizon(t *testing.T) {
|
|||||||
|
|
||||||
// We'll start by creating two nodes which will seed our test graph.
|
// We'll start by creating two nodes which will seed our test graph.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node1); err != nil {
|
if err := graph.AddNode(ctx, node1); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node2); err != nil {
|
if err := graph.AddNode(ctx, node2); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2198,7 +2198,7 @@ func TestNodeUpdatesInHorizon(t *testing.T) {
|
|||||||
// We'll create 10 node announcements, each with an update timestamp 10
|
// We'll create 10 node announcements, each with an update timestamp 10
|
||||||
// seconds after the other.
|
// seconds after the other.
|
||||||
const numNodes = 10
|
const numNodes = 10
|
||||||
nodeAnns := make([]models.LightningNode, 0, numNodes)
|
nodeAnns := make([]models.Node, 0, numNodes)
|
||||||
for i := 0; i < numNodes; i++ {
|
for i := 0; i < numNodes; i++ {
|
||||||
nodeAnn := createTestVertex(t)
|
nodeAnn := createTestVertex(t)
|
||||||
|
|
||||||
@@ -2212,14 +2212,14 @@ func TestNodeUpdatesInHorizon(t *testing.T) {
|
|||||||
|
|
||||||
nodeAnns = append(nodeAnns, *nodeAnn)
|
nodeAnns = append(nodeAnns, *nodeAnn)
|
||||||
|
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, nodeAnn))
|
require.NoError(t, graph.AddNode(ctx, nodeAnn))
|
||||||
}
|
}
|
||||||
|
|
||||||
queryCases := []struct {
|
queryCases := []struct {
|
||||||
start time.Time
|
start time.Time
|
||||||
end time.Time
|
end time.Time
|
||||||
|
|
||||||
resp []models.LightningNode
|
resp []models.Node
|
||||||
}{
|
}{
|
||||||
// If we query for a time range that's strictly below our set
|
// If we query for a time range that's strictly below our set
|
||||||
// of updates, then we'll get an empty result back.
|
// of updates, then we'll get an empty result back.
|
||||||
@@ -2384,11 +2384,11 @@ func TestFilterKnownChanIDs(t *testing.T) {
|
|||||||
|
|
||||||
// We'll start by creating two nodes which will seed our test graph.
|
// We'll start by creating two nodes which will seed our test graph.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node1); err != nil {
|
if err := graph.AddNode(ctx, node1); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node2); err != nil {
|
if err := graph.AddNode(ctx, node2); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2539,10 +2539,10 @@ func TestStressTestChannelGraphAPI(t *testing.T) {
|
|||||||
graph := MakeTestGraph(t)
|
graph := MakeTestGraph(t)
|
||||||
|
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node1))
|
require.NoError(t, graph.AddNode(ctx, node1))
|
||||||
|
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node2))
|
require.NoError(t, graph.AddNode(ctx, node2))
|
||||||
|
|
||||||
// We need to update the node's timestamp since this call to
|
// We need to update the node's timestamp since this call to
|
||||||
// SetSourceNode will trigger an upsert which will only be allowed if
|
// SetSourceNode will trigger an upsert which will only be allowed if
|
||||||
@@ -2830,10 +2830,10 @@ func TestFilterChannelRange(t *testing.T) {
|
|||||||
// We'll first populate our graph with two nodes. All channels created
|
// We'll first populate our graph with two nodes. All channels created
|
||||||
// below will be made between these two nodes.
|
// below will be made between these two nodes.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node1))
|
require.NoError(t, graph.AddNode(ctx, node1))
|
||||||
|
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node2))
|
require.NoError(t, graph.AddNode(ctx, node2))
|
||||||
|
|
||||||
// If we try to filter a channel range before we have any channels
|
// If we try to filter a channel range before we have any channels
|
||||||
// inserted, we should get an empty slice of results.
|
// inserted, we should get an empty slice of results.
|
||||||
@@ -2857,7 +2857,7 @@ func TestFilterChannelRange(t *testing.T) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
updateTimeSeed := time.Now().Unix()
|
updateTimeSeed := time.Now().Unix()
|
||||||
maybeAddPolicy := func(chanID uint64, node *models.LightningNode,
|
maybeAddPolicy := func(chanID uint64, node *models.Node,
|
||||||
node2 bool) time.Time {
|
node2 bool) time.Time {
|
||||||
|
|
||||||
var chanFlags lnwire.ChanUpdateChanFlags
|
var chanFlags lnwire.ChanUpdateChanFlags
|
||||||
@@ -3049,11 +3049,11 @@ func TestFetchChanInfos(t *testing.T) {
|
|||||||
// We'll first populate our graph with two nodes. All channels created
|
// We'll first populate our graph with two nodes. All channels created
|
||||||
// below will be made between these two nodes.
|
// below will be made between these two nodes.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node1); err != nil {
|
if err := graph.AddNode(ctx, node1); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node2); err != nil {
|
if err := graph.AddNode(ctx, node2); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3151,11 +3151,11 @@ func TestIncompleteChannelPolicies(t *testing.T) {
|
|||||||
|
|
||||||
// Create two nodes.
|
// Create two nodes.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node1); err != nil {
|
if err := graph.AddNode(ctx, node1); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node2); err != nil {
|
if err := graph.AddNode(ctx, node2); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3168,7 +3168,7 @@ func TestIncompleteChannelPolicies(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that channel is reported with unknown policies.
|
// Ensure that channel is reported with unknown policies.
|
||||||
checkPolicies := func(node *models.LightningNode, expectedIn,
|
checkPolicies := func(node *models.Node, expectedIn,
|
||||||
expectedOut bool) {
|
expectedOut bool) {
|
||||||
|
|
||||||
calls := 0
|
calls := 0
|
||||||
@@ -3256,11 +3256,11 @@ func TestChannelEdgePruningUpdateIndexDeletion(t *testing.T) {
|
|||||||
// We'll first populate our graph with two nodes. All channels created
|
// We'll first populate our graph with two nodes. All channels created
|
||||||
// below will be made between these two nodes.
|
// below will be made between these two nodes.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node1); err != nil {
|
if err := graph.AddNode(ctx, node1); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node2); err != nil {
|
if err := graph.AddNode(ctx, node2); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3401,15 +3401,15 @@ func TestPruneGraphNodes(t *testing.T) {
|
|||||||
// channel graph, at the end of the scenario, only two of these nodes
|
// channel graph, at the end of the scenario, only two of these nodes
|
||||||
// should still be in the graph.
|
// should still be in the graph.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node1); err != nil {
|
if err := graph.AddNode(ctx, node1); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node2); err != nil {
|
if err := graph.AddNode(ctx, node2); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
node3 := createTestVertex(t)
|
node3 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node3); err != nil {
|
if err := graph.AddNode(ctx, node3); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3443,7 +3443,7 @@ func TestPruneGraphNodes(t *testing.T) {
|
|||||||
|
|
||||||
// Finally, we'll ensure that node3, the only fully unconnected node as
|
// Finally, we'll ensure that node3, the only fully unconnected node as
|
||||||
// properly deleted from the graph and not another node in its place.
|
// properly deleted from the graph and not another node in its place.
|
||||||
_, err := graph.FetchLightningNode(ctx, node3.PubKeyBytes)
|
_, err := graph.FetchNode(ctx, node3.PubKeyBytes)
|
||||||
require.NotNil(t, err)
|
require.NotNil(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3469,11 +3469,11 @@ func TestAddChannelEdgeShellNodes(t *testing.T) {
|
|||||||
|
|
||||||
// Ensure that node1 was inserted as a full node, while node2 only has
|
// Ensure that node1 was inserted as a full node, while node2 only has
|
||||||
// a shell node present.
|
// a shell node present.
|
||||||
node1, err := graph.FetchLightningNode(ctx, node1.PubKeyBytes)
|
node1, err := graph.FetchNode(ctx, node1.PubKeyBytes)
|
||||||
require.NoError(t, err, "unable to fetch node1")
|
require.NoError(t, err, "unable to fetch node1")
|
||||||
require.True(t, node1.HaveNodeAnnouncement)
|
require.True(t, node1.HaveNodeAnnouncement)
|
||||||
|
|
||||||
node2, err = graph.FetchLightningNode(ctx, node2.PubKeyBytes)
|
node2, err = graph.FetchNode(ctx, node2.PubKeyBytes)
|
||||||
require.NoError(t, err, "unable to fetch node2")
|
require.NoError(t, err, "unable to fetch node2")
|
||||||
require.False(t, node2.HaveNodeAnnouncement)
|
require.False(t, node2.HaveNodeAnnouncement)
|
||||||
|
|
||||||
@@ -3483,7 +3483,7 @@ func TestAddChannelEdgeShellNodes(t *testing.T) {
|
|||||||
require.ErrorIs(t, err, ErrEdgeAlreadyExist)
|
require.ErrorIs(t, err, ErrEdgeAlreadyExist)
|
||||||
|
|
||||||
// Show that updating the shell node to a full node record works.
|
// Show that updating the shell node to a full node record works.
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node2))
|
require.NoError(t, graph.AddNode(ctx, node2))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestNodePruningUpdateIndexDeletion tests that once a node has been removed
|
// TestNodePruningUpdateIndexDeletion tests that once a node has been removed
|
||||||
@@ -3498,7 +3498,7 @@ func TestNodePruningUpdateIndexDeletion(t *testing.T) {
|
|||||||
// We'll first populate our graph with a single node that will be
|
// We'll first populate our graph with a single node that will be
|
||||||
// removed shortly.
|
// removed shortly.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node1); err != nil {
|
if err := graph.AddNode(ctx, node1); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3520,7 +3520,7 @@ func TestNodePruningUpdateIndexDeletion(t *testing.T) {
|
|||||||
|
|
||||||
// We'll now delete the node from the graph, this should result in it
|
// We'll now delete the node from the graph, this should result in it
|
||||||
// being removed from the update index as well.
|
// being removed from the update index as well.
|
||||||
err = graph.DeleteLightningNode(ctx, node1.PubKeyBytes)
|
err = graph.DeleteNode(ctx, node1.PubKeyBytes)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Now that the node has been deleted, we'll again query the nodes in
|
// Now that the node has been deleted, we'll again query the nodes in
|
||||||
@@ -3585,13 +3585,13 @@ func TestNodeIsPublic(t *testing.T) {
|
|||||||
|
|
||||||
// After creating all of our nodes and edges, we'll add them to each
|
// After creating all of our nodes and edges, we'll add them to each
|
||||||
// participant's graph.
|
// participant's graph.
|
||||||
nodes := []*models.LightningNode{aliceNode, bobNode, carolNode}
|
nodes := []*models.Node{aliceNode, bobNode, carolNode}
|
||||||
edges := []*models.ChannelEdgeInfo{&aliceBobEdge, &bobCarolEdge}
|
edges := []*models.ChannelEdgeInfo{&aliceBobEdge, &bobCarolEdge}
|
||||||
graphs := []*ChannelGraph{aliceGraph, bobGraph, carolGraph}
|
graphs := []*ChannelGraph{aliceGraph, bobGraph, carolGraph}
|
||||||
for _, graph := range graphs {
|
for _, graph := range graphs {
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
node.LastUpdate = nextUpdateTime()
|
node.LastUpdate = nextUpdateTime()
|
||||||
err := graph.AddLightningNode(ctx, node)
|
err := graph.AddNode(ctx, node)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
for _, edge := range edges {
|
for _, edge := range edges {
|
||||||
@@ -3602,7 +3602,7 @@ func TestNodeIsPublic(t *testing.T) {
|
|||||||
|
|
||||||
// checkNodes is a helper closure that will be used to assert that the
|
// checkNodes is a helper closure that will be used to assert that the
|
||||||
// given nodes are seen as public/private within the given graphs.
|
// given nodes are seen as public/private within the given graphs.
|
||||||
checkNodes := func(nodes []*models.LightningNode,
|
checkNodes := func(nodes []*models.Node,
|
||||||
graphs []*ChannelGraph, public bool) {
|
graphs []*ChannelGraph, public bool) {
|
||||||
|
|
||||||
t.Helper()
|
t.Helper()
|
||||||
@@ -3645,7 +3645,7 @@ func TestNodeIsPublic(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkNodes(
|
checkNodes(
|
||||||
[]*models.LightningNode{aliceNode},
|
[]*models.Node{aliceNode},
|
||||||
[]*ChannelGraph{bobGraph, carolGraph},
|
[]*ChannelGraph{bobGraph, carolGraph},
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
@@ -3676,7 +3676,7 @@ func TestNodeIsPublic(t *testing.T) {
|
|||||||
// With the modifications above, Bob should now be seen as a private
|
// With the modifications above, Bob should now be seen as a private
|
||||||
// node from both Alice's and Carol's perspective.
|
// node from both Alice's and Carol's perspective.
|
||||||
checkNodes(
|
checkNodes(
|
||||||
[]*models.LightningNode{bobNode},
|
[]*models.Node{bobNode},
|
||||||
[]*ChannelGraph{aliceGraph, carolGraph},
|
[]*ChannelGraph{aliceGraph, carolGraph},
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
@@ -3693,20 +3693,20 @@ func TestDisabledChannelIDs(t *testing.T) {
|
|||||||
|
|
||||||
// Create first node and add it to the graph.
|
// Create first node and add it to the graph.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node1); err != nil {
|
if err := graph.AddNode(ctx, node1); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create second node and add it to the graph.
|
// Create second node and add it to the graph.
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node2); err != nil {
|
if err := graph.AddNode(ctx, node2); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adding a new channel edge to the graph.
|
// Adding a new channel edge to the graph.
|
||||||
edgeInfo, edge1, edge2 := createChannelEdge(node1, node2)
|
edgeInfo, edge1, edge2 := createChannelEdge(node1, node2)
|
||||||
node2.LastUpdate = nextUpdateTime()
|
node2.LastUpdate = nextUpdateTime()
|
||||||
if err := graph.AddLightningNode(ctx, node2); err != nil {
|
if err := graph.AddNode(ctx, node2); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3785,13 +3785,13 @@ func TestEdgePolicyMissingMaxHTLC(t *testing.T) {
|
|||||||
// We'd like to test the update of edges inserted into the database, so
|
// We'd like to test the update of edges inserted into the database, so
|
||||||
// we create two vertexes to connect.
|
// we create two vertexes to connect.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
if err := graph.AddLightningNode(ctx, node1); err != nil {
|
if err := graph.AddNode(ctx, node1); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
|
|
||||||
edgeInfo, edge1, edge2 := createChannelEdge(node1, node2)
|
edgeInfo, edge1, edge2 := createChannelEdge(node1, node2)
|
||||||
if err := graph.AddLightningNode(ctx, node2); err != nil {
|
if err := graph.AddNode(ctx, node2); err != nil {
|
||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
if err := graph.AddChannelEdge(ctx, edgeInfo); err != nil {
|
if err := graph.AddChannelEdge(ctx, edgeInfo); err != nil {
|
||||||
@@ -3979,8 +3979,8 @@ func TestGraphZombieIndex(t *testing.T) {
|
|||||||
assertNumZombies(t, graph, 1)
|
assertNumZombies(t, graph, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// compareNodes is used to compare two LightningNodes.
|
// compareNodes is used to compare two Nodes.
|
||||||
func compareNodes(t *testing.T, a, b *models.LightningNode) {
|
func compareNodes(t *testing.T, a, b *models.Node) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
// Call the PubKey method for each node to ensure that the internal
|
// Call the PubKey method for each node to ensure that the internal
|
||||||
@@ -4046,7 +4046,7 @@ func compareEdgePolicies(a, b *models.ChannelEdgePolicy) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestLightningNodeSigVerification checks that we can use the LightningNode's
|
// TestLightningNodeSigVerification checks that we can use the Node's
|
||||||
// pubkey to verify signatures.
|
// pubkey to verify signatures.
|
||||||
func TestLightningNodeSigVerification(t *testing.T) {
|
func TestLightningNodeSigVerification(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
@@ -4068,8 +4068,8 @@ func TestLightningNodeSigVerification(t *testing.T) {
|
|||||||
t.Fatalf("signature doesn't check out")
|
t.Fatalf("signature doesn't check out")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a LightningNode from the same private key.
|
// Create a Node from the same private key.
|
||||||
node := createLightningNode(priv)
|
node := createNode(priv)
|
||||||
|
|
||||||
// And finally check that we can verify the same signature from the
|
// And finally check that we can verify the same signature from the
|
||||||
// pubkey returned from the lightning node.
|
// pubkey returned from the lightning node.
|
||||||
@@ -4186,9 +4186,9 @@ func TestBatchedUpdateEdgePolicy(t *testing.T) {
|
|||||||
// We'd like to test the update of edges inserted into the database, so
|
// We'd like to test the update of edges inserted into the database, so
|
||||||
// we create two vertexes to connect.
|
// we create two vertexes to connect.
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node1))
|
require.NoError(t, graph.AddNode(ctx, node1))
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node2))
|
require.NoError(t, graph.AddNode(ctx, node2))
|
||||||
|
|
||||||
// Create an edge and add it to the db.
|
// Create an edge and add it to the db.
|
||||||
edgeInfo, edge1, edge2 := createChannelEdge(node1, node2)
|
edgeInfo, edge1, edge2 := createChannelEdge(node1, node2)
|
||||||
@@ -4294,9 +4294,9 @@ func TestGraphCacheForEachNodeChannel(t *testing.T) {
|
|||||||
graph.graphCache = nil
|
graph.graphCache = nil
|
||||||
|
|
||||||
node1 := createTestVertex(t)
|
node1 := createTestVertex(t)
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node1))
|
require.NoError(t, graph.AddNode(ctx, node1))
|
||||||
node2 := createTestVertex(t)
|
node2 := createTestVertex(t)
|
||||||
require.NoError(t, graph.AddLightningNode(ctx, node2))
|
require.NoError(t, graph.AddNode(ctx, node2))
|
||||||
|
|
||||||
// Create an edge and add it to the db.
|
// Create an edge and add it to the db.
|
||||||
edgeInfo, e1, e2 := createChannelEdge(node1, node2)
|
edgeInfo, e1, e2 := createChannelEdge(node1, node2)
|
||||||
@@ -4442,7 +4442,7 @@ var testNodeAnn = "01012674c2e7ef68c73a086b7de2603f4ef1567358df84bb4edaa06c" +
|
|||||||
"80000000d0000000005cd2a001260706204c"
|
"80000000d0000000005cd2a001260706204c"
|
||||||
|
|
||||||
// TestLightningNodePersistence takes a raw serialized node announcement
|
// TestLightningNodePersistence takes a raw serialized node announcement
|
||||||
// message, converts it to our internal models.LightningNode type, persists it
|
// message, converts it to our internal models.Node type, persists it
|
||||||
// to disk, reads it again and converts it back to a wire message and asserts
|
// to disk, reads it again and converts it back to a wire message and asserts
|
||||||
// that the two messages are equal.
|
// that the two messages are equal.
|
||||||
func TestLightningNodePersistence(t *testing.T) {
|
func TestLightningNodePersistence(t *testing.T) {
|
||||||
@@ -4466,11 +4466,11 @@ func TestLightningNodePersistence(t *testing.T) {
|
|||||||
node := models.NodeFromWireAnnouncement(na)
|
node := models.NodeFromWireAnnouncement(na)
|
||||||
|
|
||||||
// Persist the node to disk.
|
// Persist the node to disk.
|
||||||
err = graph.AddLightningNode(ctx, node)
|
err = graph.AddNode(ctx, node)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Read the node from disk.
|
// Read the node from disk.
|
||||||
diskNode, err := graph.FetchLightningNode(ctx, node.PubKeyBytes)
|
diskNode, err := graph.FetchNode(ctx, node.PubKeyBytes)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Convert it back to a wire message.
|
// Convert it back to a wire message.
|
||||||
|
|||||||
+14
-15
@@ -32,13 +32,13 @@ type NodeTraverser interface {
|
|||||||
type V1Store interface { //nolint:interfacebloat
|
type V1Store interface { //nolint:interfacebloat
|
||||||
NodeTraverser
|
NodeTraverser
|
||||||
|
|
||||||
// AddLightningNode adds a vertex/node to the graph database. If the
|
// AddNode adds a vertex/node to the graph database. If the
|
||||||
// node is not in the database from before, this will add a new,
|
// node is not in the database from before, this will add a new,
|
||||||
// unconnected one to the graph. If it is present from before, this will
|
// unconnected one to the graph. If it is present from before, this will
|
||||||
// update that node's information. Note that this method is expected to
|
// update that node's information. Note that this method is expected to
|
||||||
// only be called to update an already present node from a node
|
// only be called to update an already present node from a node
|
||||||
// announcement, or to insert a node found in a channel update.
|
// announcement, or to insert a node found in a channel update.
|
||||||
AddLightningNode(ctx context.Context, node *models.LightningNode,
|
AddNode(ctx context.Context, node *models.Node,
|
||||||
op ...batch.SchedulerOption) error
|
op ...batch.SchedulerOption) error
|
||||||
|
|
||||||
// AddrsForNode returns all known addresses for the target node public
|
// AddrsForNode returns all known addresses for the target node public
|
||||||
@@ -53,7 +53,7 @@ type V1Store interface { //nolint:interfacebloat
|
|||||||
// the channel and the channel peer's node information.
|
// the channel and the channel peer's node information.
|
||||||
ForEachSourceNodeChannel(ctx context.Context,
|
ForEachSourceNodeChannel(ctx context.Context,
|
||||||
cb func(chanPoint wire.OutPoint, havePolicy bool,
|
cb func(chanPoint wire.OutPoint, havePolicy bool,
|
||||||
otherNode *models.LightningNode) error,
|
otherNode *models.Node) error,
|
||||||
reset func()) error
|
reset func()) error
|
||||||
|
|
||||||
// ForEachNodeChannel iterates through all channels of the given node,
|
// ForEachNodeChannel iterates through all channels of the given node,
|
||||||
@@ -87,7 +87,7 @@ type V1Store interface { //nolint:interfacebloat
|
|||||||
// graph, executing the passed callback with each node encountered. If
|
// graph, executing the passed callback with each node encountered. If
|
||||||
// the callback returns an error, then the transaction is aborted and
|
// the callback returns an error, then the transaction is aborted and
|
||||||
// the iteration stops early.
|
// the iteration stops early.
|
||||||
ForEachNode(ctx context.Context, cb func(*models.LightningNode) error,
|
ForEachNode(ctx context.Context, cb func(*models.Node) error,
|
||||||
reset func()) error
|
reset func()) error
|
||||||
|
|
||||||
// ForEachNodeCacheable iterates through all the stored vertices/nodes
|
// ForEachNodeCacheable iterates through all the stored vertices/nodes
|
||||||
@@ -101,30 +101,29 @@ type V1Store interface { //nolint:interfacebloat
|
|||||||
// node.
|
// node.
|
||||||
LookupAlias(ctx context.Context, pub *btcec.PublicKey) (string, error)
|
LookupAlias(ctx context.Context, pub *btcec.PublicKey) (string, error)
|
||||||
|
|
||||||
// DeleteLightningNode starts a new database transaction to remove a
|
// DeleteNode starts a new database transaction to remove a
|
||||||
// vertex/node from the database according to the node's public key.
|
// vertex/node from the database according to the node's public key.
|
||||||
DeleteLightningNode(ctx context.Context, nodePub route.Vertex) error
|
DeleteNode(ctx context.Context, nodePub route.Vertex) error
|
||||||
|
|
||||||
// NodeUpdatesInHorizon returns all the known lightning node which have
|
// NodeUpdatesInHorizon returns all the known lightning node which have
|
||||||
// an update timestamp within the passed range. This method can be used
|
// an update timestamp within the passed range. This method can be used
|
||||||
// by two nodes to quickly determine if they have the same set of up to
|
// by two nodes to quickly determine if they have the same set of up to
|
||||||
// date node announcements.
|
// date node announcements.
|
||||||
NodeUpdatesInHorizon(startTime,
|
NodeUpdatesInHorizon(startTime,
|
||||||
endTime time.Time) ([]models.LightningNode, error)
|
endTime time.Time) ([]models.Node, error)
|
||||||
|
|
||||||
// FetchLightningNode attempts to look up a target node by its identity
|
// FetchNode attempts to look up a target node by its identity
|
||||||
// public key. If the node isn't found in the database, then
|
// public key. If the node isn't found in the database, then
|
||||||
// ErrGraphNodeNotFound is returned.
|
// ErrGraphNodeNotFound is returned.
|
||||||
FetchLightningNode(ctx context.Context,
|
FetchNode(ctx context.Context, nodePub route.Vertex) (*models.Node,
|
||||||
nodePub route.Vertex) (*models.LightningNode, error)
|
error)
|
||||||
|
|
||||||
// HasLightningNode determines if the graph has a vertex identified by
|
// HasNode determines if the graph has a vertex identified by
|
||||||
// the target node identity public key. If the node exists in the
|
// the target node identity public key. If the node exists in the
|
||||||
// database, a timestamp of when the data for the node was lasted
|
// database, a timestamp of when the data for the node was lasted
|
||||||
// updated is returned along with a true boolean. Otherwise, an empty
|
// updated is returned along with a true boolean. Otherwise, an empty
|
||||||
// time.Time is returned with a false boolean.
|
// time.Time is returned with a false boolean.
|
||||||
HasLightningNode(ctx context.Context, nodePub [33]byte) (time.Time,
|
HasNode(ctx context.Context, nodePub [33]byte) (time.Time, bool, error)
|
||||||
bool, error)
|
|
||||||
|
|
||||||
// IsPublicNode is a helper method that determines whether the node with
|
// IsPublicNode is a helper method that determines whether the node with
|
||||||
// the given public key is seen as a public node in the graph from the
|
// the given public key is seen as a public node in the graph from the
|
||||||
@@ -327,13 +326,13 @@ type V1Store interface { //nolint:interfacebloat
|
|||||||
// treated as the center node within a star-graph. This method may be
|
// treated as the center node within a star-graph. This method may be
|
||||||
// used to kick off a path finding algorithm in order to explore the
|
// used to kick off a path finding algorithm in order to explore the
|
||||||
// reachability of another node based off the source node.
|
// reachability of another node based off the source node.
|
||||||
SourceNode(ctx context.Context) (*models.LightningNode, error)
|
SourceNode(ctx context.Context) (*models.Node, error)
|
||||||
|
|
||||||
// SetSourceNode sets the source node within the graph database. The
|
// SetSourceNode sets the source node within the graph database. The
|
||||||
// source node is to be used as the center of a star-graph within path
|
// source node is to be used as the center of a star-graph within path
|
||||||
// finding algorithms.
|
// finding algorithms.
|
||||||
SetSourceNode(ctx context.Context,
|
SetSourceNode(ctx context.Context,
|
||||||
node *models.LightningNode) error
|
node *models.Node) error
|
||||||
|
|
||||||
// PruneTip returns the block height and hash of the latest block that
|
// PruneTip returns the block height and hash of the latest block that
|
||||||
// has been used to prune channels in the graph. Knowing the "prune tip"
|
// has been used to prune channels in the graph. Knowing the "prune tip"
|
||||||
|
|||||||
+54
-54
@@ -382,7 +382,7 @@ func (c *KVStore) AddrsForNode(ctx context.Context,
|
|||||||
return false, nil, err
|
return false, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
node, err := c.FetchLightningNode(ctx, pubKey)
|
node, err := c.FetchNode(ctx, pubKey)
|
||||||
// We don't consider it an error if the graph is unaware of the node.
|
// We don't consider it an error if the graph is unaware of the node.
|
||||||
switch {
|
switch {
|
||||||
case err != nil && !errors.Is(err, ErrGraphNodeNotFound):
|
case err != nil && !errors.Is(err, ErrGraphNodeNotFound):
|
||||||
@@ -629,7 +629,7 @@ func (c *KVStore) fetchNodeFeatures(tx kvdb.RTx,
|
|||||||
node route.Vertex) (*lnwire.FeatureVector, error) {
|
node route.Vertex) (*lnwire.FeatureVector, error) {
|
||||||
|
|
||||||
// Fallback that uses the database.
|
// Fallback that uses the database.
|
||||||
targetNode, err := c.FetchLightningNodeTx(tx, node)
|
targetNode, err := c.fetchNodeTx(tx, node)
|
||||||
switch {
|
switch {
|
||||||
// If the node exists and has features, return them directly.
|
// If the node exists and has features, return them directly.
|
||||||
case err == nil:
|
case err == nil:
|
||||||
@@ -683,7 +683,7 @@ func (c *KVStore) ForEachNodeCached(ctx context.Context, withAddrs bool,
|
|||||||
// node, and construct a similar callback functiopn signature as the
|
// node, and construct a similar callback functiopn signature as the
|
||||||
// main funcotin expects.
|
// main funcotin expects.
|
||||||
return forEachNode(c.db, func(tx kvdb.RTx,
|
return forEachNode(c.db, func(tx kvdb.RTx,
|
||||||
node *models.LightningNode) error {
|
node *models.Node) error {
|
||||||
|
|
||||||
channels := make(map[uint64]*DirectedChannel)
|
channels := make(map[uint64]*DirectedChannel)
|
||||||
|
|
||||||
@@ -804,10 +804,10 @@ func (c *KVStore) DisabledChannelIDs() ([]uint64, error) {
|
|||||||
//
|
//
|
||||||
// NOTE: this is part of the V1Store interface.
|
// NOTE: this is part of the V1Store interface.
|
||||||
func (c *KVStore) ForEachNode(_ context.Context,
|
func (c *KVStore) ForEachNode(_ context.Context,
|
||||||
cb func(*models.LightningNode) error, reset func()) error {
|
cb func(*models.Node) error, reset func()) error {
|
||||||
|
|
||||||
return forEachNode(c.db, func(tx kvdb.RTx,
|
return forEachNode(c.db, func(tx kvdb.RTx,
|
||||||
node *models.LightningNode) error {
|
node *models.Node) error {
|
||||||
|
|
||||||
return cb(node)
|
return cb(node)
|
||||||
}, reset)
|
}, reset)
|
||||||
@@ -821,7 +821,7 @@ func (c *KVStore) ForEachNode(_ context.Context,
|
|||||||
// TODO(roasbeef): add iterator interface to allow for memory efficient graph
|
// TODO(roasbeef): add iterator interface to allow for memory efficient graph
|
||||||
// traversal when graph gets mega.
|
// traversal when graph gets mega.
|
||||||
func forEachNode(db kvdb.Backend,
|
func forEachNode(db kvdb.Backend,
|
||||||
cb func(kvdb.RTx, *models.LightningNode) error, reset func()) error {
|
cb func(kvdb.RTx, *models.Node) error, reset func()) error {
|
||||||
|
|
||||||
traversal := func(tx kvdb.RTx) error {
|
traversal := func(tx kvdb.RTx) error {
|
||||||
// First grab the nodes bucket which stores the mapping from
|
// First grab the nodes bucket which stores the mapping from
|
||||||
@@ -899,14 +899,14 @@ func (c *KVStore) ForEachNodeCacheable(_ context.Context,
|
|||||||
// as the center node within a star-graph. This method may be used to kick off
|
// as the center node within a star-graph. This method may be used to kick off
|
||||||
// a path finding algorithm in order to explore the reachability of another
|
// a path finding algorithm in order to explore the reachability of another
|
||||||
// node based off the source node.
|
// node based off the source node.
|
||||||
func (c *KVStore) SourceNode(_ context.Context) (*models.LightningNode, error) {
|
func (c *KVStore) SourceNode(_ context.Context) (*models.Node, error) {
|
||||||
return sourceNode(c.db)
|
return sourceNode(c.db)
|
||||||
}
|
}
|
||||||
|
|
||||||
// sourceNode fetches the source node of the graph. The source node is treated
|
// sourceNode fetches the source node of the graph. The source node is treated
|
||||||
// as the center node within a star-graph.
|
// as the center node within a star-graph.
|
||||||
func sourceNode(db kvdb.Backend) (*models.LightningNode, error) {
|
func sourceNode(db kvdb.Backend) (*models.Node, error) {
|
||||||
var source *models.LightningNode
|
var source *models.Node
|
||||||
err := kvdb.View(db, func(tx kvdb.RTx) error {
|
err := kvdb.View(db, func(tx kvdb.RTx) error {
|
||||||
// First grab the nodes bucket which stores the mapping from
|
// First grab the nodes bucket which stores the mapping from
|
||||||
// pubKey to node information.
|
// pubKey to node information.
|
||||||
@@ -936,7 +936,7 @@ func sourceNode(db kvdb.Backend) (*models.LightningNode, error) {
|
|||||||
// node of the graph. The source node is treated as the center node within a
|
// node of the graph. The source node is treated as the center node within a
|
||||||
// star-graph. This method may be used to kick off a path finding algorithm in
|
// star-graph. This method may be used to kick off a path finding algorithm in
|
||||||
// order to explore the reachability of another node based off the source node.
|
// order to explore the reachability of another node based off the source node.
|
||||||
func sourceNodeWithTx(nodes kvdb.RBucket) (*models.LightningNode, error) {
|
func sourceNodeWithTx(nodes kvdb.RBucket) (*models.Node, error) {
|
||||||
selfPub := nodes.Get(sourceKey)
|
selfPub := nodes.Get(sourceKey)
|
||||||
if selfPub == nil {
|
if selfPub == nil {
|
||||||
return nil, ErrSourceNodeNotSet
|
return nil, ErrSourceNodeNotSet
|
||||||
@@ -956,7 +956,7 @@ func sourceNodeWithTx(nodes kvdb.RBucket) (*models.LightningNode, error) {
|
|||||||
// node is to be used as the center of a star-graph within path finding
|
// node is to be used as the center of a star-graph within path finding
|
||||||
// algorithms.
|
// algorithms.
|
||||||
func (c *KVStore) SetSourceNode(_ context.Context,
|
func (c *KVStore) SetSourceNode(_ context.Context,
|
||||||
node *models.LightningNode) error {
|
node *models.Node) error {
|
||||||
|
|
||||||
nodePubBytes := node.PubKeyBytes[:]
|
nodePubBytes := node.PubKeyBytes[:]
|
||||||
|
|
||||||
@@ -980,7 +980,7 @@ func (c *KVStore) SetSourceNode(_ context.Context,
|
|||||||
}, func() {})
|
}, func() {})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddLightningNode adds a vertex/node to the graph database. If the node is not
|
// AddNode adds a vertex/node to the graph database. If the node is not
|
||||||
// in the database from before, this will add a new, unconnected one to the
|
// in the database from before, this will add a new, unconnected one to the
|
||||||
// graph. If it is present from before, this will update that node's
|
// graph. If it is present from before, this will update that node's
|
||||||
// information. Note that this method is expected to only be called to update an
|
// information. Note that this method is expected to only be called to update an
|
||||||
@@ -988,8 +988,8 @@ func (c *KVStore) SetSourceNode(_ context.Context,
|
|||||||
// channel update.
|
// channel update.
|
||||||
//
|
//
|
||||||
// TODO(roasbeef): also need sig of announcement.
|
// TODO(roasbeef): also need sig of announcement.
|
||||||
func (c *KVStore) AddLightningNode(ctx context.Context,
|
func (c *KVStore) AddNode(ctx context.Context,
|
||||||
node *models.LightningNode, opts ...batch.SchedulerOption) error {
|
node *models.Node, opts ...batch.SchedulerOption) error {
|
||||||
|
|
||||||
r := &batch.Request[kvdb.RwTx]{
|
r := &batch.Request[kvdb.RwTx]{
|
||||||
Opts: batch.NewSchedulerOptions(opts...),
|
Opts: batch.NewSchedulerOptions(opts...),
|
||||||
@@ -1001,7 +1001,7 @@ func (c *KVStore) AddLightningNode(ctx context.Context,
|
|||||||
return c.nodeScheduler.Execute(ctx, r)
|
return c.nodeScheduler.Execute(ctx, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
func addLightningNode(tx kvdb.RwTx, node *models.LightningNode) error {
|
func addLightningNode(tx kvdb.RwTx, node *models.Node) error {
|
||||||
nodes, err := tx.CreateTopLevelBucket(nodeBucket)
|
nodes, err := tx.CreateTopLevelBucket(nodeBucket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -1061,9 +1061,9 @@ func (c *KVStore) LookupAlias(_ context.Context,
|
|||||||
return alias, nil
|
return alias, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteLightningNode starts a new database transaction to remove a vertex/node
|
// DeleteNode starts a new database transaction to remove a vertex/node
|
||||||
// from the database according to the node's public key.
|
// from the database according to the node's public key.
|
||||||
func (c *KVStore) DeleteLightningNode(_ context.Context,
|
func (c *KVStore) DeleteNode(_ context.Context,
|
||||||
nodePub route.Vertex) error {
|
nodePub route.Vertex) error {
|
||||||
|
|
||||||
// TODO(roasbeef): ensure dangling edges are removed...
|
// TODO(roasbeef): ensure dangling edges are removed...
|
||||||
@@ -1204,7 +1204,7 @@ func (c *KVStore) addChannelEdge(tx kvdb.RwTx,
|
|||||||
_, node1Err := fetchLightningNode(nodes, edge.NodeKey1Bytes[:])
|
_, node1Err := fetchLightningNode(nodes, edge.NodeKey1Bytes[:])
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(node1Err, ErrGraphNodeNotFound):
|
case errors.Is(node1Err, ErrGraphNodeNotFound):
|
||||||
node1Shell := models.LightningNode{
|
node1Shell := models.Node{
|
||||||
PubKeyBytes: edge.NodeKey1Bytes,
|
PubKeyBytes: edge.NodeKey1Bytes,
|
||||||
HaveNodeAnnouncement: false,
|
HaveNodeAnnouncement: false,
|
||||||
}
|
}
|
||||||
@@ -1220,7 +1220,7 @@ func (c *KVStore) addChannelEdge(tx kvdb.RwTx,
|
|||||||
_, node2Err := fetchLightningNode(nodes, edge.NodeKey2Bytes[:])
|
_, node2Err := fetchLightningNode(nodes, edge.NodeKey2Bytes[:])
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(node2Err, ErrGraphNodeNotFound):
|
case errors.Is(node2Err, ErrGraphNodeNotFound):
|
||||||
node2Shell := models.LightningNode{
|
node2Shell := models.Node{
|
||||||
PubKeyBytes: edge.NodeKey2Bytes,
|
PubKeyBytes: edge.NodeKey2Bytes,
|
||||||
HaveNodeAnnouncement: false,
|
HaveNodeAnnouncement: false,
|
||||||
}
|
}
|
||||||
@@ -2032,11 +2032,11 @@ type ChannelEdge struct {
|
|||||||
|
|
||||||
// Node1 is "node 1" in the channel. This is the node that would have
|
// Node1 is "node 1" in the channel. This is the node that would have
|
||||||
// produced Policy1 if it exists.
|
// produced Policy1 if it exists.
|
||||||
Node1 *models.LightningNode
|
Node1 *models.Node
|
||||||
|
|
||||||
// Node2 is "node 2" in the channel. This is the node that would have
|
// Node2 is "node 2" in the channel. This is the node that would have
|
||||||
// produced Policy2 if it exists.
|
// produced Policy2 if it exists.
|
||||||
Node2 *models.LightningNode
|
Node2 *models.Node
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChanUpdatesInHorizon returns all the known channel edges which have at least
|
// ChanUpdatesInHorizon returns all the known channel edges which have at least
|
||||||
@@ -2199,9 +2199,9 @@ func (c *KVStore) ChanUpdatesInHorizon(startTime,
|
|||||||
// nodes to quickly determine if they have the same set of up to date node
|
// nodes to quickly determine if they have the same set of up to date node
|
||||||
// announcements.
|
// announcements.
|
||||||
func (c *KVStore) NodeUpdatesInHorizon(startTime,
|
func (c *KVStore) NodeUpdatesInHorizon(startTime,
|
||||||
endTime time.Time) ([]models.LightningNode, error) {
|
endTime time.Time) ([]models.Node, error) {
|
||||||
|
|
||||||
var nodesInHorizon []models.LightningNode
|
var nodesInHorizon []models.Node
|
||||||
|
|
||||||
err := kvdb.View(c.db, func(tx kvdb.RTx) error {
|
err := kvdb.View(c.db, func(tx kvdb.RTx) error {
|
||||||
nodes := tx.ReadBucket(nodeBucket)
|
nodes := tx.ReadBucket(nodeBucket)
|
||||||
@@ -3043,21 +3043,21 @@ func (c *KVStore) isPublic(tx kvdb.RTx, nodePub route.Vertex,
|
|||||||
return nodeIsPublic, nil
|
return nodeIsPublic, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// FetchLightningNodeTx attempts to look up a target node by its identity
|
// fetchNodeTx attempts to look up a target node by its identity
|
||||||
// public key. If the node isn't found in the database, then
|
// public key. If the node isn't found in the database, then
|
||||||
// ErrGraphNodeNotFound is returned. An optional transaction may be provided.
|
// ErrGraphNodeNotFound is returned. An optional transaction may be provided.
|
||||||
// If none is provided, then a new one will be created.
|
// If none is provided, then a new one will be created.
|
||||||
func (c *KVStore) FetchLightningNodeTx(tx kvdb.RTx, nodePub route.Vertex) (
|
func (c *KVStore) fetchNodeTx(tx kvdb.RTx, nodePub route.Vertex) (*models.Node,
|
||||||
*models.LightningNode, error) {
|
error) {
|
||||||
|
|
||||||
return c.fetchLightningNode(tx, nodePub)
|
return c.fetchLightningNode(tx, nodePub)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FetchLightningNode attempts to look up a target node by its identity public
|
// FetchNode attempts to look up a target node by its identity public
|
||||||
// key. If the node isn't found in the database, then ErrGraphNodeNotFound is
|
// key. If the node isn't found in the database, then ErrGraphNodeNotFound is
|
||||||
// returned.
|
// returned.
|
||||||
func (c *KVStore) FetchLightningNode(_ context.Context,
|
func (c *KVStore) FetchNode(_ context.Context,
|
||||||
nodePub route.Vertex) (*models.LightningNode, error) {
|
nodePub route.Vertex) (*models.Node, error) {
|
||||||
|
|
||||||
return c.fetchLightningNode(nil, nodePub)
|
return c.fetchLightningNode(nil, nodePub)
|
||||||
}
|
}
|
||||||
@@ -3067,9 +3067,9 @@ func (c *KVStore) FetchLightningNode(_ context.Context,
|
|||||||
// returned. An optional transaction may be provided. If none is provided, then
|
// returned. An optional transaction may be provided. If none is provided, then
|
||||||
// a new one will be created.
|
// a new one will be created.
|
||||||
func (c *KVStore) fetchLightningNode(tx kvdb.RTx,
|
func (c *KVStore) fetchLightningNode(tx kvdb.RTx,
|
||||||
nodePub route.Vertex) (*models.LightningNode, error) {
|
nodePub route.Vertex) (*models.Node, error) {
|
||||||
|
|
||||||
var node *models.LightningNode
|
var node *models.Node
|
||||||
fetch := func(tx kvdb.RTx) error {
|
fetch := func(tx kvdb.RTx) error {
|
||||||
// First grab the nodes bucket which stores the mapping from
|
// First grab the nodes bucket which stores the mapping from
|
||||||
// pubKey to node information.
|
// pubKey to node information.
|
||||||
@@ -3124,7 +3124,7 @@ func (c *KVStore) fetchLightningNode(tx kvdb.RTx,
|
|||||||
// timestamp of when the data for the node was lasted updated is returned along
|
// timestamp of when the data for the node was lasted updated is returned along
|
||||||
// with a true boolean. Otherwise, an empty time.Time is returned with a false
|
// with a true boolean. Otherwise, an empty time.Time is returned with a false
|
||||||
// boolean.
|
// boolean.
|
||||||
func (c *KVStore) HasLightningNode(_ context.Context,
|
func (c *KVStore) HasNode(_ context.Context,
|
||||||
nodePub [33]byte) (time.Time, bool, error) {
|
nodePub [33]byte) (time.Time, bool, error) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -3287,7 +3287,7 @@ func (c *KVStore) ForEachNodeChannel(_ context.Context, nodePub route.Vertex,
|
|||||||
// peer's node information.
|
// peer's node information.
|
||||||
func (c *KVStore) ForEachSourceNodeChannel(_ context.Context,
|
func (c *KVStore) ForEachSourceNodeChannel(_ context.Context,
|
||||||
cb func(chanPoint wire.OutPoint, havePolicy bool,
|
cb func(chanPoint wire.OutPoint, havePolicy bool,
|
||||||
otherNode *models.LightningNode) error, reset func()) error {
|
otherNode *models.Node) error, reset func()) error {
|
||||||
|
|
||||||
return kvdb.View(c.db, func(tx kvdb.RTx) error {
|
return kvdb.View(c.db, func(tx kvdb.RTx) error {
|
||||||
nodes := tx.ReadBucket(nodeBucket)
|
nodes := tx.ReadBucket(nodeBucket)
|
||||||
@@ -3343,13 +3343,13 @@ func (c *KVStore) forEachNodeChannelTx(tx kvdb.RTx,
|
|||||||
return nodeTraversal(tx, nodePub[:], c.db, cb, reset)
|
return nodeTraversal(tx, nodePub[:], c.db, cb, reset)
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetchOtherNode attempts to fetch the full LightningNode that's opposite of
|
// fetchOtherNode attempts to fetch the full Node that's opposite of
|
||||||
// the target node in the channel. This is useful when one knows the pubkey of
|
// the target node in the channel. This is useful when one knows the pubkey of
|
||||||
// one of the nodes, and wishes to obtain the full LightningNode for the other
|
// one of the nodes, and wishes to obtain the full Node for the other
|
||||||
// end of the channel.
|
// end of the channel.
|
||||||
func (c *KVStore) fetchOtherNode(tx kvdb.RTx,
|
func (c *KVStore) fetchOtherNode(tx kvdb.RTx,
|
||||||
channel *models.ChannelEdgeInfo, thisNodeKey []byte) (
|
channel *models.ChannelEdgeInfo, thisNodeKey []byte) (
|
||||||
*models.LightningNode, error) {
|
*models.Node, error) {
|
||||||
|
|
||||||
// Ensure that the node passed in is actually a member of the channel.
|
// Ensure that the node passed in is actually a member of the channel.
|
||||||
var targetNodeBytes [33]byte
|
var targetNodeBytes [33]byte
|
||||||
@@ -3362,7 +3362,7 @@ func (c *KVStore) fetchOtherNode(tx kvdb.RTx,
|
|||||||
return nil, fmt.Errorf("node not participating in this channel")
|
return nil, fmt.Errorf("node not participating in this channel")
|
||||||
}
|
}
|
||||||
|
|
||||||
var targetNode *models.LightningNode
|
var targetNode *models.Node
|
||||||
fetchNodeFunc := func(tx kvdb.RTx) error {
|
fetchNodeFunc := func(tx kvdb.RTx) error {
|
||||||
// First grab the nodes bucket which stores the mapping from
|
// First grab the nodes bucket which stores the mapping from
|
||||||
// pubKey to node information.
|
// pubKey to node information.
|
||||||
@@ -4019,7 +4019,7 @@ func (c *nodeTraverserSession) FetchNodeFeatures(nodePub route.Vertex) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
func putLightningNode(nodeBucket, aliasBucket, updateIndex kvdb.RwBucket,
|
func putLightningNode(nodeBucket, aliasBucket, updateIndex kvdb.RwBucket,
|
||||||
node *models.LightningNode) error {
|
node *models.Node) error {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
scratch [16]byte
|
scratch [16]byte
|
||||||
@@ -4148,11 +4148,11 @@ func putLightningNode(nodeBucket, aliasBucket, updateIndex kvdb.RwBucket,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func fetchLightningNode(nodeBucket kvdb.RBucket,
|
func fetchLightningNode(nodeBucket kvdb.RBucket,
|
||||||
nodePub []byte) (models.LightningNode, error) {
|
nodePub []byte) (models.Node, error) {
|
||||||
|
|
||||||
nodeBytes := nodeBucket.Get(nodePub)
|
nodeBytes := nodeBucket.Get(nodePub)
|
||||||
if nodeBytes == nil {
|
if nodeBytes == nil {
|
||||||
return models.LightningNode{}, ErrGraphNodeNotFound
|
return models.Node{}, ErrGraphNodeNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
nodeReader := bytes.NewReader(nodeBytes)
|
nodeReader := bytes.NewReader(nodeBytes)
|
||||||
@@ -4215,9 +4215,9 @@ func deserializeLightningNodeCacheable(r io.Reader) (route.Vertex,
|
|||||||
return pubKey, features, nil
|
return pubKey, features, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func deserializeLightningNode(r io.Reader) (models.LightningNode, error) {
|
func deserializeLightningNode(r io.Reader) (models.Node, error) {
|
||||||
var (
|
var (
|
||||||
node models.LightningNode
|
node models.Node
|
||||||
scratch [8]byte
|
scratch [8]byte
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
@@ -4227,18 +4227,18 @@ func deserializeLightningNode(r io.Reader) (models.LightningNode, error) {
|
|||||||
node.Features = lnwire.EmptyFeatureVector()
|
node.Features = lnwire.EmptyFeatureVector()
|
||||||
|
|
||||||
if _, err := r.Read(scratch[:]); err != nil {
|
if _, err := r.Read(scratch[:]); err != nil {
|
||||||
return models.LightningNode{}, err
|
return models.Node{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
unix := int64(byteOrder.Uint64(scratch[:]))
|
unix := int64(byteOrder.Uint64(scratch[:]))
|
||||||
node.LastUpdate = time.Unix(unix, 0)
|
node.LastUpdate = time.Unix(unix, 0)
|
||||||
|
|
||||||
if _, err := io.ReadFull(r, node.PubKeyBytes[:]); err != nil {
|
if _, err := io.ReadFull(r, node.PubKeyBytes[:]); err != nil {
|
||||||
return models.LightningNode{}, err
|
return models.Node{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := r.Read(scratch[:2]); err != nil {
|
if _, err := r.Read(scratch[:2]); err != nil {
|
||||||
return models.LightningNode{}, err
|
return models.Node{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
hasNodeAnn := byteOrder.Uint16(scratch[:2])
|
hasNodeAnn := byteOrder.Uint16(scratch[:2])
|
||||||
@@ -4257,27 +4257,27 @@ func deserializeLightningNode(r io.Reader) (models.LightningNode, error) {
|
|||||||
// We did get a node announcement for this node, so we'll have the rest
|
// We did get a node announcement for this node, so we'll have the rest
|
||||||
// of the data available.
|
// of the data available.
|
||||||
if err := binary.Read(r, byteOrder, &node.Color.R); err != nil {
|
if err := binary.Read(r, byteOrder, &node.Color.R); err != nil {
|
||||||
return models.LightningNode{}, err
|
return models.Node{}, err
|
||||||
}
|
}
|
||||||
if err := binary.Read(r, byteOrder, &node.Color.G); err != nil {
|
if err := binary.Read(r, byteOrder, &node.Color.G); err != nil {
|
||||||
return models.LightningNode{}, err
|
return models.Node{}, err
|
||||||
}
|
}
|
||||||
if err := binary.Read(r, byteOrder, &node.Color.B); err != nil {
|
if err := binary.Read(r, byteOrder, &node.Color.B); err != nil {
|
||||||
return models.LightningNode{}, err
|
return models.Node{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
node.Alias, err = wire.ReadVarString(r, 0)
|
node.Alias, err = wire.ReadVarString(r, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return models.LightningNode{}, err
|
return models.Node{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = node.Features.Decode(r)
|
err = node.Features.Decode(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return models.LightningNode{}, err
|
return models.Node{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := r.Read(scratch[:2]); err != nil {
|
if _, err := r.Read(scratch[:2]); err != nil {
|
||||||
return models.LightningNode{}, err
|
return models.Node{}, err
|
||||||
}
|
}
|
||||||
numAddresses := int(byteOrder.Uint16(scratch[:2]))
|
numAddresses := int(byteOrder.Uint16(scratch[:2]))
|
||||||
|
|
||||||
@@ -4285,7 +4285,7 @@ func deserializeLightningNode(r io.Reader) (models.LightningNode, error) {
|
|||||||
for i := 0; i < numAddresses; i++ {
|
for i := 0; i < numAddresses; i++ {
|
||||||
address, err := DeserializeAddr(r)
|
address, err := DeserializeAddr(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return models.LightningNode{}, err
|
return models.Node{}, err
|
||||||
}
|
}
|
||||||
addresses = append(addresses, address)
|
addresses = append(addresses, address)
|
||||||
}
|
}
|
||||||
@@ -4293,7 +4293,7 @@ func deserializeLightningNode(r io.Reader) (models.LightningNode, error) {
|
|||||||
|
|
||||||
node.AuthSigBytes, err = wire.ReadVarBytes(r, 0, 80, "sig")
|
node.AuthSigBytes, err = wire.ReadVarBytes(r, 0, 80, "sig")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return models.LightningNode{}, err
|
return models.Node{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// We'll try and see if there are any opaque bytes left, if not, then
|
// We'll try and see if there are any opaque bytes left, if not, then
|
||||||
@@ -4305,7 +4305,7 @@ func deserializeLightningNode(r io.Reader) (models.LightningNode, error) {
|
|||||||
case errors.Is(err, io.ErrUnexpectedEOF):
|
case errors.Is(err, io.ErrUnexpectedEOF):
|
||||||
case errors.Is(err, io.EOF):
|
case errors.Is(err, io.EOF):
|
||||||
case err != nil:
|
case err != nil:
|
||||||
return models.LightningNode{}, err
|
return models.Node{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(extraBytes) > 0 {
|
if len(extraBytes) > 0 {
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LightningNode represents an individual vertex/node within the channel graph.
|
// Node represents an individual vertex/node within the channel graph.
|
||||||
// A node is connected to other nodes by one or more channel edges emanating
|
// A node is connected to other nodes by one or more channel edges emanating
|
||||||
// from it. As the graph is directed, a node will also have an incoming edge
|
// from it. As the graph is directed, a node will also have an incoming edge
|
||||||
// attached to it for each outgoing edge.
|
// attached to it for each outgoing edge.
|
||||||
type LightningNode struct {
|
type Node struct {
|
||||||
// PubKeyBytes is the raw bytes of the public key of the target node.
|
// PubKeyBytes is the raw bytes of the public key of the target node.
|
||||||
PubKeyBytes [33]byte
|
PubKeyBytes [33]byte
|
||||||
pubKey *btcec.PublicKey
|
pubKey *btcec.PublicKey
|
||||||
@@ -65,7 +65,7 @@ type LightningNode struct {
|
|||||||
//
|
//
|
||||||
// NOTE: By having this method to access an attribute, we ensure we only need
|
// NOTE: By having this method to access an attribute, we ensure we only need
|
||||||
// to fully deserialize the pubkey if absolutely necessary.
|
// to fully deserialize the pubkey if absolutely necessary.
|
||||||
func (l *LightningNode) PubKey() (*btcec.PublicKey, error) {
|
func (l *Node) PubKey() (*btcec.PublicKey, error) {
|
||||||
if l.pubKey != nil {
|
if l.pubKey != nil {
|
||||||
return l.pubKey, nil
|
return l.pubKey, nil
|
||||||
}
|
}
|
||||||
@@ -84,19 +84,19 @@ func (l *LightningNode) PubKey() (*btcec.PublicKey, error) {
|
|||||||
//
|
//
|
||||||
// NOTE: By having this method to access an attribute, we ensure we only need
|
// NOTE: By having this method to access an attribute, we ensure we only need
|
||||||
// to fully deserialize the signature if absolutely necessary.
|
// to fully deserialize the signature if absolutely necessary.
|
||||||
func (l *LightningNode) AuthSig() (*ecdsa.Signature, error) {
|
func (l *Node) AuthSig() (*ecdsa.Signature, error) {
|
||||||
return ecdsa.ParseSignature(l.AuthSigBytes)
|
return ecdsa.ParseSignature(l.AuthSigBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddPubKey is a setter-link method that can be used to swap out the public
|
// AddPubKey is a setter-link method that can be used to swap out the public
|
||||||
// key for a node.
|
// key for a node.
|
||||||
func (l *LightningNode) AddPubKey(key *btcec.PublicKey) {
|
func (l *Node) AddPubKey(key *btcec.PublicKey) {
|
||||||
l.pubKey = key
|
l.pubKey = key
|
||||||
copy(l.PubKeyBytes[:], key.SerializeCompressed())
|
copy(l.PubKeyBytes[:], key.SerializeCompressed())
|
||||||
}
|
}
|
||||||
|
|
||||||
// NodeAnnouncement retrieves the latest node announcement of the node.
|
// NodeAnnouncement retrieves the latest node announcement of the node.
|
||||||
func (l *LightningNode) NodeAnnouncement(signed bool) (*lnwire.NodeAnnouncement,
|
func (l *Node) NodeAnnouncement(signed bool) (*lnwire.NodeAnnouncement,
|
||||||
error) {
|
error) {
|
||||||
|
|
||||||
if !l.HaveNodeAnnouncement {
|
if !l.HaveNodeAnnouncement {
|
||||||
@@ -132,13 +132,13 @@ func (l *LightningNode) NodeAnnouncement(signed bool) (*lnwire.NodeAnnouncement,
|
|||||||
return nodeAnn, nil
|
return nodeAnn, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NodeFromWireAnnouncement creates a LightningNode instance from an
|
// NodeFromWireAnnouncement creates a Node instance from an
|
||||||
// lnwire.NodeAnnouncement message.
|
// lnwire.NodeAnnouncement message.
|
||||||
func NodeFromWireAnnouncement(msg *lnwire.NodeAnnouncement) *LightningNode {
|
func NodeFromWireAnnouncement(msg *lnwire.NodeAnnouncement) *Node {
|
||||||
timestamp := time.Unix(int64(msg.Timestamp), 0)
|
timestamp := time.Unix(int64(msg.Timestamp), 0)
|
||||||
features := lnwire.NewFeatureVector(msg.Features, lnwire.Features)
|
features := lnwire.NewFeatureVector(msg.Features, lnwire.Features)
|
||||||
|
|
||||||
return &LightningNode{
|
return &Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
LastUpdate: timestamp,
|
LastUpdate: timestamp,
|
||||||
Addresses: msg.Addresses,
|
Addresses: msg.Addresses,
|
||||||
|
|||||||
@@ -382,7 +382,7 @@ func (c *ChannelGraph) addToTopologyChange(update *TopologyChange,
|
|||||||
|
|
||||||
// Any node announcement maps directly to a NetworkNodeUpdate struct.
|
// Any node announcement maps directly to a NetworkNodeUpdate struct.
|
||||||
// No further data munging or db queries are required.
|
// No further data munging or db queries are required.
|
||||||
case *models.LightningNode:
|
case *models.Node:
|
||||||
pubKey, err := m.PubKey()
|
pubKey, err := m.PubKey()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ func migrateNodes(ctx context.Context, cfg *sqldb.QueryConfig,
|
|||||||
// fetch the corresponding node object in the SQL store, and it will
|
// fetch the corresponding node object in the SQL store, and it will
|
||||||
// then be compared against the original KVDB node object.
|
// then be compared against the original KVDB node object.
|
||||||
batch := make(
|
batch := make(
|
||||||
map[int64]*models.LightningNode, cfg.MaxBatchSize,
|
map[int64]*models.Node, cfg.MaxBatchSize,
|
||||||
)
|
)
|
||||||
|
|
||||||
// validateBatch validates that the batch of nodes in the 'batch' map
|
// validateBatch validates that the batch of nodes in the 'batch' map
|
||||||
@@ -226,7 +226,7 @@ func migrateNodes(ctx context.Context, cfg *sqldb.QueryConfig,
|
|||||||
|
|
||||||
// Clear the batch map for the next iteration.
|
// Clear the batch map for the next iteration.
|
||||||
batch = make(
|
batch = make(
|
||||||
map[int64]*models.LightningNode, cfg.MaxBatchSize,
|
map[int64]*models.Node, cfg.MaxBatchSize,
|
||||||
)
|
)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -235,7 +235,7 @@ func migrateNodes(ctx context.Context, cfg *sqldb.QueryConfig,
|
|||||||
// Loop through each node in the KV store and insert it into the SQL
|
// Loop through each node in the KV store and insert it into the SQL
|
||||||
// database.
|
// database.
|
||||||
err := forEachNode(kvBackend, func(_ kvdb.RTx,
|
err := forEachNode(kvBackend, func(_ kvdb.RTx,
|
||||||
node *models.LightningNode) error {
|
node *models.Node) error {
|
||||||
|
|
||||||
pub := node.PubKeyBytes
|
pub := node.PubKeyBytes
|
||||||
|
|
||||||
@@ -307,7 +307,7 @@ func migrateNodes(ctx context.Context, cfg *sqldb.QueryConfig,
|
|||||||
chunk = 0
|
chunk = 0
|
||||||
skipped = 0
|
skipped = 0
|
||||||
t0 = time.Now()
|
t0 = time.Now()
|
||||||
batch = make(map[int64]*models.LightningNode, cfg.MaxBatchSize)
|
batch = make(map[int64]*models.Node, cfg.MaxBatchSize)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("could not migrate nodes: %w", err)
|
return fmt.Errorf("could not migrate nodes: %w", err)
|
||||||
@@ -1371,7 +1371,7 @@ func forEachClosedSCID(db kvdb.Backend,
|
|||||||
// the migration to be idempotent and dont want to error out if we re-insert the
|
// the migration to be idempotent and dont want to error out if we re-insert the
|
||||||
// exact same node.
|
// exact same node.
|
||||||
func insertNodeSQLMig(ctx context.Context, db SQLQueries,
|
func insertNodeSQLMig(ctx context.Context, db SQLQueries,
|
||||||
node *models.LightningNode) (int64, error) {
|
node *models.Node) (int64, error) {
|
||||||
|
|
||||||
params := sqlc.InsertNodeMigParams{
|
params := sqlc.InsertNodeMigParams{
|
||||||
Version: int16(ProtocolV1),
|
Version: int16(ProtocolV1),
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ func TestMigrateGraphToSQL(t *testing.T) {
|
|||||||
|
|
||||||
var err error
|
var err error
|
||||||
switch obj := object.(type) {
|
switch obj := object.(type) {
|
||||||
case *models.LightningNode:
|
case *models.Node:
|
||||||
err = db.AddLightningNode(ctx, obj)
|
err = db.AddNode(ctx, obj)
|
||||||
case *models.ChannelEdgeInfo:
|
case *models.ChannelEdgeInfo:
|
||||||
err = db.AddChannelEdge(ctx, obj)
|
err = db.AddChannelEdge(ctx, obj)
|
||||||
case *models.ChannelEdgePolicy:
|
case *models.ChannelEdgePolicy:
|
||||||
@@ -118,11 +118,11 @@ func TestMigrateGraphToSQL(t *testing.T) {
|
|||||||
// A node with no node announcement.
|
// A node with no node announcement.
|
||||||
makeTestShellNode(t),
|
makeTestShellNode(t),
|
||||||
// A node with an announcement but no addresses.
|
// A node with an announcement but no addresses.
|
||||||
makeTestNode(t, func(n *models.LightningNode) {
|
makeTestNode(t, func(n *models.Node) {
|
||||||
n.Addresses = nil
|
n.Addresses = nil
|
||||||
}),
|
}),
|
||||||
// A node with all types of addresses.
|
// A node with all types of addresses.
|
||||||
makeTestNode(t, func(n *models.LightningNode) {
|
makeTestNode(t, func(n *models.Node) {
|
||||||
n.Addresses = []net.Addr{
|
n.Addresses = []net.Addr{
|
||||||
testAddr,
|
testAddr,
|
||||||
testIPV4Addr,
|
testIPV4Addr,
|
||||||
@@ -134,11 +134,11 @@ func TestMigrateGraphToSQL(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
// No extra opaque data.
|
// No extra opaque data.
|
||||||
makeTestNode(t, func(n *models.LightningNode) {
|
makeTestNode(t, func(n *models.Node) {
|
||||||
n.ExtraOpaqueData = nil
|
n.ExtraOpaqueData = nil
|
||||||
}),
|
}),
|
||||||
// A node with no features.
|
// A node with no features.
|
||||||
makeTestNode(t, func(n *models.LightningNode) {
|
makeTestNode(t, func(n *models.Node) {
|
||||||
n.Features = lnwire.EmptyFeatureVector()
|
n.Features = lnwire.EmptyFeatureVector()
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
@@ -149,7 +149,7 @@ func TestMigrateGraphToSQL(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "source node",
|
name: "source node",
|
||||||
write: func(t *testing.T, db *KVStore, object any) {
|
write: func(t *testing.T, db *KVStore, object any) {
|
||||||
node, ok := object.(*models.LightningNode)
|
node, ok := object.(*models.Node)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
|
|
||||||
err := db.SetSourceNode(ctx, node)
|
err := db.SetSourceNode(ctx, node)
|
||||||
@@ -175,11 +175,11 @@ func TestMigrateGraphToSQL(t *testing.T) {
|
|||||||
|
|
||||||
// Insert some nodes.
|
// Insert some nodes.
|
||||||
// - node count += 1
|
// - node count += 1
|
||||||
makeTestNode(t, func(n *models.LightningNode) {
|
makeTestNode(t, func(n *models.Node) {
|
||||||
n.PubKeyBytes = node1
|
n.PubKeyBytes = node1
|
||||||
}),
|
}),
|
||||||
// - node count += 1
|
// - node count += 1
|
||||||
makeTestNode(t, func(n *models.LightningNode) {
|
makeTestNode(t, func(n *models.Node) {
|
||||||
n.PubKeyBytes = node2
|
n.PubKeyBytes = node2
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -228,11 +228,11 @@ func TestMigrateGraphToSQL(t *testing.T) {
|
|||||||
|
|
||||||
// Insert some nodes.
|
// Insert some nodes.
|
||||||
// - node count += 1
|
// - node count += 1
|
||||||
makeTestNode(t, func(n *models.LightningNode) {
|
makeTestNode(t, func(n *models.Node) {
|
||||||
n.PubKeyBytes = node1
|
n.PubKeyBytes = node1
|
||||||
}),
|
}),
|
||||||
// - node count += 1
|
// - node count += 1
|
||||||
makeTestNode(t, func(n *models.LightningNode) {
|
makeTestNode(t, func(n *models.Node) {
|
||||||
n.PubKeyBytes = node2
|
n.PubKeyBytes = node2
|
||||||
}),
|
}),
|
||||||
|
|
||||||
@@ -296,7 +296,7 @@ func TestMigrateGraphToSQL(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
switch obj := object.(type) {
|
switch obj := object.(type) {
|
||||||
case *models.LightningNode:
|
case *models.Node:
|
||||||
err = db.SetSourceNode(ctx, obj)
|
err = db.SetSourceNode(ctx, obj)
|
||||||
default:
|
default:
|
||||||
height, ok := obj.(uint32)
|
height, ok := obj.(uint32)
|
||||||
@@ -312,7 +312,7 @@ func TestMigrateGraphToSQL(t *testing.T) {
|
|||||||
// The PruneGraph call requires that the source
|
// The PruneGraph call requires that the source
|
||||||
// node be set. So that is the first object
|
// node be set. So that is the first object
|
||||||
// we will write.
|
// we will write.
|
||||||
&models.LightningNode{
|
&models.Node{
|
||||||
HaveNodeAnnouncement: false,
|
HaveNodeAnnouncement: false,
|
||||||
PubKeyBytes: testPub,
|
PubKeyBytes: testPub,
|
||||||
},
|
},
|
||||||
@@ -455,14 +455,13 @@ func assertInSync(t *testing.T, kvDB *KVStore, sqlDB *SQLStore,
|
|||||||
|
|
||||||
// fetchAllNodes retrieves all nodes from the given store and returns them
|
// fetchAllNodes retrieves all nodes from the given store and returns them
|
||||||
// sorted by their public key.
|
// sorted by their public key.
|
||||||
func fetchAllNodes(t *testing.T, store V1Store) []*models.LightningNode {
|
func fetchAllNodes(t *testing.T, store V1Store) []*models.Node {
|
||||||
nodes := make([]*models.LightningNode, 0)
|
nodes := make([]*models.Node, 0)
|
||||||
|
|
||||||
err := store.ForEachNode(t.Context(),
|
err := store.ForEachNode(t.Context(),
|
||||||
func(node *models.LightningNode) error {
|
func(node *models.Node) error {
|
||||||
|
// Call PubKey to ensure the objects cached pubkey is
|
||||||
// Call PubKey to ensure the objects cached pubkey is set so that
|
// set so that the objects can be compared as a whole.
|
||||||
// the objects can be compared as a whole.
|
|
||||||
_, err := node.PubKey()
|
_, err := node.PubKey()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@@ -479,7 +478,7 @@ func fetchAllNodes(t *testing.T, store V1Store) []*models.LightningNode {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Sort the nodes by their public key to ensure a consistent order.
|
// Sort the nodes by their public key to ensure a consistent order.
|
||||||
slices.SortFunc(nodes, func(i, j *models.LightningNode) int {
|
slices.SortFunc(nodes, func(i, j *models.Node) int {
|
||||||
return bytes.Compare(i.PubKeyBytes[:], j.PubKeyBytes[:])
|
return bytes.Compare(i.PubKeyBytes[:], j.PubKeyBytes[:])
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -487,7 +486,7 @@ func fetchAllNodes(t *testing.T, store V1Store) []*models.LightningNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// fetchSourceNode retrieves the source node from the given store.
|
// fetchSourceNode retrieves the source node from the given store.
|
||||||
func fetchSourceNode(t *testing.T, store V1Store) *models.LightningNode {
|
func fetchSourceNode(t *testing.T, store V1Store) *models.Node {
|
||||||
node, err := store.SourceNode(t.Context())
|
node, err := store.SourceNode(t.Context())
|
||||||
if errors.Is(err, ErrSourceNodeNotSet) {
|
if errors.Is(err, ErrSourceNodeNotSet) {
|
||||||
return nil
|
return nil
|
||||||
@@ -670,13 +669,13 @@ func genPubKey(t require.TestingT) route.Vertex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// testNodeOpt defines a functional option type that can be used to
|
// testNodeOpt defines a functional option type that can be used to
|
||||||
// modify the attributes of a models.LightningNode crated by makeTestNode.
|
// modify the attributes of a models.Node crated by makeTestNode.
|
||||||
type testNodeOpt func(*models.LightningNode)
|
type testNodeOpt func(*models.Node)
|
||||||
|
|
||||||
// makeTestNode can be used to create a test models.LightningNode. The
|
// makeTestNode can be used to create a test models.Node. The
|
||||||
// functional options can be used to modify the node's attributes.
|
// functional options can be used to modify the node's attributes.
|
||||||
func makeTestNode(t *testing.T, opts ...testNodeOpt) *models.LightningNode {
|
func makeTestNode(t *testing.T, opts ...testNodeOpt) *models.Node {
|
||||||
n := &models.LightningNode{
|
n := &models.Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
AuthSigBytes: testSigBytes,
|
AuthSigBytes: testSigBytes,
|
||||||
LastUpdate: testTime,
|
LastUpdate: testTime,
|
||||||
@@ -700,12 +699,12 @@ func makeTestNode(t *testing.T, opts ...testNodeOpt) *models.LightningNode {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeTestShellNode creates a minimal models.LightningNode
|
// makeTestShellNode creates a minimal models.Node
|
||||||
// that only contains the public key and no other attributes.
|
// that only contains the public key and no other attributes.
|
||||||
func makeTestShellNode(t *testing.T,
|
func makeTestShellNode(t *testing.T,
|
||||||
opts ...testNodeOpt) *models.LightningNode {
|
opts ...testNodeOpt) *models.Node {
|
||||||
|
|
||||||
n := &models.LightningNode{
|
n := &models.Node{
|
||||||
HaveNodeAnnouncement: false,
|
HaveNodeAnnouncement: false,
|
||||||
PubKeyBytes: genPubKey(t),
|
PubKeyBytes: genPubKey(t),
|
||||||
Features: testEmptyFeatures,
|
Features: testEmptyFeatures,
|
||||||
@@ -934,20 +933,20 @@ func TestSQLMigrationEdgeCases(t *testing.T) {
|
|||||||
|
|
||||||
// Make one valid node and one node with invalid TLV data.
|
// Make one valid node and one node with invalid TLV data.
|
||||||
n1 := makeTestNode(t)
|
n1 := makeTestNode(t)
|
||||||
n2 := makeTestNode(t, func(n *models.LightningNode) {
|
n2 := makeTestNode(t, func(n *models.Node) {
|
||||||
n.ExtraOpaqueData = invalidTLVData
|
n.ExtraOpaqueData = invalidTLVData
|
||||||
})
|
})
|
||||||
|
|
||||||
populateKV := func(t *testing.T, db *KVStore) {
|
populateKV := func(t *testing.T, db *KVStore) {
|
||||||
// Insert both nodes into the KV store.
|
// Insert both nodes into the KV store.
|
||||||
require.NoError(t, db.AddLightningNode(ctx, n1))
|
require.NoError(t, db.AddNode(ctx, n1))
|
||||||
require.NoError(t, db.AddLightningNode(ctx, n2))
|
require.NoError(t, db.AddNode(ctx, n2))
|
||||||
}
|
}
|
||||||
|
|
||||||
runTestMigration(t, populateKV, dbState{
|
runTestMigration(t, populateKV, dbState{
|
||||||
// We expect only the valid node to be present in the
|
// We expect only the valid node to be present in the
|
||||||
// SQL db.
|
// SQL db.
|
||||||
nodes: []*models.LightningNode{n1},
|
nodes: []*models.Node{n1},
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -979,8 +978,8 @@ func TestSQLMigrationEdgeCases(t *testing.T) {
|
|||||||
|
|
||||||
populateKV := func(t *testing.T, db *KVStore) {
|
populateKV := func(t *testing.T, db *KVStore) {
|
||||||
// Insert both nodes into the KV store.
|
// Insert both nodes into the KV store.
|
||||||
require.NoError(t, db.AddLightningNode(ctx, n1))
|
require.NoError(t, db.AddNode(ctx, n1))
|
||||||
require.NoError(t, db.AddLightningNode(ctx, n2))
|
require.NoError(t, db.AddNode(ctx, n2))
|
||||||
|
|
||||||
// Insert both channels into the KV store.
|
// Insert both channels into the KV store.
|
||||||
require.NoError(t, db.AddChannelEdge(ctx, c1))
|
require.NoError(t, db.AddChannelEdge(ctx, c1))
|
||||||
@@ -995,7 +994,7 @@ func TestSQLMigrationEdgeCases(t *testing.T) {
|
|||||||
|
|
||||||
runTestMigration(t, populateKV, dbState{
|
runTestMigration(t, populateKV, dbState{
|
||||||
// Both nodes will be present.
|
// Both nodes will be present.
|
||||||
nodes: []*models.LightningNode{n1, n2},
|
nodes: []*models.Node{n1, n2},
|
||||||
// We only expect the first channel and its policy to
|
// We only expect the first channel and its policy to
|
||||||
// be present in the SQL db.
|
// be present in the SQL db.
|
||||||
chans: chanSet{{
|
chans: chanSet{{
|
||||||
@@ -1033,8 +1032,8 @@ func TestSQLMigrationEdgeCases(t *testing.T) {
|
|||||||
|
|
||||||
populateKV := func(t *testing.T, db *KVStore) {
|
populateKV := func(t *testing.T, db *KVStore) {
|
||||||
// Insert both nodes into the KV store.
|
// Insert both nodes into the KV store.
|
||||||
require.NoError(t, db.AddLightningNode(ctx, n1))
|
require.NoError(t, db.AddNode(ctx, n1))
|
||||||
require.NoError(t, db.AddLightningNode(ctx, n2))
|
require.NoError(t, db.AddNode(ctx, n2))
|
||||||
|
|
||||||
// Insert the channel into the KV store.
|
// Insert the channel into the KV store.
|
||||||
require.NoError(t, db.AddChannelEdge(ctx, c))
|
require.NoError(t, db.AddChannelEdge(ctx, c))
|
||||||
@@ -1056,7 +1055,7 @@ func TestSQLMigrationEdgeCases(t *testing.T) {
|
|||||||
|
|
||||||
runTestMigration(t, populateKV, dbState{
|
runTestMigration(t, populateKV, dbState{
|
||||||
// Both nodes will be present.
|
// Both nodes will be present.
|
||||||
nodes: []*models.LightningNode{n1, n2},
|
nodes: []*models.Node{n1, n2},
|
||||||
// The channel will be present, but only the
|
// The channel will be present, but only the
|
||||||
// valid policy will be included in the SQL db.
|
// valid policy will be included in the SQL db.
|
||||||
chans: chanSet{{
|
chans: chanSet{{
|
||||||
@@ -1114,8 +1113,8 @@ func TestSQLMigrationEdgeCases(t *testing.T) {
|
|||||||
|
|
||||||
populateKV := func(t *testing.T, db *KVStore) {
|
populateKV := func(t *testing.T, db *KVStore) {
|
||||||
// Insert both nodes into the KV store.
|
// Insert both nodes into the KV store.
|
||||||
require.NoError(t, db.AddLightningNode(ctx, n1))
|
require.NoError(t, db.AddNode(ctx, n1))
|
||||||
require.NoError(t, db.AddLightningNode(ctx, n2))
|
require.NoError(t, db.AddNode(ctx, n2))
|
||||||
|
|
||||||
// Insert the channel into the KV store.
|
// Insert the channel into the KV store.
|
||||||
require.NoError(t, db.AddChannelEdge(ctx, c))
|
require.NoError(t, db.AddChannelEdge(ctx, c))
|
||||||
@@ -1132,7 +1131,7 @@ func TestSQLMigrationEdgeCases(t *testing.T) {
|
|||||||
|
|
||||||
runTestMigration(t, populateKV, dbState{
|
runTestMigration(t, populateKV, dbState{
|
||||||
// Both nodes will be present.
|
// Both nodes will be present.
|
||||||
nodes: []*models.LightningNode{n1, n2},
|
nodes: []*models.Node{n1, n2},
|
||||||
// The channel will be present, but only the
|
// The channel will be present, but only the
|
||||||
// valid policy will be included in the SQL db.
|
// valid policy will be included in the SQL db.
|
||||||
chans: chanSet{{
|
chans: chanSet{{
|
||||||
@@ -1205,7 +1204,7 @@ func runTestMigration(t *testing.T, populateKV func(t *testing.T, db *KVStore),
|
|||||||
|
|
||||||
// dbState describes the expected state of the SQLStore after a migration.
|
// dbState describes the expected state of the SQLStore after a migration.
|
||||||
type dbState struct {
|
type dbState struct {
|
||||||
nodes []*models.LightningNode
|
nodes []*models.Node
|
||||||
chans chanSet
|
chans chanSet
|
||||||
closed []uint64
|
closed []uint64
|
||||||
zombies []uint64
|
zombies []uint64
|
||||||
@@ -1294,7 +1293,7 @@ func testMigrateGraphToSQLRapidOnce(t *testing.T, rt *rapid.T,
|
|||||||
// Keep track of all nodes that should be in the database. We may expect
|
// Keep track of all nodes that should be in the database. We may expect
|
||||||
// more than just the ones we generated above if we have channels that
|
// more than just the ones we generated above if we have channels that
|
||||||
// point to shell nodes.
|
// point to shell nodes.
|
||||||
allNodes := make(map[route.Vertex]*models.LightningNode)
|
allNodes := make(map[route.Vertex]*models.Node)
|
||||||
var nodePubs []route.Vertex
|
var nodePubs []route.Vertex
|
||||||
for _, node := range nodes {
|
for _, node := range nodes {
|
||||||
allNodes[node.PubKeyBytes] = node
|
allNodes[node.PubKeyBytes] = node
|
||||||
@@ -1333,7 +1332,7 @@ func testMigrateGraphToSQLRapidOnce(t *testing.T, rt *rapid.T,
|
|||||||
}
|
}
|
||||||
|
|
||||||
shellNode := makeTestShellNode(
|
shellNode := makeTestShellNode(
|
||||||
t, func(node *models.LightningNode) {
|
t, func(node *models.Node) {
|
||||||
node.PubKeyBytes = n
|
node.PubKeyBytes = n
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -1372,7 +1371,7 @@ func testMigrateGraphToSQLRapidOnce(t *testing.T, rt *rapid.T,
|
|||||||
|
|
||||||
// Write the test objects to the kvdb store.
|
// Write the test objects to the kvdb store.
|
||||||
for _, node := range allNodes {
|
for _, node := range allNodes {
|
||||||
err := kvDB.AddLightningNode(ctx, node)
|
err := kvDB.AddNode(ctx, node)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
for _, channel := range channels {
|
for _, channel := range channels {
|
||||||
@@ -1389,7 +1388,7 @@ func testMigrateGraphToSQLRapidOnce(t *testing.T, rt *rapid.T,
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// Create a slice of all nodes.
|
// Create a slice of all nodes.
|
||||||
var nodesSlice []*models.LightningNode
|
var nodesSlice []*models.Node
|
||||||
for _, node := range allNodes {
|
for _, node := range allNodes {
|
||||||
nodesSlice = append(nodesSlice, node)
|
nodesSlice = append(nodesSlice, node)
|
||||||
}
|
}
|
||||||
@@ -1603,7 +1602,7 @@ func sortAddrs(addrs []net.Addr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// genRandomNode is a rapid generator for creating random lightning nodes.
|
// genRandomNode is a rapid generator for creating random lightning nodes.
|
||||||
func genRandomNode(t *rapid.T) *models.LightningNode {
|
func genRandomNode(t *rapid.T) *models.Node {
|
||||||
// Generate a random alias that is valid.
|
// Generate a random alias that is valid.
|
||||||
alias := lnwire.RandNodeAlias(t)
|
alias := lnwire.RandNodeAlias(t)
|
||||||
|
|
||||||
@@ -1647,7 +1646,7 @@ func genRandomNode(t *rapid.T) *models.LightningNode {
|
|||||||
extraOpaqueData = nil
|
extraOpaqueData = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
node := &models.LightningNode{
|
node := &models.Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
AuthSigBytes: sigBytes,
|
AuthSigBytes: sigBytes,
|
||||||
LastUpdate: randTime,
|
LastUpdate: randTime,
|
||||||
|
|||||||
+29
-29
@@ -241,14 +241,14 @@ func NewSQLStore(cfg *SQLStoreConfig, db BatchedSQLQueries,
|
|||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddLightningNode adds a vertex/node to the graph database. If the node is not
|
// AddNode adds a vertex/node to the graph database. If the node is not
|
||||||
// in the database from before, this will add a new, unconnected one to the
|
// in the database from before, this will add a new, unconnected one to the
|
||||||
// graph. If it is present from before, this will update that node's
|
// graph. If it is present from before, this will update that node's
|
||||||
// information.
|
// information.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the V1Store interface.
|
||||||
func (s *SQLStore) AddLightningNode(ctx context.Context,
|
func (s *SQLStore) AddNode(ctx context.Context,
|
||||||
node *models.LightningNode, opts ...batch.SchedulerOption) error {
|
node *models.Node, opts ...batch.SchedulerOption) error {
|
||||||
|
|
||||||
r := &batch.Request[SQLQueries]{
|
r := &batch.Request[SQLQueries]{
|
||||||
Opts: batch.NewSchedulerOptions(opts...),
|
Opts: batch.NewSchedulerOptions(opts...),
|
||||||
@@ -261,15 +261,15 @@ func (s *SQLStore) AddLightningNode(ctx context.Context,
|
|||||||
return s.nodeScheduler.Execute(ctx, r)
|
return s.nodeScheduler.Execute(ctx, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FetchLightningNode attempts to look up a target node by its identity public
|
// FetchNode attempts to look up a target node by its identity public
|
||||||
// key. If the node isn't found in the database, then ErrGraphNodeNotFound is
|
// key. If the node isn't found in the database, then ErrGraphNodeNotFound is
|
||||||
// returned.
|
// returned.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the V1Store interface.
|
||||||
func (s *SQLStore) FetchLightningNode(ctx context.Context,
|
func (s *SQLStore) FetchNode(ctx context.Context,
|
||||||
pubKey route.Vertex) (*models.LightningNode, error) {
|
pubKey route.Vertex) (*models.Node, error) {
|
||||||
|
|
||||||
var node *models.LightningNode
|
var node *models.Node
|
||||||
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
||||||
var err error
|
var err error
|
||||||
_, node, err = getNodeByPubKey(ctx, s.cfg.QueryCfg, db, pubKey)
|
_, node, err = getNodeByPubKey(ctx, s.cfg.QueryCfg, db, pubKey)
|
||||||
@@ -283,14 +283,14 @@ func (s *SQLStore) FetchLightningNode(ctx context.Context,
|
|||||||
return node, nil
|
return node, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasLightningNode determines if the graph has a vertex identified by the
|
// HasNode determines if the graph has a vertex identified by the
|
||||||
// target node identity public key. If the node exists in the database, a
|
// target node identity public key. If the node exists in the database, a
|
||||||
// timestamp of when the data for the node was lasted updated is returned along
|
// timestamp of when the data for the node was lasted updated is returned along
|
||||||
// with a true boolean. Otherwise, an empty time.Time is returned with a false
|
// with a true boolean. Otherwise, an empty time.Time is returned with a false
|
||||||
// boolean.
|
// boolean.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the V1Store interface.
|
||||||
func (s *SQLStore) HasLightningNode(ctx context.Context,
|
func (s *SQLStore) HasNode(ctx context.Context,
|
||||||
pubKey [33]byte) (time.Time, bool, error) {
|
pubKey [33]byte) (time.Time, bool, error) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -369,11 +369,11 @@ func (s *SQLStore) AddrsForNode(ctx context.Context,
|
|||||||
return known, addresses, nil
|
return known, addresses, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteLightningNode starts a new database transaction to remove a vertex/node
|
// DeleteNode starts a new database transaction to remove a vertex/node
|
||||||
// from the database according to the node's public key.
|
// from the database according to the node's public key.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the V1Store interface.
|
||||||
func (s *SQLStore) DeleteLightningNode(ctx context.Context,
|
func (s *SQLStore) DeleteNode(ctx context.Context,
|
||||||
pubKey route.Vertex) error {
|
pubKey route.Vertex) error {
|
||||||
|
|
||||||
err := s.db.ExecTx(ctx, sqldb.WriteTxOpt(), func(db SQLQueries) error {
|
err := s.db.ExecTx(ctx, sqldb.WriteTxOpt(), func(db SQLQueries) error {
|
||||||
@@ -489,10 +489,10 @@ func (s *SQLStore) LookupAlias(ctx context.Context,
|
|||||||
// node based off the source node.
|
// node based off the source node.
|
||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the V1Store interface.
|
||||||
func (s *SQLStore) SourceNode(ctx context.Context) (*models.LightningNode,
|
func (s *SQLStore) SourceNode(ctx context.Context) (*models.Node,
|
||||||
error) {
|
error) {
|
||||||
|
|
||||||
var node *models.LightningNode
|
var node *models.Node
|
||||||
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
||||||
_, nodePub, err := s.getSourceNode(ctx, db, ProtocolV1)
|
_, nodePub, err := s.getSourceNode(ctx, db, ProtocolV1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -517,7 +517,7 @@ func (s *SQLStore) SourceNode(ctx context.Context) (*models.LightningNode,
|
|||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the V1Store interface.
|
||||||
func (s *SQLStore) SetSourceNode(ctx context.Context,
|
func (s *SQLStore) SetSourceNode(ctx context.Context,
|
||||||
node *models.LightningNode) error {
|
node *models.Node) error {
|
||||||
|
|
||||||
return s.db.ExecTx(ctx, sqldb.WriteTxOpt(), func(db SQLQueries) error {
|
return s.db.ExecTx(ctx, sqldb.WriteTxOpt(), func(db SQLQueries) error {
|
||||||
id, err := upsertNode(ctx, db, node)
|
id, err := upsertNode(ctx, db, node)
|
||||||
@@ -553,11 +553,11 @@ func (s *SQLStore) SetSourceNode(ctx context.Context,
|
|||||||
//
|
//
|
||||||
// NOTE: This is part of the V1Store interface.
|
// NOTE: This is part of the V1Store interface.
|
||||||
func (s *SQLStore) NodeUpdatesInHorizon(startTime,
|
func (s *SQLStore) NodeUpdatesInHorizon(startTime,
|
||||||
endTime time.Time) ([]models.LightningNode, error) {
|
endTime time.Time) ([]models.Node, error) {
|
||||||
|
|
||||||
ctx := context.TODO()
|
ctx := context.TODO()
|
||||||
|
|
||||||
var nodes []models.LightningNode
|
var nodes []models.Node
|
||||||
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
||||||
dbNodes, err := db.GetNodesByLastUpdateRange(
|
dbNodes, err := db.GetNodesByLastUpdateRange(
|
||||||
ctx, sqlc.GetNodesByLastUpdateRangeParams{
|
ctx, sqlc.GetNodesByLastUpdateRangeParams{
|
||||||
@@ -571,7 +571,7 @@ func (s *SQLStore) NodeUpdatesInHorizon(startTime,
|
|||||||
|
|
||||||
err = forEachNodeInBatch(
|
err = forEachNodeInBatch(
|
||||||
ctx, s.cfg.QueryCfg, db, dbNodes,
|
ctx, s.cfg.QueryCfg, db, dbNodes,
|
||||||
func(_ int64, node *models.LightningNode) error {
|
func(_ int64, node *models.Node) error {
|
||||||
nodes = append(nodes, *node)
|
nodes = append(nodes, *node)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -776,7 +776,7 @@ func (s *SQLStore) updateEdgeCache(e *models.ChannelEdgePolicy,
|
|||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the V1Store interface.
|
||||||
func (s *SQLStore) ForEachSourceNodeChannel(ctx context.Context,
|
func (s *SQLStore) ForEachSourceNodeChannel(ctx context.Context,
|
||||||
cb func(chanPoint wire.OutPoint, havePolicy bool,
|
cb func(chanPoint wire.OutPoint, havePolicy bool,
|
||||||
otherNode *models.LightningNode) error, reset func()) error {
|
otherNode *models.Node) error, reset func()) error {
|
||||||
|
|
||||||
return s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
return s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
||||||
nodeID, nodePub, err := s.getSourceNode(ctx, db, ProtocolV1)
|
nodeID, nodePub, err := s.getSourceNode(ctx, db, ProtocolV1)
|
||||||
@@ -832,13 +832,13 @@ func (s *SQLStore) ForEachSourceNodeChannel(ctx context.Context,
|
|||||||
//
|
//
|
||||||
// NOTE: part of the V1Store interface.
|
// NOTE: part of the V1Store interface.
|
||||||
func (s *SQLStore) ForEachNode(ctx context.Context,
|
func (s *SQLStore) ForEachNode(ctx context.Context,
|
||||||
cb func(node *models.LightningNode) error, reset func()) error {
|
cb func(node *models.Node) error, reset func()) error {
|
||||||
|
|
||||||
return s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
return s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
||||||
return forEachNodePaginated(
|
return forEachNodePaginated(
|
||||||
ctx, s.cfg.QueryCfg, db,
|
ctx, s.cfg.QueryCfg, db,
|
||||||
ProtocolV1, func(_ context.Context, _ int64,
|
ProtocolV1, func(_ context.Context, _ int64,
|
||||||
node *models.LightningNode) error {
|
node *models.Node) error {
|
||||||
|
|
||||||
return cb(node)
|
return cb(node)
|
||||||
},
|
},
|
||||||
@@ -3201,7 +3201,7 @@ func updateChanEdgePolicy(ctx context.Context, tx SQLQueries,
|
|||||||
|
|
||||||
// getNodeByPubKey attempts to look up a target node by its public key.
|
// getNodeByPubKey attempts to look up a target node by its public key.
|
||||||
func getNodeByPubKey(ctx context.Context, cfg *sqldb.QueryConfig, db SQLQueries,
|
func getNodeByPubKey(ctx context.Context, cfg *sqldb.QueryConfig, db SQLQueries,
|
||||||
pubKey route.Vertex) (int64, *models.LightningNode, error) {
|
pubKey route.Vertex) (int64, *models.Node, error) {
|
||||||
|
|
||||||
dbNode, err := db.GetNodeByPubKey(
|
dbNode, err := db.GetNodeByPubKey(
|
||||||
ctx, sqlc.GetNodeByPubKeyParams{
|
ctx, sqlc.GetNodeByPubKeyParams{
|
||||||
@@ -3236,11 +3236,11 @@ func buildCacheableChannelInfo(scid []byte, capacity int64, node1Pub,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// buildNode constructs a LightningNode instance from the given database node
|
// buildNode constructs a Node instance from the given database node
|
||||||
// record. The node's features, addresses and extra signed fields are also
|
// record. The node's features, addresses and extra signed fields are also
|
||||||
// fetched from the database and set on the node.
|
// fetched from the database and set on the node.
|
||||||
func buildNode(ctx context.Context, cfg *sqldb.QueryConfig, db SQLQueries,
|
func buildNode(ctx context.Context, cfg *sqldb.QueryConfig, db SQLQueries,
|
||||||
dbNode sqlc.GraphNode) (*models.LightningNode, error) {
|
dbNode sqlc.GraphNode) (*models.Node, error) {
|
||||||
|
|
||||||
data, err := batchLoadNodeData(ctx, cfg, db, []int64{dbNode.ID})
|
data, err := batchLoadNodeData(ctx, cfg, db, []int64{dbNode.ID})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -3251,12 +3251,12 @@ func buildNode(ctx context.Context, cfg *sqldb.QueryConfig, db SQLQueries,
|
|||||||
return buildNodeWithBatchData(dbNode, data)
|
return buildNodeWithBatchData(dbNode, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// buildNodeWithBatchData builds a models.LightningNode instance
|
// buildNodeWithBatchData builds a models.Node instance
|
||||||
// from the provided sqlc.GraphNode and batchNodeData. If the node does have
|
// from the provided sqlc.GraphNode and batchNodeData. If the node does have
|
||||||
// features/addresses/extra fields, then the corresponding fields are expected
|
// features/addresses/extra fields, then the corresponding fields are expected
|
||||||
// to be present in the batchNodeData.
|
// to be present in the batchNodeData.
|
||||||
func buildNodeWithBatchData(dbNode sqlc.GraphNode,
|
func buildNodeWithBatchData(dbNode sqlc.GraphNode,
|
||||||
batchData *batchNodeData) (*models.LightningNode, error) {
|
batchData *batchNodeData) (*models.Node, error) {
|
||||||
|
|
||||||
if dbNode.Version != int16(ProtocolV1) {
|
if dbNode.Version != int16(ProtocolV1) {
|
||||||
return nil, fmt.Errorf("unsupported node version: %d",
|
return nil, fmt.Errorf("unsupported node version: %d",
|
||||||
@@ -3266,7 +3266,7 @@ func buildNodeWithBatchData(dbNode sqlc.GraphNode,
|
|||||||
var pub [33]byte
|
var pub [33]byte
|
||||||
copy(pub[:], dbNode.PubKey)
|
copy(pub[:], dbNode.PubKey)
|
||||||
|
|
||||||
node := &models.LightningNode{
|
node := &models.Node{
|
||||||
PubKeyBytes: pub,
|
PubKeyBytes: pub,
|
||||||
Features: lnwire.EmptyFeatureVector(),
|
Features: lnwire.EmptyFeatureVector(),
|
||||||
LastUpdate: time.Unix(0, 0),
|
LastUpdate: time.Unix(0, 0),
|
||||||
@@ -3328,7 +3328,7 @@ func buildNodeWithBatchData(dbNode sqlc.GraphNode,
|
|||||||
// with the preloaded data, and executes the provided callback for each node.
|
// with the preloaded data, and executes the provided callback for each node.
|
||||||
func forEachNodeInBatch(ctx context.Context, cfg *sqldb.QueryConfig,
|
func forEachNodeInBatch(ctx context.Context, cfg *sqldb.QueryConfig,
|
||||||
db SQLQueries, nodes []sqlc.GraphNode,
|
db SQLQueries, nodes []sqlc.GraphNode,
|
||||||
cb func(dbID int64, node *models.LightningNode) error) error {
|
cb func(dbID int64, node *models.Node) error) error {
|
||||||
|
|
||||||
// Extract node IDs for batch loading.
|
// Extract node IDs for batch loading.
|
||||||
nodeIDs := make([]int64, len(nodes))
|
nodeIDs := make([]int64, len(nodes))
|
||||||
@@ -3382,7 +3382,7 @@ func getNodeFeatures(ctx context.Context, db SQLQueries,
|
|||||||
// then a new node is created. The node's features, addresses and extra TLV
|
// then a new node is created. The node's features, addresses and extra TLV
|
||||||
// types are also updated. The node's DB ID is returned.
|
// types are also updated. The node's DB ID is returned.
|
||||||
func upsertNode(ctx context.Context, db SQLQueries,
|
func upsertNode(ctx context.Context, db SQLQueries,
|
||||||
node *models.LightningNode) (int64, error) {
|
node *models.Node) (int64, error) {
|
||||||
|
|
||||||
params := sqlc.UpsertNodeParams{
|
params := sqlc.UpsertNodeParams{
|
||||||
Version: int16(ProtocolV1),
|
Version: int16(ProtocolV1),
|
||||||
@@ -5064,7 +5064,7 @@ func batchLoadChannelPolicyExtrasHelper(ctx context.Context,
|
|||||||
func forEachNodePaginated(ctx context.Context, cfg *sqldb.QueryConfig,
|
func forEachNodePaginated(ctx context.Context, cfg *sqldb.QueryConfig,
|
||||||
db SQLQueries, protocol ProtocolVersion,
|
db SQLQueries, protocol ProtocolVersion,
|
||||||
processNode func(context.Context, int64,
|
processNode func(context.Context, int64,
|
||||||
*models.LightningNode) error) error {
|
*models.Node) error) error {
|
||||||
|
|
||||||
pageQueryFunc := func(ctx context.Context, lastID int64,
|
pageQueryFunc := func(ctx context.Context, lastID int64,
|
||||||
limit int32) ([]sqlc.GraphNode, error) {
|
limit int32) ([]sqlc.GraphNode, error) {
|
||||||
|
|||||||
+11
-13
@@ -23,7 +23,7 @@ type ChannelGraphSource interface {
|
|||||||
// AddNode is used to add information about a node to the router
|
// AddNode is used to add information about a node to the router
|
||||||
// database. If the node with this pubkey is not present in an existing
|
// database. If the node with this pubkey is not present in an existing
|
||||||
// channel, it will be ignored.
|
// channel, it will be ignored.
|
||||||
AddNode(ctx context.Context, node *models.LightningNode,
|
AddNode(ctx context.Context, node *models.Node,
|
||||||
op ...batch.SchedulerOption) error
|
op ...batch.SchedulerOption) error
|
||||||
|
|
||||||
// AddEdge is used to add edge/channel to the topology of the router,
|
// AddEdge is used to add edge/channel to the topology of the router,
|
||||||
@@ -83,11 +83,10 @@ type ChannelGraphSource interface {
|
|||||||
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
*models.ChannelEdgeInfo, *models.ChannelEdgePolicy,
|
||||||
*models.ChannelEdgePolicy, error)
|
*models.ChannelEdgePolicy, error)
|
||||||
|
|
||||||
// FetchLightningNode attempts to look up a target node by its identity
|
// FetchNode attempts to look up a target node by its identity
|
||||||
// public key. channeldb.ErrGraphNodeNotFound is returned if the node
|
// public key. channeldb.ErrGraphNodeNotFound is returned if the node
|
||||||
// doesn't exist within the graph.
|
// doesn't exist within the graph.
|
||||||
FetchLightningNode(context.Context,
|
FetchNode(context.Context, route.Vertex) (*models.Node, error)
|
||||||
route.Vertex) (*models.LightningNode, error)
|
|
||||||
|
|
||||||
// MarkZombieEdge marks the channel with the given ID as a zombie edge.
|
// MarkZombieEdge marks the channel with the given ID as a zombie edge.
|
||||||
MarkZombieEdge(chanID uint64) error
|
MarkZombieEdge(chanID uint64) error
|
||||||
@@ -135,7 +134,7 @@ type DB interface {
|
|||||||
// treated as the center node within a star-graph. This method may be
|
// treated as the center node within a star-graph. This method may be
|
||||||
// used to kick off a path finding algorithm in order to explore the
|
// used to kick off a path finding algorithm in order to explore the
|
||||||
// reachability of another node based off the source node.
|
// reachability of another node based off the source node.
|
||||||
SourceNode(ctx context.Context) (*models.LightningNode, error)
|
SourceNode(ctx context.Context) (*models.Node, error)
|
||||||
|
|
||||||
// DisabledChannelIDs returns the channel ids of disabled channels.
|
// DisabledChannelIDs returns the channel ids of disabled channels.
|
||||||
// A channel is disabled when two of the associated ChanelEdgePolicies
|
// A channel is disabled when two of the associated ChanelEdgePolicies
|
||||||
@@ -200,13 +199,13 @@ type DB interface {
|
|||||||
FetchChannelEdgesByID(chanID uint64) (*models.ChannelEdgeInfo,
|
FetchChannelEdgesByID(chanID uint64) (*models.ChannelEdgeInfo,
|
||||||
*models.ChannelEdgePolicy, *models.ChannelEdgePolicy, error)
|
*models.ChannelEdgePolicy, *models.ChannelEdgePolicy, error)
|
||||||
|
|
||||||
// AddLightningNode adds a vertex/node to the graph database. If the
|
// AddNode adds a vertex/node to the graph database. If the
|
||||||
// node is not in the database from before, this will add a new,
|
// node is not in the database from before, this will add a new,
|
||||||
// unconnected one to the graph. If it is present from before, this will
|
// unconnected one to the graph. If it is present from before, this will
|
||||||
// update that node's information. Note that this method is expected to
|
// update that node's information. Note that this method is expected to
|
||||||
// only be called to update an already present node from a node
|
// only be called to update an already present node from a node
|
||||||
// announcement, or to insert a node found in a channel update.
|
// announcement, or to insert a node found in a channel update.
|
||||||
AddLightningNode(ctx context.Context, node *models.LightningNode,
|
AddNode(ctx context.Context, node *models.Node,
|
||||||
op ...batch.SchedulerOption) error
|
op ...batch.SchedulerOption) error
|
||||||
|
|
||||||
// AddChannelEdge adds a new (undirected, blank) edge to the graph
|
// AddChannelEdge adds a new (undirected, blank) edge to the graph
|
||||||
@@ -235,19 +234,18 @@ type DB interface {
|
|||||||
UpdateEdgePolicy(ctx context.Context, edge *models.ChannelEdgePolicy,
|
UpdateEdgePolicy(ctx context.Context, edge *models.ChannelEdgePolicy,
|
||||||
op ...batch.SchedulerOption) error
|
op ...batch.SchedulerOption) error
|
||||||
|
|
||||||
// HasLightningNode determines if the graph has a vertex identified by
|
// HasNode determines if the graph has a vertex identified by
|
||||||
// the target node identity public key. If the node exists in the
|
// the target node identity public key. If the node exists in the
|
||||||
// database, a timestamp of when the data for the node was lasted
|
// database, a timestamp of when the data for the node was lasted
|
||||||
// updated is returned along with a true boolean. Otherwise, an empty
|
// updated is returned along with a true boolean. Otherwise, an empty
|
||||||
// time.Time is returned with a false boolean.
|
// time.Time is returned with a false boolean.
|
||||||
HasLightningNode(ctx context.Context, nodePub [33]byte) (time.Time,
|
HasNode(ctx context.Context, nodePub [33]byte) (time.Time, bool, error)
|
||||||
bool, error)
|
|
||||||
|
|
||||||
// FetchLightningNode attempts to look up a target node by its identity
|
// FetchNode attempts to look up a target node by its identity
|
||||||
// public key. If the node isn't found in the database, then
|
// public key. If the node isn't found in the database, then
|
||||||
// ErrGraphNodeNotFound is returned.
|
// ErrGraphNodeNotFound is returned.
|
||||||
FetchLightningNode(ctx context.Context,
|
FetchNode(ctx context.Context, nodePub route.Vertex) (*models.Node,
|
||||||
nodePub route.Vertex) (*models.LightningNode, error)
|
error)
|
||||||
|
|
||||||
// ForEachNodeChannel iterates through all channels of the given node,
|
// ForEachNodeChannel iterates through all channels of the given node,
|
||||||
// executing the passed callback with an edge info structure and the
|
// executing the passed callback with an edge info structure and the
|
||||||
|
|||||||
@@ -76,14 +76,14 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func createTestNode(t *testing.T) *models.LightningNode {
|
func createTestNode(t *testing.T) *models.Node {
|
||||||
updateTime := prand.Int63()
|
updateTime := prand.Int63()
|
||||||
|
|
||||||
priv, err := btcec.NewPrivateKey()
|
priv, err := btcec.NewPrivateKey()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
pub := priv.PubKey().SerializeCompressed()
|
pub := priv.PubKey().SerializeCompressed()
|
||||||
n := &models.LightningNode{
|
n := &models.Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
LastUpdate: time.Unix(updateTime, 0),
|
LastUpdate: time.Unix(updateTime, 0),
|
||||||
Addresses: testAddrs,
|
Addresses: testAddrs,
|
||||||
@@ -98,7 +98,7 @@ func createTestNode(t *testing.T) *models.LightningNode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func randEdgePolicy(chanID *lnwire.ShortChannelID,
|
func randEdgePolicy(chanID *lnwire.ShortChannelID,
|
||||||
node *models.LightningNode) (*models.ChannelEdgePolicy, error) {
|
node *models.Node) (*models.ChannelEdgePolicy, error) {
|
||||||
|
|
||||||
InboundFee := models.InboundFee{
|
InboundFee := models.InboundFee{
|
||||||
Base: prand.Int31() * -1,
|
Base: prand.Int31() * -1,
|
||||||
@@ -676,7 +676,7 @@ func TestNodeUpdateNotification(t *testing.T) {
|
|||||||
t.Fatalf("unable to add node: %v", err)
|
t.Fatalf("unable to add node: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
assertNodeNtfnCorrect := func(t *testing.T, ann *models.LightningNode,
|
assertNodeNtfnCorrect := func(t *testing.T, ann *models.Node,
|
||||||
nodeUpdate *graphdb.NetworkNodeUpdate) {
|
nodeUpdate *graphdb.NetworkNodeUpdate) {
|
||||||
|
|
||||||
nodeKey, _ := ann.PubKey()
|
nodeKey, _ := ann.PubKey()
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ func (s *Server) ImportGraph(ctx context.Context,
|
|||||||
|
|
||||||
var err error
|
var err error
|
||||||
for _, rpcNode := range graph.Nodes {
|
for _, rpcNode := range graph.Nodes {
|
||||||
node := &models.LightningNode{
|
node := &models.Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
LastUpdate: time.Unix(
|
LastUpdate: time.Unix(
|
||||||
int64(rpcNode.LastUpdate), 0,
|
int64(rpcNode.LastUpdate), 0,
|
||||||
@@ -260,7 +260,7 @@ func (s *Server) ImportGraph(ctx context.Context,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := graphDB.AddLightningNode(ctx, node); err != nil {
|
if err := graphDB.AddNode(ctx, node); err != nil {
|
||||||
return nil, fmt.Errorf("unable to add node %v: %w",
|
return nil, fmt.Errorf("unable to add node %v: %w",
|
||||||
rpcNode.PubKey, err)
|
rpcNode.PubKey, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
|
|||||||
privKeyMap := make(map[string]*btcec.PrivateKey)
|
privKeyMap := make(map[string]*btcec.PrivateKey)
|
||||||
channelIDs := make(map[route.Vertex]map[route.Vertex]uint64)
|
channelIDs := make(map[route.Vertex]map[route.Vertex]uint64)
|
||||||
links := make(map[lnwire.ShortChannelID]htlcswitch.ChannelLink)
|
links := make(map[lnwire.ShortChannelID]htlcswitch.ChannelLink)
|
||||||
var source *models.LightningNode
|
var source *models.Node
|
||||||
|
|
||||||
// First we insert all the nodes within the graph as vertexes.
|
// First we insert all the nodes within the graph as vertexes.
|
||||||
for _, node := range g.Nodes {
|
for _, node := range g.Nodes {
|
||||||
@@ -228,7 +228,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
dbNode := &models.LightningNode{
|
dbNode := &models.Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
AuthSigBytes: testSig.Serialize(),
|
AuthSigBytes: testSig.Serialize(),
|
||||||
LastUpdate: testTime,
|
LastUpdate: testTime,
|
||||||
@@ -293,14 +293,14 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
|
|||||||
source = dbNode
|
source = dbNode
|
||||||
|
|
||||||
// If this is the source node, we don't have to call
|
// If this is the source node, we don't have to call
|
||||||
// AddLightningNode below since we will call
|
// AddNode below since we will call
|
||||||
// SetSourceNode later.
|
// SetSourceNode later.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// With the node fully parsed, add it as a vertex within the
|
// With the node fully parsed, add it as a vertex within the
|
||||||
// graph.
|
// graph.
|
||||||
if err := graph.AddLightningNode(ctx, dbNode); err != nil {
|
if err := graph.AddNode(ctx, dbNode); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -565,7 +565,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
|
|||||||
features = lnwire.EmptyFeatureVector()
|
features = lnwire.EmptyFeatureVector()
|
||||||
}
|
}
|
||||||
|
|
||||||
dbNode := &models.LightningNode{
|
dbNode := &models.Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
AuthSigBytes: testSig.Serialize(),
|
AuthSigBytes: testSig.Serialize(),
|
||||||
LastUpdate: testTime,
|
LastUpdate: testTime,
|
||||||
@@ -584,7 +584,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
|
|||||||
err = graph.SetSourceNode(ctx, dbNode)
|
err = graph.SetSourceNode(ctx, dbNode)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
} else {
|
} else {
|
||||||
err := graph.AddLightningNode(ctx, dbNode)
|
err := graph.AddNode(ctx, dbNode)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1253,7 +1253,7 @@ func runPathFindingWithAdditionalEdges(t *testing.T, useCache bool) {
|
|||||||
dogePubKey, err := btcec.ParsePubKey(dogePubKeyBytes)
|
dogePubKey, err := btcec.ParsePubKey(dogePubKeyBytes)
|
||||||
require.NoError(t, err, "unable to parse public key from bytes")
|
require.NoError(t, err, "unable to parse public key from bytes")
|
||||||
|
|
||||||
doge := &models.LightningNode{}
|
doge := &models.Node{}
|
||||||
doge.AddPubKey(dogePubKey)
|
doge.AddPubKey(dogePubKey)
|
||||||
doge.Alias = "doge"
|
doge.Alias = "doge"
|
||||||
copy(doge.PubKeyBytes[:], dogePubKeyBytes)
|
copy(doge.PubKeyBytes[:], dogePubKeyBytes)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ type SessionSource struct {
|
|||||||
GraphSessionFactory GraphSessionFactory
|
GraphSessionFactory GraphSessionFactory
|
||||||
|
|
||||||
// SourceNode is the graph's source node.
|
// SourceNode is the graph's source node.
|
||||||
SourceNode *models.LightningNode
|
SourceNode *models.Node
|
||||||
|
|
||||||
// GetLink is a method that allows querying the lower link layer
|
// GetLink is a method that allows querying the lower link layer
|
||||||
// to determine the up to date available bandwidth at a prospective link
|
// to determine the up to date available bandwidth at a prospective link
|
||||||
@@ -102,7 +102,7 @@ func RouteHintsToEdges(routeHints [][]zpay32.HopHint, target route.Vertex) (
|
|||||||
// we'll need to look at the next hint's start node. If
|
// we'll need to look at the next hint's start node. If
|
||||||
// we've reached the end of the hints list, we can
|
// we've reached the end of the hints list, we can
|
||||||
// assume we've reached the destination.
|
// assume we've reached the destination.
|
||||||
endNode := &models.LightningNode{}
|
endNode := &models.Node{}
|
||||||
if i != len(routeHint)-1 {
|
if i != len(routeHint)-1 {
|
||||||
endNode.AddPubKey(routeHint[i+1].NodeID)
|
endNode.AddPubKey(routeHint[i+1].NodeID)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ func TestUpdateAdditionalEdge(t *testing.T) {
|
|||||||
|
|
||||||
// Create a minimal test node using the private key priv1.
|
// Create a minimal test node using the private key priv1.
|
||||||
pub := priv1.PubKey().SerializeCompressed()
|
pub := priv1.PubKey().SerializeCompressed()
|
||||||
testNode := &models.LightningNode{}
|
testNode := &models.Node{}
|
||||||
copy(testNode.PubKeyBytes[:], pub)
|
copy(testNode.PubKeyBytes[:], pub)
|
||||||
|
|
||||||
nodeID, err := testNode.PubKey()
|
nodeID, err := testNode.PubKey()
|
||||||
|
|||||||
+12
-12
@@ -183,7 +183,7 @@ func createTestCtxFromGraphInstanceAssumeValid(t *testing.T,
|
|||||||
return ctx
|
return ctx
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTestNode() (*models.LightningNode, error) {
|
func createTestNode() (*models.Node, error) {
|
||||||
updateTime := rand.Int63()
|
updateTime := rand.Int63()
|
||||||
|
|
||||||
priv, err := btcec.NewPrivateKey()
|
priv, err := btcec.NewPrivateKey()
|
||||||
@@ -192,7 +192,7 @@ func createTestNode() (*models.LightningNode, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub := priv.PubKey().SerializeCompressed()
|
pub := priv.PubKey().SerializeCompressed()
|
||||||
n := &models.LightningNode{
|
n := &models.Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
LastUpdate: time.Unix(updateTime, 0),
|
LastUpdate: time.Unix(updateTime, 0),
|
||||||
Addresses: testAddrs,
|
Addresses: testAddrs,
|
||||||
@@ -2718,11 +2718,11 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
|||||||
copy(pub2[:], priv2.PubKey().SerializeCompressed())
|
copy(pub2[:], priv2.PubKey().SerializeCompressed())
|
||||||
|
|
||||||
// The two nodes we are about to add should not exist yet.
|
// The two nodes we are about to add should not exist yet.
|
||||||
_, exists1, err := ctx.graph.HasLightningNode(ctxb, pub1)
|
_, exists1, err := ctx.graph.HasNode(ctxb, pub1)
|
||||||
require.NoError(t, err, "unable to query graph")
|
require.NoError(t, err, "unable to query graph")
|
||||||
require.False(t, exists1)
|
require.False(t, exists1)
|
||||||
|
|
||||||
_, exists2, err := ctx.graph.HasLightningNode(ctxb, pub2)
|
_, exists2, err := ctx.graph.HasNode(ctxb, pub2)
|
||||||
require.NoError(t, err, "unable to query graph")
|
require.NoError(t, err, "unable to query graph")
|
||||||
require.False(t, exists2)
|
require.False(t, exists2)
|
||||||
|
|
||||||
@@ -2779,11 +2779,11 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
|||||||
|
|
||||||
// After adding the edge between the two previously unknown nodes, they
|
// After adding the edge between the two previously unknown nodes, they
|
||||||
// should have been added to the graph.
|
// should have been added to the graph.
|
||||||
_, exists1, err = ctx.graph.HasLightningNode(ctxb, pub1)
|
_, exists1, err = ctx.graph.HasNode(ctxb, pub1)
|
||||||
require.NoError(t, err, "unable to query graph")
|
require.NoError(t, err, "unable to query graph")
|
||||||
require.True(t, exists1)
|
require.True(t, exists1)
|
||||||
|
|
||||||
_, exists2, err = ctx.graph.HasLightningNode(ctxb, pub2)
|
_, exists2, err = ctx.graph.HasNode(ctxb, pub2)
|
||||||
require.NoError(t, err, "unable to query graph")
|
require.NoError(t, err, "unable to query graph")
|
||||||
require.True(t, exists2)
|
require.True(t, exists2)
|
||||||
|
|
||||||
@@ -2871,7 +2871,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
|||||||
|
|
||||||
// Now check that we can update the node info for the partial node
|
// Now check that we can update the node info for the partial node
|
||||||
// without messing up the channel graph.
|
// without messing up the channel graph.
|
||||||
n1 := &models.LightningNode{
|
n1 := &models.Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
LastUpdate: time.Unix(123, 0),
|
LastUpdate: time.Unix(123, 0),
|
||||||
Addresses: testAddrs,
|
Addresses: testAddrs,
|
||||||
@@ -2882,9 +2882,9 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
copy(n1.PubKeyBytes[:], priv1.PubKey().SerializeCompressed())
|
copy(n1.PubKeyBytes[:], priv1.PubKey().SerializeCompressed())
|
||||||
|
|
||||||
require.NoError(t, ctx.graph.AddLightningNode(ctxb, n1))
|
require.NoError(t, ctx.graph.AddNode(ctxb, n1))
|
||||||
|
|
||||||
n2 := &models.LightningNode{
|
n2 := &models.Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
LastUpdate: time.Unix(123, 0),
|
LastUpdate: time.Unix(123, 0),
|
||||||
Addresses: testAddrs,
|
Addresses: testAddrs,
|
||||||
@@ -2895,7 +2895,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
|||||||
}
|
}
|
||||||
copy(n2.PubKeyBytes[:], priv2.PubKey().SerializeCompressed())
|
copy(n2.PubKeyBytes[:], priv2.PubKey().SerializeCompressed())
|
||||||
|
|
||||||
require.NoError(t, ctx.graph.AddLightningNode(ctxb, n2))
|
require.NoError(t, ctx.graph.AddNode(ctxb, n2))
|
||||||
|
|
||||||
// Should still be able to find the route, and the info should be
|
// Should still be able to find the route, and the info should be
|
||||||
// updated.
|
// updated.
|
||||||
@@ -2908,12 +2908,12 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
|
|||||||
_, _, err = ctx.router.FindRoute(req)
|
_, _, err = ctx.router.FindRoute(req)
|
||||||
require.NoError(t, err, "unable to find any routes")
|
require.NoError(t, err, "unable to find any routes")
|
||||||
|
|
||||||
copy1, err := ctx.graph.FetchLightningNode(ctxb, pub1)
|
copy1, err := ctx.graph.FetchNode(ctxb, pub1)
|
||||||
require.NoError(t, err, "unable to fetch node")
|
require.NoError(t, err, "unable to fetch node")
|
||||||
|
|
||||||
require.Equal(t, n1.Alias, copy1.Alias)
|
require.Equal(t, n1.Alias, copy1.Alias)
|
||||||
|
|
||||||
copy2, err := ctx.graph.FetchLightningNode(ctxb, pub2)
|
copy2, err := ctx.graph.FetchNode(ctxb, pub2)
|
||||||
require.NoError(t, err, "unable to fetch node")
|
require.NoError(t, err, "unable to fetch node")
|
||||||
|
|
||||||
require.Equal(t, n2.Alias, copy2.Alias)
|
require.Equal(t, n2.Alias, copy2.Alias)
|
||||||
|
|||||||
+5
-5
@@ -1783,7 +1783,7 @@ func (r *rpcServer) VerifyMessage(ctx context.Context,
|
|||||||
//
|
//
|
||||||
// TODO(phlip9): Require valid nodes to have capital in active channels.
|
// TODO(phlip9): Require valid nodes to have capital in active channels.
|
||||||
graph := r.server.graphDB
|
graph := r.server.graphDB
|
||||||
_, active, err := graph.HasLightningNode(ctx, pub)
|
_, active, err := graph.HasNode(ctx, pub)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to query graph: %w", err)
|
return nil, fmt.Errorf("failed to query graph: %w", err)
|
||||||
}
|
}
|
||||||
@@ -6758,7 +6758,7 @@ func (r *rpcServer) DescribeGraph(ctx context.Context,
|
|||||||
// First iterate through all the known nodes (connected or unconnected
|
// First iterate through all the known nodes (connected or unconnected
|
||||||
// within the graph), collating their current state into the RPC
|
// within the graph), collating their current state into the RPC
|
||||||
// response.
|
// response.
|
||||||
err := graph.ForEachNode(ctx, func(node *models.LightningNode) error {
|
err := graph.ForEachNode(ctx, func(node *models.Node) error {
|
||||||
lnNode := marshalNode(node)
|
lnNode := marshalNode(node)
|
||||||
|
|
||||||
resp.Nodes = append(resp.Nodes, lnNode)
|
resp.Nodes = append(resp.Nodes, lnNode)
|
||||||
@@ -7053,7 +7053,7 @@ func (r *rpcServer) GetNodeInfo(ctx context.Context,
|
|||||||
// With the public key decoded, attempt to fetch the node corresponding
|
// With the public key decoded, attempt to fetch the node corresponding
|
||||||
// to this public key. If the node cannot be found, then an error will
|
// to this public key. If the node cannot be found, then an error will
|
||||||
// be returned.
|
// be returned.
|
||||||
node, err := graph.FetchLightningNode(ctx, pubKey)
|
node, err := graph.FetchNode(ctx, pubKey)
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, graphdb.ErrGraphNodeNotFound):
|
case errors.Is(err, graphdb.ErrGraphNodeNotFound):
|
||||||
return nil, status.Error(codes.NotFound, err.Error())
|
return nil, status.Error(codes.NotFound, err.Error())
|
||||||
@@ -7114,7 +7114,7 @@ func (r *rpcServer) GetNodeInfo(ctx context.Context,
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func marshalNode(node *models.LightningNode) *lnrpc.LightningNode {
|
func marshalNode(node *models.Node) *lnrpc.LightningNode {
|
||||||
nodeAddrs := make([]*lnrpc.NodeAddress, len(node.Addresses))
|
nodeAddrs := make([]*lnrpc.NodeAddress, len(node.Addresses))
|
||||||
for i, addr := range node.Addresses {
|
for i, addr := range node.Addresses {
|
||||||
nodeAddr := &lnrpc.NodeAddress{
|
nodeAddr := &lnrpc.NodeAddress{
|
||||||
@@ -8189,7 +8189,7 @@ func (r *rpcServer) ForwardingHistory(ctx context.Context,
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
peer, err := r.server.graphDB.FetchLightningNode(ctx, vertex)
|
peer, err := r.server.graphDB.FetchNode(ctx, vertex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3316,7 +3316,7 @@ func (s *server) createNewHiddenService(ctx context.Context) error {
|
|||||||
|
|
||||||
// Finally, we'll update the on-disk version of our announcement so it
|
// Finally, we'll update the on-disk version of our announcement so it
|
||||||
// will eventually propagate to nodes in the network.
|
// will eventually propagate to nodes in the network.
|
||||||
selfNode := &models.LightningNode{
|
selfNode := &models.Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
LastUpdate: time.Unix(int64(newNodeAnn.Timestamp), 0),
|
LastUpdate: time.Unix(int64(newNodeAnn.Timestamp), 0),
|
||||||
Addresses: newNodeAnn.Addresses,
|
Addresses: newNodeAnn.Addresses,
|
||||||
@@ -3505,7 +3505,7 @@ func (s *server) establishPersistentConnections(ctx context.Context) error {
|
|||||||
// each of the nodes.
|
// each of the nodes.
|
||||||
graphAddrs := make(map[string]*nodeAddresses)
|
graphAddrs := make(map[string]*nodeAddresses)
|
||||||
forEachSrcNodeChan := func(chanPoint wire.OutPoint,
|
forEachSrcNodeChan := func(chanPoint wire.OutPoint,
|
||||||
havePolicy bool, channelPeer *models.LightningNode) error {
|
havePolicy bool, channelPeer *models.Node) error {
|
||||||
|
|
||||||
// If the remote party has announced the channel to us, but we
|
// If the remote party has announced the channel to us, but we
|
||||||
// haven't yet, then we won't have a policy. However, we don't
|
// haven't yet, then we won't have a policy. However, we don't
|
||||||
@@ -5208,7 +5208,7 @@ func (s *server) fetchNodeAdvertisedAddrs(ctx context.Context,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
node, err := s.graphDB.FetchLightningNode(ctx, vertex)
|
node, err := s.graphDB.FetchNode(ctx, vertex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -5634,7 +5634,7 @@ func (s *server) setSelfNode(ctx context.Context, nodePub route.Vertex,
|
|||||||
|
|
||||||
// TODO(abdulkbk): potentially find a way to use the source node's
|
// TODO(abdulkbk): potentially find a way to use the source node's
|
||||||
// features in the self node.
|
// features in the self node.
|
||||||
selfNode := &models.LightningNode{
|
selfNode := &models.Node{
|
||||||
HaveNodeAnnouncement: true,
|
HaveNodeAnnouncement: true,
|
||||||
LastUpdate: nodeLastUpdate,
|
LastUpdate: nodeLastUpdate,
|
||||||
Addresses: addrs,
|
Addresses: addrs,
|
||||||
|
|||||||
Reference in new issue
Block a user