multi: move LightningNode struct to models package

This commit is contained in:
Elle Mouton
2024-10-29 18:25:07 +02:00
parent ccb8f0eeb8
commit 6e13898981
20 changed files with 252 additions and 246 deletions

View File

@@ -214,7 +214,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
privKeyMap := make(map[string]*btcec.PrivateKey)
channelIDs := make(map[route.Vertex]map[route.Vertex]uint64)
links := make(map[lnwire.ShortChannelID]htlcswitch.ChannelLink)
var source *graphdb.LightningNode
var source *models.LightningNode
// First we insert all the nodes within the graph as vertexes.
for _, node := range g.Nodes {
@@ -223,7 +223,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
return nil, err
}
dbNode := &graphdb.LightningNode{
dbNode := &models.LightningNode{
HaveNodeAnnouncement: true,
AuthSigBytes: testSig.Serialize(),
LastUpdate: testTime,
@@ -536,7 +536,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
nodeIndex := byte(0)
addNodeWithAlias := func(alias string, features *lnwire.FeatureVector) (
*graphdb.LightningNode, error) {
*models.LightningNode, error) {
keyBytes := []byte{
0, 0, 0, 0, 0, 0, 0, 0,
@@ -551,7 +551,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
features = lnwire.EmptyFeatureVector()
}
dbNode := &graphdb.LightningNode{
dbNode := &models.LightningNode{
HaveNodeAnnouncement: true,
AuthSigBytes: testSig.Serialize(),
LastUpdate: testTime,
@@ -1207,7 +1207,7 @@ func runPathFindingWithAdditionalEdges(t *testing.T, useCache bool) {
dogePubKey, err := btcec.ParsePubKey(dogePubKeyBytes)
require.NoError(t, err, "unable to parse public key from bytes")
doge := &graphdb.LightningNode{}
doge := &models.LightningNode{}
doge.AddPubKey(dogePubKey)
doge.Alias = "doge"
copy(doge.PubKeyBytes[:], dogePubKeyBytes)

View File

@@ -3,7 +3,6 @@ package routing
import (
"github.com/btcsuite/btcd/btcec/v2"
"github.com/lightningnetwork/lnd/fn"
graphdb "github.com/lightningnetwork/lnd/graph/db"
"github.com/lightningnetwork/lnd/graph/db/models"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route"
@@ -24,7 +23,7 @@ type SessionSource struct {
GraphSessionFactory GraphSessionFactory
// SourceNode is the graph's source node.
SourceNode *graphdb.LightningNode
SourceNode *models.LightningNode
// GetLink is a method that allows querying the lower link layer
// to determine the up to date available bandwidth at a prospective link
@@ -101,7 +100,7 @@ func RouteHintsToEdges(routeHints [][]zpay32.HopHint, target route.Vertex) (
// we'll need to look at the next hint's start node. If
// we've reached the end of the hints list, we can
// assume we've reached the destination.
endNode := &graphdb.LightningNode{}
endNode := &models.LightningNode{}
if i != len(routeHint)-1 {
endNode.AddPubKey(routeHint[i+1].NodeID)
} else {

View File

@@ -4,7 +4,6 @@ import (
"testing"
"time"
graphdb "github.com/lightningnetwork/lnd/graph/db"
"github.com/lightningnetwork/lnd/graph/db/models"
"github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnwire"
@@ -89,7 +88,7 @@ func TestUpdateAdditionalEdge(t *testing.T) {
// Create a minimal test node using the private key priv1.
pub := priv1.PubKey().SerializeCompressed()
testNode := &graphdb.LightningNode{}
testNode := &models.LightningNode{}
copy(testNode.PubKeyBytes[:], pub)
nodeID, err := testNode.PubKey()

View File

@@ -192,7 +192,7 @@ func createTestCtxFromGraphInstanceAssumeValid(t *testing.T,
return ctx
}
func createTestNode() (*graphdb.LightningNode, error) {
func createTestNode() (*models.LightningNode, error) {
updateTime := rand.Int63()
priv, err := btcec.NewPrivateKey()
@@ -201,7 +201,7 @@ func createTestNode() (*graphdb.LightningNode, error) {
}
pub := priv.PubKey().SerializeCompressed()
n := &graphdb.LightningNode{
n := &models.LightningNode{
HaveNodeAnnouncement: true,
LastUpdate: time.Unix(updateTime, 0),
Addresses: testAddrs,
@@ -2899,7 +2899,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
// Now check that we can update the node info for the partial node
// without messing up the channel graph.
n1 := &graphdb.LightningNode{
n1 := &models.LightningNode{
HaveNodeAnnouncement: true,
LastUpdate: time.Unix(123, 0),
Addresses: testAddrs,
@@ -2912,7 +2912,7 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
require.NoError(t, ctx.graph.AddLightningNode(n1))
n2 := &graphdb.LightningNode{
n2 := &models.LightningNode{
HaveNodeAnnouncement: true,
LastUpdate: time.Unix(123, 0),
Addresses: testAddrs,