multi: rename models.LightningNode to models.Node
This commit is contained in:
26 files changed
+212
-214
No files matched your search
+4
-4
@@ -975,7 +975,7 @@ func (b *Builder) ApplyChannelUpdate(msg *lnwire.ChannelUpdate1) bool {
|
||||
// be ignored.
|
||||
//
|
||||
// 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 {
|
||||
|
||||
err := b.addNode(ctx, node, op...)
|
||||
@@ -988,11 +988,11 @@ func (b *Builder) AddNode(ctx context.Context, node *models.LightningNode,
|
||||
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
|
||||
// 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.
|
||||
func (b *Builder) addNode(ctx context.Context, node *models.LightningNode,
|
||||
func (b *Builder) addNode(ctx context.Context, node *models.Node,
|
||||
op ...batch.SchedulerOption) error {
|
||||
|
||||
// Before we add the node to the database, we'll check to see if the
|
||||
@@ -1263,7 +1263,7 @@ func (b *Builder) GetChannelByID(chanID lnwire.ShortChannelID) (
|
||||
//
|
||||
// NOTE: This method is part of the ChannelGraphSource interface.
|
||||
func (b *Builder) FetchLightningNode(ctx context.Context,
|
||||
node route.Vertex) (*models.LightningNode, error) {
|
||||
node route.Vertex) (*models.Node, error) {
|
||||
|
||||
return b.cfg.Graph.FetchLightningNode(ctx, node)
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ func TestIgnoreNodeAnnouncement(t *testing.T) {
|
||||
ctx := createTestCtxFromFile(t, startingBlockHeight, basicGraphFilePath)
|
||||
|
||||
pub := priv1.PubKey()
|
||||
node := &models.LightningNode{
|
||||
node := &models.Node{
|
||||
HaveNodeAnnouncement: true,
|
||||
LastUpdate: time.Unix(123, 0),
|
||||
Addresses: testAddrs,
|
||||
@@ -1084,7 +1084,7 @@ func TestIsStaleNode(t *testing.T) {
|
||||
|
||||
// With the node stub in the database, we'll add the fully node
|
||||
// announcement to the database.
|
||||
n1 := &models.LightningNode{
|
||||
n1 := &models.Node{
|
||||
HaveNodeAnnouncement: true,
|
||||
LastUpdate: updateTimeStamp,
|
||||
Addresses: testAddrs,
|
||||
@@ -1392,7 +1392,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 *models.LightningNode
|
||||
var source *models.Node
|
||||
|
||||
// First we insert all the nodes within the graph as vertexes.
|
||||
for _, node := range g.Nodes {
|
||||
@@ -1401,7 +1401,7 @@ func parseTestGraph(t *testing.T, useCache bool, path string) (
|
||||
return nil, err
|
||||
}
|
||||
|
||||
dbNode := &models.LightningNode{
|
||||
dbNode := &models.Node{
|
||||
HaveNodeAnnouncement: true,
|
||||
AuthSigBytes: testSig.Serialize(),
|
||||
LastUpdate: testTime,
|
||||
@@ -1787,7 +1787,7 @@ func createTestGraphFromChannels(t *testing.T, useCache bool,
|
||||
features = lnwire.EmptyFeatureVector()
|
||||
}
|
||||
|
||||
dbNode := &models.LightningNode{
|
||||
dbNode := &models.Node{
|
||||
HaveNodeAnnouncement: true,
|
||||
AuthSigBytes: testSig.Serialize(),
|
||||
LastUpdate: testTime,
|
||||
|
||||
@@ -350,7 +350,7 @@ func TestPopulateDBs(t *testing.T) {
|
||||
countNodes := func(graph *ChannelGraph) int {
|
||||
numNodes := 0
|
||||
err := graph.ForEachNode(
|
||||
ctx, func(node *models.LightningNode) error {
|
||||
ctx, func(node *models.Node) error {
|
||||
numNodes++
|
||||
|
||||
return nil
|
||||
@@ -580,7 +580,7 @@ func syncGraph(t *testing.T, src, dest *ChannelGraph) {
|
||||
}
|
||||
|
||||
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)
|
||||
go func() {
|
||||
defer wgNodes.Done()
|
||||
@@ -746,7 +746,7 @@ func BenchmarkGraphReadMethods(b *testing.B) {
|
||||
fn: func(b testing.TB, store V1Store) {
|
||||
err := store.ForEachNode(
|
||||
ctx,
|
||||
func(_ *models.LightningNode) error {
|
||||
func(_ *models.Node) error {
|
||||
// Increment the counter to
|
||||
// ensure the callback is doing
|
||||
// something.
|
||||
@@ -932,10 +932,9 @@ func BenchmarkFindOptimalSQLQueryConfig(b *testing.B) {
|
||||
numChannels = 0
|
||||
)
|
||||
|
||||
//nolint:ll
|
||||
err := store.ForEachNode(
|
||||
ctx,
|
||||
func(_ *models.LightningNode) error {
|
||||
func(_ *models.Node) error {
|
||||
numNodes++
|
||||
|
||||
return nil
|
||||
|
||||
+1
-1
@@ -273,7 +273,7 @@ func (c *ChannelGraph) ForEachNodeCached(ctx context.Context, withAddrs bool,
|
||||
// already present node from a node announcement, or to insert a node found in a
|
||||
// channel update.
|
||||
func (c *ChannelGraph) AddLightningNode(ctx context.Context,
|
||||
node *models.LightningNode, op ...batch.SchedulerOption) error {
|
||||
node *models.Node, op ...batch.SchedulerOption) error {
|
||||
|
||||
err := c.V1Store.AddLightningNode(ctx, node, op...)
|
||||
if err != nil {
|
||||
|
||||
+33
-33
@@ -69,9 +69,9 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
func createLightningNode(priv *btcec.PrivateKey) *models.LightningNode {
|
||||
func createLightningNode(priv *btcec.PrivateKey) *models.Node {
|
||||
pub := priv.PubKey().SerializeCompressed()
|
||||
n := &models.LightningNode{
|
||||
n := &models.Node{
|
||||
HaveNodeAnnouncement: true,
|
||||
AuthSigBytes: testSig.Serialize(),
|
||||
LastUpdate: nextUpdateTime(),
|
||||
@@ -85,7 +85,7 @@ func createLightningNode(priv *btcec.PrivateKey) *models.LightningNode {
|
||||
return n
|
||||
}
|
||||
|
||||
func createTestVertex(t testing.TB) *models.LightningNode {
|
||||
func createTestVertex(t testing.TB) *models.Node {
|
||||
t.Helper()
|
||||
|
||||
priv, err := btcec.NewPrivateKey()
|
||||
@@ -94,7 +94,7 @@ func createTestVertex(t testing.TB) *models.LightningNode {
|
||||
return createLightningNode(priv)
|
||||
}
|
||||
|
||||
// TestNodeInsertionAndDeletion tests the CRUD operations for a LightningNode.
|
||||
// TestNodeInsertionAndDeletion tests the CRUD operations for a Node.
|
||||
func TestNodeInsertionAndDeletion(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := t.Context()
|
||||
@@ -104,9 +104,9 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
|
||||
// We'd like to test basic insertion/deletion for vertexes from the
|
||||
// graph, so we'll create a test vertex to start with.
|
||||
timeStamp := int64(1232342)
|
||||
nodeWithAddrs := func(addrs []net.Addr) *models.LightningNode {
|
||||
nodeWithAddrs := func(addrs []net.Addr) *models.Node {
|
||||
timeStamp++
|
||||
return &models.LightningNode{
|
||||
return &models.Node{
|
||||
HaveNodeAnnouncement: true,
|
||||
AuthSigBytes: testSig.Serialize(),
|
||||
LastUpdate: time.Unix(timeStamp, 0),
|
||||
@@ -271,7 +271,7 @@ func TestNodeInsertionAndDeletion(t *testing.T) {
|
||||
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.
|
||||
func TestPartialNode(t *testing.T) {
|
||||
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
|
||||
// node keys for nodes we are not yet aware
|
||||
var node1, node2 models.LightningNode
|
||||
var node1, node2 models.Node
|
||||
copy(node1.PubKeyBytes[:], pubKey1Bytes)
|
||||
copy(node2.PubKeyBytes[:], pubKey2Bytes)
|
||||
|
||||
@@ -307,7 +307,7 @@ func TestPartialNode(t *testing.T) {
|
||||
|
||||
// The two nodes should match exactly! (with default values for
|
||||
// LastUpdate and db set to satisfy compareNodes())
|
||||
expectedNode1 := &models.LightningNode{
|
||||
expectedNode1 := &models.Node{
|
||||
HaveNodeAnnouncement: false,
|
||||
LastUpdate: time.Unix(0, 0),
|
||||
PubKeyBytes: pubKey1,
|
||||
@@ -321,7 +321,7 @@ func TestPartialNode(t *testing.T) {
|
||||
|
||||
// The two nodes should match exactly! (with default values for
|
||||
// LastUpdate and db set to satisfy compareNodes())
|
||||
expectedNode2 := &models.LightningNode{
|
||||
expectedNode2 := &models.Node{
|
||||
HaveNodeAnnouncement: false,
|
||||
LastUpdate: time.Unix(0, 0),
|
||||
PubKeyBytes: pubKey2,
|
||||
@@ -484,7 +484,7 @@ func TestEdgeInsertionDeletion(t *testing.T) {
|
||||
}
|
||||
|
||||
func createEdge(height, txIndex uint32, txPosition uint16, outPointIndex uint32,
|
||||
node1, node2 *models.LightningNode) (models.ChannelEdgeInfo,
|
||||
node1, node2 *models.Node) (models.ChannelEdgeInfo,
|
||||
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,
|
||||
*models.ChannelEdgePolicy, *models.ChannelEdgePolicy) {
|
||||
|
||||
@@ -982,7 +982,7 @@ func TestEdgePolicyCRUD(t *testing.T) {
|
||||
updateAndAssertPolicies()
|
||||
}
|
||||
|
||||
func assertNodeInCache(t *testing.T, g *ChannelGraph, n *models.LightningNode,
|
||||
func assertNodeInCache(t *testing.T, g *ChannelGraph, n *models.Node,
|
||||
expectedFeatures *lnwire.FeatureVector) {
|
||||
|
||||
// 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
|
||||
// returns the expected data in the call-back.
|
||||
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)
|
||||
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
|
||||
// it is tested in another test).
|
||||
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{}{}
|
||||
|
||||
return nil
|
||||
@@ -1579,11 +1579,11 @@ func TestGraphCacheTraversal(t *testing.T) {
|
||||
}
|
||||
|
||||
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()
|
||||
|
||||
nodes := make([]*models.LightningNode, numNodes)
|
||||
nodes := make([]*models.Node, numNodes)
|
||||
nodeIndex := map[string]struct{}{}
|
||||
for i := 0; i < numNodes; i++ {
|
||||
node := createTestVertex(t)
|
||||
@@ -1600,7 +1600,7 @@ func fillTestGraph(t testing.TB, graph *ChannelGraph, numNodes,
|
||||
|
||||
// Iterate over each node as returned by the graph, if all nodes are
|
||||
// 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)
|
||||
return nil
|
||||
}, func() {})
|
||||
@@ -1710,7 +1710,7 @@ func assertNumChans(t *testing.T, graph *ChannelGraph, n int) {
|
||||
func assertNumNodes(t *testing.T, graph *ChannelGraph, n int) {
|
||||
numNodes := 0
|
||||
err := graph.ForEachNode(t.Context(),
|
||||
func(_ *models.LightningNode) error {
|
||||
func(_ *models.Node) error {
|
||||
numNodes++
|
||||
|
||||
return nil
|
||||
@@ -1784,7 +1784,7 @@ func TestGraphPruning(t *testing.T) {
|
||||
// and enough edges to create a fully connected graph. The graph will
|
||||
// be rather simple, representing a straight line.
|
||||
const numNodes = 5
|
||||
graphNodes := make([]*models.LightningNode, numNodes)
|
||||
graphNodes := make([]*models.Node, numNodes)
|
||||
for i := 0; i < numNodes; i++ {
|
||||
node := createTestVertex(t)
|
||||
|
||||
@@ -2198,7 +2198,7 @@ func TestNodeUpdatesInHorizon(t *testing.T) {
|
||||
// We'll create 10 node announcements, each with an update timestamp 10
|
||||
// seconds after the other.
|
||||
const numNodes = 10
|
||||
nodeAnns := make([]models.LightningNode, 0, numNodes)
|
||||
nodeAnns := make([]models.Node, 0, numNodes)
|
||||
for i := 0; i < numNodes; i++ {
|
||||
nodeAnn := createTestVertex(t)
|
||||
|
||||
@@ -2219,7 +2219,7 @@ func TestNodeUpdatesInHorizon(t *testing.T) {
|
||||
start time.Time
|
||||
end time.Time
|
||||
|
||||
resp []models.LightningNode
|
||||
resp []models.Node
|
||||
}{
|
||||
// If we query for a time range that's strictly below our set
|
||||
// of updates, then we'll get an empty result back.
|
||||
@@ -2857,7 +2857,7 @@ func TestFilterChannelRange(t *testing.T) {
|
||||
)
|
||||
|
||||
updateTimeSeed := time.Now().Unix()
|
||||
maybeAddPolicy := func(chanID uint64, node *models.LightningNode,
|
||||
maybeAddPolicy := func(chanID uint64, node *models.Node,
|
||||
node2 bool) time.Time {
|
||||
|
||||
var chanFlags lnwire.ChanUpdateChanFlags
|
||||
@@ -3168,7 +3168,7 @@ func TestIncompleteChannelPolicies(t *testing.T) {
|
||||
}
|
||||
|
||||
// Ensure that channel is reported with unknown policies.
|
||||
checkPolicies := func(node *models.LightningNode, expectedIn,
|
||||
checkPolicies := func(node *models.Node, expectedIn,
|
||||
expectedOut bool) {
|
||||
|
||||
calls := 0
|
||||
@@ -3585,7 +3585,7 @@ func TestNodeIsPublic(t *testing.T) {
|
||||
|
||||
// After creating all of our nodes and edges, we'll add them to each
|
||||
// participant's graph.
|
||||
nodes := []*models.LightningNode{aliceNode, bobNode, carolNode}
|
||||
nodes := []*models.Node{aliceNode, bobNode, carolNode}
|
||||
edges := []*models.ChannelEdgeInfo{&aliceBobEdge, &bobCarolEdge}
|
||||
graphs := []*ChannelGraph{aliceGraph, bobGraph, carolGraph}
|
||||
for _, graph := range graphs {
|
||||
@@ -3602,7 +3602,7 @@ func TestNodeIsPublic(t *testing.T) {
|
||||
|
||||
// checkNodes is a helper closure that will be used to assert that the
|
||||
// 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) {
|
||||
|
||||
t.Helper()
|
||||
@@ -3645,7 +3645,7 @@ func TestNodeIsPublic(t *testing.T) {
|
||||
}
|
||||
}
|
||||
checkNodes(
|
||||
[]*models.LightningNode{aliceNode},
|
||||
[]*models.Node{aliceNode},
|
||||
[]*ChannelGraph{bobGraph, carolGraph},
|
||||
false,
|
||||
)
|
||||
@@ -3676,7 +3676,7 @@ func TestNodeIsPublic(t *testing.T) {
|
||||
// With the modifications above, Bob should now be seen as a private
|
||||
// node from both Alice's and Carol's perspective.
|
||||
checkNodes(
|
||||
[]*models.LightningNode{bobNode},
|
||||
[]*models.Node{bobNode},
|
||||
[]*ChannelGraph{aliceGraph, carolGraph},
|
||||
false,
|
||||
)
|
||||
@@ -3979,8 +3979,8 @@ func TestGraphZombieIndex(t *testing.T) {
|
||||
assertNumZombies(t, graph, 1)
|
||||
}
|
||||
|
||||
// compareNodes is used to compare two LightningNodes.
|
||||
func compareNodes(t *testing.T, a, b *models.LightningNode) {
|
||||
// compareNodes is used to compare two Nodes.
|
||||
func compareNodes(t *testing.T, a, b *models.Node) {
|
||||
t.Helper()
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// TestLightningNodeSigVerification checks that we can use the LightningNode's
|
||||
// TestLightningNodeSigVerification checks that we can use the Node's
|
||||
// pubkey to verify signatures.
|
||||
func TestLightningNodeSigVerification(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -4068,7 +4068,7 @@ func TestLightningNodeSigVerification(t *testing.T) {
|
||||
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)
|
||||
|
||||
// And finally check that we can verify the same signature from the
|
||||
@@ -4442,7 +4442,7 @@ var testNodeAnn = "01012674c2e7ef68c73a086b7de2603f4ef1567358df84bb4edaa06c" +
|
||||
"80000000d0000000005cd2a001260706204c"
|
||||
|
||||
// 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
|
||||
// that the two messages are equal.
|
||||
func TestLightningNodePersistence(t *testing.T) {
|
||||
|
||||
@@ -38,7 +38,7 @@ type V1Store interface { //nolint:interfacebloat
|
||||
// update that node's 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 channel update.
|
||||
AddLightningNode(ctx context.Context, node *models.LightningNode,
|
||||
AddLightningNode(ctx context.Context, node *models.Node,
|
||||
op ...batch.SchedulerOption) error
|
||||
|
||||
// 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.
|
||||
ForEachSourceNodeChannel(ctx context.Context,
|
||||
cb func(chanPoint wire.OutPoint, havePolicy bool,
|
||||
otherNode *models.LightningNode) error,
|
||||
otherNode *models.Node) error,
|
||||
reset func()) error
|
||||
|
||||
// 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
|
||||
// the callback returns an error, then the transaction is aborted and
|
||||
// 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
|
||||
|
||||
// ForEachNodeCacheable iterates through all the stored vertices/nodes
|
||||
@@ -110,13 +110,13 @@ type V1Store interface { //nolint:interfacebloat
|
||||
// by two nodes to quickly determine if they have the same set of up to
|
||||
// date node announcements.
|
||||
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
|
||||
// public key. If the node isn't found in the database, then
|
||||
// ErrGraphNodeNotFound is returned.
|
||||
FetchLightningNode(ctx context.Context,
|
||||
nodePub route.Vertex) (*models.LightningNode, error)
|
||||
nodePub route.Vertex) (*models.Node, error)
|
||||
|
||||
// HasLightningNode determines if the graph has a vertex identified by
|
||||
// the target node identity public key. If the node exists in the
|
||||
@@ -327,13 +327,13 @@ type V1Store interface { //nolint:interfacebloat
|
||||
// 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
|
||||
// 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
|
||||
// source node is to be used as the center of a star-graph within path
|
||||
// finding algorithms.
|
||||
SetSourceNode(ctx context.Context,
|
||||
node *models.LightningNode) error
|
||||
node *models.Node) error
|
||||
|
||||
// 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"
|
||||
|
||||
+43
-43
@@ -683,7 +683,7 @@ func (c *KVStore) ForEachNodeCached(ctx context.Context, withAddrs bool,
|
||||
// node, and construct a similar callback functiopn signature as the
|
||||
// main funcotin expects.
|
||||
return forEachNode(c.db, func(tx kvdb.RTx,
|
||||
node *models.LightningNode) error {
|
||||
node *models.Node) error {
|
||||
|
||||
channels := make(map[uint64]*DirectedChannel)
|
||||
|
||||
@@ -804,10 +804,10 @@ func (c *KVStore) DisabledChannelIDs() ([]uint64, error) {
|
||||
//
|
||||
// NOTE: this is part of the V1Store interface.
|
||||
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,
|
||||
node *models.LightningNode) error {
|
||||
node *models.Node) error {
|
||||
|
||||
return cb(node)
|
||||
}, reset)
|
||||
@@ -821,7 +821,7 @@ func (c *KVStore) ForEachNode(_ context.Context,
|
||||
// TODO(roasbeef): add iterator interface to allow for memory efficient graph
|
||||
// traversal when graph gets mega.
|
||||
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 {
|
||||
// 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
|
||||
// a path finding algorithm in order to explore the reachability of another
|
||||
// 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)
|
||||
}
|
||||
|
||||
// sourceNode fetches the source node of the graph. The source node is treated
|
||||
// as the center node within a star-graph.
|
||||
func sourceNode(db kvdb.Backend) (*models.LightningNode, error) {
|
||||
var source *models.LightningNode
|
||||
func sourceNode(db kvdb.Backend) (*models.Node, error) {
|
||||
var source *models.Node
|
||||
err := kvdb.View(db, func(tx kvdb.RTx) error {
|
||||
// First grab the nodes bucket which stores the mapping from
|
||||
// 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
|
||||
// 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.
|
||||
func sourceNodeWithTx(nodes kvdb.RBucket) (*models.LightningNode, error) {
|
||||
func sourceNodeWithTx(nodes kvdb.RBucket) (*models.Node, error) {
|
||||
selfPub := nodes.Get(sourceKey)
|
||||
if selfPub == nil {
|
||||
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
|
||||
// algorithms.
|
||||
func (c *KVStore) SetSourceNode(_ context.Context,
|
||||
node *models.LightningNode) error {
|
||||
node *models.Node) error {
|
||||
|
||||
nodePubBytes := node.PubKeyBytes[:]
|
||||
|
||||
@@ -989,7 +989,7 @@ func (c *KVStore) SetSourceNode(_ context.Context,
|
||||
//
|
||||
// TODO(roasbeef): also need sig of announcement.
|
||||
func (c *KVStore) AddLightningNode(ctx context.Context,
|
||||
node *models.LightningNode, opts ...batch.SchedulerOption) error {
|
||||
node *models.Node, opts ...batch.SchedulerOption) error {
|
||||
|
||||
r := &batch.Request[kvdb.RwTx]{
|
||||
Opts: batch.NewSchedulerOptions(opts...),
|
||||
@@ -1001,7 +1001,7 @@ func (c *KVStore) AddLightningNode(ctx context.Context,
|
||||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -1204,7 +1204,7 @@ func (c *KVStore) addChannelEdge(tx kvdb.RwTx,
|
||||
_, node1Err := fetchLightningNode(nodes, edge.NodeKey1Bytes[:])
|
||||
switch {
|
||||
case errors.Is(node1Err, ErrGraphNodeNotFound):
|
||||
node1Shell := models.LightningNode{
|
||||
node1Shell := models.Node{
|
||||
PubKeyBytes: edge.NodeKey1Bytes,
|
||||
HaveNodeAnnouncement: false,
|
||||
}
|
||||
@@ -1220,7 +1220,7 @@ func (c *KVStore) addChannelEdge(tx kvdb.RwTx,
|
||||
_, node2Err := fetchLightningNode(nodes, edge.NodeKey2Bytes[:])
|
||||
switch {
|
||||
case errors.Is(node2Err, ErrGraphNodeNotFound):
|
||||
node2Shell := models.LightningNode{
|
||||
node2Shell := models.Node{
|
||||
PubKeyBytes: edge.NodeKey2Bytes,
|
||||
HaveNodeAnnouncement: false,
|
||||
}
|
||||
@@ -2032,11 +2032,11 @@ type ChannelEdge struct {
|
||||
|
||||
// Node1 is "node 1" in the channel. This is the node that would have
|
||||
// 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
|
||||
// produced Policy2 if it exists.
|
||||
Node2 *models.LightningNode
|
||||
Node2 *models.Node
|
||||
}
|
||||
|
||||
// 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
|
||||
// announcements.
|
||||
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 {
|
||||
nodes := tx.ReadBucket(nodeBucket)
|
||||
@@ -3048,7 +3048,7 @@ func (c *KVStore) isPublic(tx kvdb.RTx, nodePub route.Vertex,
|
||||
// ErrGraphNodeNotFound is returned. An optional transaction may be provided.
|
||||
// If none is provided, then a new one will be created.
|
||||
func (c *KVStore) FetchLightningNodeTx(tx kvdb.RTx, nodePub route.Vertex) (
|
||||
*models.LightningNode, error) {
|
||||
*models.Node, error) {
|
||||
|
||||
return c.fetchLightningNode(tx, nodePub)
|
||||
}
|
||||
@@ -3057,7 +3057,7 @@ func (c *KVStore) FetchLightningNodeTx(tx kvdb.RTx, nodePub route.Vertex) (
|
||||
// key. If the node isn't found in the database, then ErrGraphNodeNotFound is
|
||||
// returned.
|
||||
func (c *KVStore) FetchLightningNode(_ context.Context,
|
||||
nodePub route.Vertex) (*models.LightningNode, error) {
|
||||
nodePub route.Vertex) (*models.Node, error) {
|
||||
|
||||
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
|
||||
// a new one will be created.
|
||||
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 {
|
||||
// First grab the nodes bucket which stores the mapping from
|
||||
// pubKey to node information.
|
||||
@@ -3287,7 +3287,7 @@ func (c *KVStore) ForEachNodeChannel(_ context.Context, nodePub route.Vertex,
|
||||
// peer's node information.
|
||||
func (c *KVStore) ForEachSourceNodeChannel(_ context.Context,
|
||||
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 {
|
||||
nodes := tx.ReadBucket(nodeBucket)
|
||||
@@ -3343,13 +3343,13 @@ func (c *KVStore) forEachNodeChannelTx(tx kvdb.RTx,
|
||||
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
|
||||
// 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.
|
||||
func (c *KVStore) fetchOtherNode(tx kvdb.RTx,
|
||||
channel *models.ChannelEdgeInfo, thisNodeKey []byte) (
|
||||
*models.LightningNode, error) {
|
||||
*models.Node, error) {
|
||||
|
||||
// Ensure that the node passed in is actually a member of the channel.
|
||||
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")
|
||||
}
|
||||
|
||||
var targetNode *models.LightningNode
|
||||
var targetNode *models.Node
|
||||
fetchNodeFunc := func(tx kvdb.RTx) error {
|
||||
// First grab the nodes bucket which stores the mapping from
|
||||
// pubKey to node information.
|
||||
@@ -4019,7 +4019,7 @@ func (c *nodeTraverserSession) FetchNodeFeatures(nodePub route.Vertex) (
|
||||
}
|
||||
|
||||
func putLightningNode(nodeBucket, aliasBucket, updateIndex kvdb.RwBucket,
|
||||
node *models.LightningNode) error {
|
||||
node *models.Node) error {
|
||||
|
||||
var (
|
||||
scratch [16]byte
|
||||
@@ -4148,11 +4148,11 @@ func putLightningNode(nodeBucket, aliasBucket, updateIndex kvdb.RwBucket,
|
||||
}
|
||||
|
||||
func fetchLightningNode(nodeBucket kvdb.RBucket,
|
||||
nodePub []byte) (models.LightningNode, error) {
|
||||
nodePub []byte) (models.Node, error) {
|
||||
|
||||
nodeBytes := nodeBucket.Get(nodePub)
|
||||
if nodeBytes == nil {
|
||||
return models.LightningNode{}, ErrGraphNodeNotFound
|
||||
return models.Node{}, ErrGraphNodeNotFound
|
||||
}
|
||||
|
||||
nodeReader := bytes.NewReader(nodeBytes)
|
||||
@@ -4215,9 +4215,9 @@ func deserializeLightningNodeCacheable(r io.Reader) (route.Vertex,
|
||||
return pubKey, features, nil
|
||||
}
|
||||
|
||||
func deserializeLightningNode(r io.Reader) (models.LightningNode, error) {
|
||||
func deserializeLightningNode(r io.Reader) (models.Node, error) {
|
||||
var (
|
||||
node models.LightningNode
|
||||
node models.Node
|
||||
scratch [8]byte
|
||||
err error
|
||||
)
|
||||
@@ -4227,18 +4227,18 @@ func deserializeLightningNode(r io.Reader) (models.LightningNode, error) {
|
||||
node.Features = lnwire.EmptyFeatureVector()
|
||||
|
||||
if _, err := r.Read(scratch[:]); err != nil {
|
||||
return models.LightningNode{}, err
|
||||
return models.Node{}, err
|
||||
}
|
||||
|
||||
unix := int64(byteOrder.Uint64(scratch[:]))
|
||||
node.LastUpdate = time.Unix(unix, 0)
|
||||
|
||||
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 {
|
||||
return models.LightningNode{}, err
|
||||
return models.Node{}, err
|
||||
}
|
||||
|
||||
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
|
||||
// of the data available.
|
||||
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 {
|
||||
return models.LightningNode{}, err
|
||||
return models.Node{}, err
|
||||
}
|
||||
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)
|
||||
if err != nil {
|
||||
return models.LightningNode{}, err
|
||||
return models.Node{}, err
|
||||
}
|
||||
|
||||
err = node.Features.Decode(r)
|
||||
if err != nil {
|
||||
return models.LightningNode{}, err
|
||||
return models.Node{}, err
|
||||
}
|
||||
|
||||
if _, err := r.Read(scratch[:2]); err != nil {
|
||||
return models.LightningNode{}, err
|
||||
return models.Node{}, err
|
||||
}
|
||||
numAddresses := int(byteOrder.Uint16(scratch[:2]))
|
||||
|
||||
@@ -4285,7 +4285,7 @@ func deserializeLightningNode(r io.Reader) (models.LightningNode, error) {
|
||||
for i := 0; i < numAddresses; i++ {
|
||||
address, err := DeserializeAddr(r)
|
||||
if err != nil {
|
||||
return models.LightningNode{}, err
|
||||
return models.Node{}, err
|
||||
}
|
||||
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")
|
||||
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
|
||||
@@ -4305,7 +4305,7 @@ func deserializeLightningNode(r io.Reader) (models.LightningNode, error) {
|
||||
case errors.Is(err, io.ErrUnexpectedEOF):
|
||||
case errors.Is(err, io.EOF):
|
||||
case err != nil:
|
||||
return models.LightningNode{}, err
|
||||
return models.Node{}, err
|
||||
}
|
||||
|
||||
if len(extraBytes) > 0 {
|
||||
|
||||
@@ -11,11 +11,11 @@ import (
|
||||
"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
|
||||
// from it. As the graph is directed, a node will also have an incoming 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 [33]byte
|
||||
pubKey *btcec.PublicKey
|
||||
@@ -65,7 +65,7 @@ type LightningNode struct {
|
||||
//
|
||||
// NOTE: By having this method to access an attribute, we ensure we only need
|
||||
// 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 {
|
||||
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
|
||||
// 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)
|
||||
}
|
||||
|
||||
// AddPubKey is a setter-link method that can be used to swap out the public
|
||||
// key for a node.
|
||||
func (l *LightningNode) AddPubKey(key *btcec.PublicKey) {
|
||||
func (l *Node) AddPubKey(key *btcec.PublicKey) {
|
||||
l.pubKey = key
|
||||
copy(l.PubKeyBytes[:], key.SerializeCompressed())
|
||||
}
|
||||
|
||||
// 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) {
|
||||
|
||||
if !l.HaveNodeAnnouncement {
|
||||
@@ -132,13 +132,13 @@ func (l *LightningNode) NodeAnnouncement(signed bool) (*lnwire.NodeAnnouncement,
|
||||
return nodeAnn, nil
|
||||
}
|
||||
|
||||
// NodeFromWireAnnouncement creates a LightningNode instance from an
|
||||
// NodeFromWireAnnouncement creates a Node instance from an
|
||||
// lnwire.NodeAnnouncement message.
|
||||
func NodeFromWireAnnouncement(msg *lnwire.NodeAnnouncement) *LightningNode {
|
||||
func NodeFromWireAnnouncement(msg *lnwire.NodeAnnouncement) *Node {
|
||||
timestamp := time.Unix(int64(msg.Timestamp), 0)
|
||||
features := lnwire.NewFeatureVector(msg.Features, lnwire.Features)
|
||||
|
||||
return &LightningNode{
|
||||
return &Node{
|
||||
HaveNodeAnnouncement: true,
|
||||
LastUpdate: timestamp,
|
||||
Addresses: msg.Addresses,
|
||||
|
||||
@@ -382,7 +382,7 @@ func (c *ChannelGraph) addToTopologyChange(update *TopologyChange,
|
||||
|
||||
// Any node announcement maps directly to a NetworkNodeUpdate struct.
|
||||
// No further data munging or db queries are required.
|
||||
case *models.LightningNode:
|
||||
case *models.Node:
|
||||
pubKey, err := m.PubKey()
|
||||
if err != nil {
|
||||
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
|
||||
// then be compared against the original KVDB node object.
|
||||
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
|
||||
@@ -226,7 +226,7 @@ func migrateNodes(ctx context.Context, cfg *sqldb.QueryConfig,
|
||||
|
||||
// Clear the batch map for the next iteration.
|
||||
batch = make(
|
||||
map[int64]*models.LightningNode, cfg.MaxBatchSize,
|
||||
map[int64]*models.Node, cfg.MaxBatchSize,
|
||||
)
|
||||
|
||||
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
|
||||
// database.
|
||||
err := forEachNode(kvBackend, func(_ kvdb.RTx,
|
||||
node *models.LightningNode) error {
|
||||
node *models.Node) error {
|
||||
|
||||
pub := node.PubKeyBytes
|
||||
|
||||
@@ -307,7 +307,7 @@ func migrateNodes(ctx context.Context, cfg *sqldb.QueryConfig,
|
||||
chunk = 0
|
||||
skipped = 0
|
||||
t0 = time.Now()
|
||||
batch = make(map[int64]*models.LightningNode, cfg.MaxBatchSize)
|
||||
batch = make(map[int64]*models.Node, cfg.MaxBatchSize)
|
||||
})
|
||||
if err != nil {
|
||||
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
|
||||
// exact same node.
|
||||
func insertNodeSQLMig(ctx context.Context, db SQLQueries,
|
||||
node *models.LightningNode) (int64, error) {
|
||||
node *models.Node) (int64, error) {
|
||||
|
||||
params := sqlc.InsertNodeMigParams{
|
||||
Version: int16(ProtocolV1),
|
||||
|
||||
@@ -73,7 +73,7 @@ func TestMigrateGraphToSQL(t *testing.T) {
|
||||
|
||||
var err error
|
||||
switch obj := object.(type) {
|
||||
case *models.LightningNode:
|
||||
case *models.Node:
|
||||
err = db.AddLightningNode(ctx, obj)
|
||||
case *models.ChannelEdgeInfo:
|
||||
err = db.AddChannelEdge(ctx, obj)
|
||||
@@ -118,11 +118,11 @@ func TestMigrateGraphToSQL(t *testing.T) {
|
||||
// A node with no node announcement.
|
||||
makeTestShellNode(t),
|
||||
// A node with an announcement but no addresses.
|
||||
makeTestNode(t, func(n *models.LightningNode) {
|
||||
makeTestNode(t, func(n *models.Node) {
|
||||
n.Addresses = nil
|
||||
}),
|
||||
// A node with all types of addresses.
|
||||
makeTestNode(t, func(n *models.LightningNode) {
|
||||
makeTestNode(t, func(n *models.Node) {
|
||||
n.Addresses = []net.Addr{
|
||||
testAddr,
|
||||
testIPV4Addr,
|
||||
@@ -134,11 +134,11 @@ func TestMigrateGraphToSQL(t *testing.T) {
|
||||
}
|
||||
}),
|
||||
// No extra opaque data.
|
||||
makeTestNode(t, func(n *models.LightningNode) {
|
||||
makeTestNode(t, func(n *models.Node) {
|
||||
n.ExtraOpaqueData = nil
|
||||
}),
|
||||
// A node with no features.
|
||||
makeTestNode(t, func(n *models.LightningNode) {
|
||||
makeTestNode(t, func(n *models.Node) {
|
||||
n.Features = lnwire.EmptyFeatureVector()
|
||||
}),
|
||||
},
|
||||
@@ -149,7 +149,7 @@ func TestMigrateGraphToSQL(t *testing.T) {
|
||||
{
|
||||
name: "source node",
|
||||
write: func(t *testing.T, db *KVStore, object any) {
|
||||
node, ok := object.(*models.LightningNode)
|
||||
node, ok := object.(*models.Node)
|
||||
require.True(t, ok)
|
||||
|
||||
err := db.SetSourceNode(ctx, node)
|
||||
@@ -175,11 +175,11 @@ func TestMigrateGraphToSQL(t *testing.T) {
|
||||
|
||||
// Insert some nodes.
|
||||
// - node count += 1
|
||||
makeTestNode(t, func(n *models.LightningNode) {
|
||||
makeTestNode(t, func(n *models.Node) {
|
||||
n.PubKeyBytes = node1
|
||||
}),
|
||||
// - node count += 1
|
||||
makeTestNode(t, func(n *models.LightningNode) {
|
||||
makeTestNode(t, func(n *models.Node) {
|
||||
n.PubKeyBytes = node2
|
||||
}),
|
||||
|
||||
@@ -228,11 +228,11 @@ func TestMigrateGraphToSQL(t *testing.T) {
|
||||
|
||||
// Insert some nodes.
|
||||
// - node count += 1
|
||||
makeTestNode(t, func(n *models.LightningNode) {
|
||||
makeTestNode(t, func(n *models.Node) {
|
||||
n.PubKeyBytes = node1
|
||||
}),
|
||||
// - node count += 1
|
||||
makeTestNode(t, func(n *models.LightningNode) {
|
||||
makeTestNode(t, func(n *models.Node) {
|
||||
n.PubKeyBytes = node2
|
||||
}),
|
||||
|
||||
@@ -296,7 +296,7 @@ func TestMigrateGraphToSQL(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
switch obj := object.(type) {
|
||||
case *models.LightningNode:
|
||||
case *models.Node:
|
||||
err = db.SetSourceNode(ctx, obj)
|
||||
default:
|
||||
height, ok := obj.(uint32)
|
||||
@@ -312,7 +312,7 @@ func TestMigrateGraphToSQL(t *testing.T) {
|
||||
// The PruneGraph call requires that the source
|
||||
// node be set. So that is the first object
|
||||
// we will write.
|
||||
&models.LightningNode{
|
||||
&models.Node{
|
||||
HaveNodeAnnouncement: false,
|
||||
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
|
||||
// sorted by their public key.
|
||||
func fetchAllNodes(t *testing.T, store V1Store) []*models.LightningNode {
|
||||
nodes := make([]*models.LightningNode, 0)
|
||||
func fetchAllNodes(t *testing.T, store V1Store) []*models.Node {
|
||||
nodes := make([]*models.Node, 0)
|
||||
|
||||
err := store.ForEachNode(t.Context(),
|
||||
func(node *models.LightningNode) error {
|
||||
|
||||
// Call PubKey to ensure the objects cached pubkey is set so that
|
||||
// the objects can be compared as a whole.
|
||||
func(node *models.Node) error {
|
||||
// Call PubKey to ensure the objects cached pubkey is
|
||||
// set so that the objects can be compared as a whole.
|
||||
_, err := node.PubKey()
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -479,7 +478,7 @@ func fetchAllNodes(t *testing.T, store V1Store) []*models.LightningNode {
|
||||
require.NoError(t, err)
|
||||
|
||||
// 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[:])
|
||||
})
|
||||
|
||||
@@ -487,7 +486,7 @@ func fetchAllNodes(t *testing.T, store V1Store) []*models.LightningNode {
|
||||
}
|
||||
|
||||
// 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())
|
||||
if errors.Is(err, ErrSourceNodeNotSet) {
|
||||
return nil
|
||||
@@ -670,13 +669,13 @@ func genPubKey(t require.TestingT) route.Vertex {
|
||||
}
|
||||
|
||||
// testNodeOpt defines a functional option type that can be used to
|
||||
// modify the attributes of a models.LightningNode crated by makeTestNode.
|
||||
type testNodeOpt func(*models.LightningNode)
|
||||
// modify the attributes of a models.Node crated by makeTestNode.
|
||||
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.
|
||||
func makeTestNode(t *testing.T, opts ...testNodeOpt) *models.LightningNode {
|
||||
n := &models.LightningNode{
|
||||
func makeTestNode(t *testing.T, opts ...testNodeOpt) *models.Node {
|
||||
n := &models.Node{
|
||||
HaveNodeAnnouncement: true,
|
||||
AuthSigBytes: testSigBytes,
|
||||
LastUpdate: testTime,
|
||||
@@ -700,12 +699,12 @@ func makeTestNode(t *testing.T, opts ...testNodeOpt) *models.LightningNode {
|
||||
return n
|
||||
}
|
||||
|
||||
// makeTestShellNode creates a minimal models.LightningNode
|
||||
// makeTestShellNode creates a minimal models.Node
|
||||
// that only contains the public key and no other attributes.
|
||||
func makeTestShellNode(t *testing.T,
|
||||
opts ...testNodeOpt) *models.LightningNode {
|
||||
opts ...testNodeOpt) *models.Node {
|
||||
|
||||
n := &models.LightningNode{
|
||||
n := &models.Node{
|
||||
HaveNodeAnnouncement: false,
|
||||
PubKeyBytes: genPubKey(t),
|
||||
Features: testEmptyFeatures,
|
||||
@@ -934,7 +933,7 @@ func TestSQLMigrationEdgeCases(t *testing.T) {
|
||||
|
||||
// Make one valid node and one node with invalid TLV data.
|
||||
n1 := makeTestNode(t)
|
||||
n2 := makeTestNode(t, func(n *models.LightningNode) {
|
||||
n2 := makeTestNode(t, func(n *models.Node) {
|
||||
n.ExtraOpaqueData = invalidTLVData
|
||||
})
|
||||
|
||||
@@ -947,7 +946,7 @@ func TestSQLMigrationEdgeCases(t *testing.T) {
|
||||
runTestMigration(t, populateKV, dbState{
|
||||
// We expect only the valid node to be present in the
|
||||
// SQL db.
|
||||
nodes: []*models.LightningNode{n1},
|
||||
nodes: []*models.Node{n1},
|
||||
})
|
||||
})
|
||||
|
||||
@@ -995,7 +994,7 @@ func TestSQLMigrationEdgeCases(t *testing.T) {
|
||||
|
||||
runTestMigration(t, populateKV, dbState{
|
||||
// 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
|
||||
// be present in the SQL db.
|
||||
chans: chanSet{{
|
||||
@@ -1056,7 +1055,7 @@ func TestSQLMigrationEdgeCases(t *testing.T) {
|
||||
|
||||
runTestMigration(t, populateKV, dbState{
|
||||
// Both nodes will be present.
|
||||
nodes: []*models.LightningNode{n1, n2},
|
||||
nodes: []*models.Node{n1, n2},
|
||||
// The channel will be present, but only the
|
||||
// valid policy will be included in the SQL db.
|
||||
chans: chanSet{{
|
||||
@@ -1132,7 +1131,7 @@ func TestSQLMigrationEdgeCases(t *testing.T) {
|
||||
|
||||
runTestMigration(t, populateKV, dbState{
|
||||
// Both nodes will be present.
|
||||
nodes: []*models.LightningNode{n1, n2},
|
||||
nodes: []*models.Node{n1, n2},
|
||||
// The channel will be present, but only the
|
||||
// valid policy will be included in the SQL db.
|
||||
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.
|
||||
type dbState struct {
|
||||
nodes []*models.LightningNode
|
||||
nodes []*models.Node
|
||||
chans chanSet
|
||||
closed []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
|
||||
// more than just the ones we generated above if we have channels that
|
||||
// point to shell nodes.
|
||||
allNodes := make(map[route.Vertex]*models.LightningNode)
|
||||
allNodes := make(map[route.Vertex]*models.Node)
|
||||
var nodePubs []route.Vertex
|
||||
for _, node := range nodes {
|
||||
allNodes[node.PubKeyBytes] = node
|
||||
@@ -1333,7 +1332,7 @@ func testMigrateGraphToSQLRapidOnce(t *testing.T, rt *rapid.T,
|
||||
}
|
||||
|
||||
shellNode := makeTestShellNode(
|
||||
t, func(node *models.LightningNode) {
|
||||
t, func(node *models.Node) {
|
||||
node.PubKeyBytes = n
|
||||
},
|
||||
)
|
||||
@@ -1389,7 +1388,7 @@ func testMigrateGraphToSQLRapidOnce(t *testing.T, rt *rapid.T,
|
||||
require.NoError(t, err)
|
||||
|
||||
// Create a slice of all nodes.
|
||||
var nodesSlice []*models.LightningNode
|
||||
var nodesSlice []*models.Node
|
||||
for _, node := range allNodes {
|
||||
nodesSlice = append(nodesSlice, node)
|
||||
}
|
||||
@@ -1603,7 +1602,7 @@ func sortAddrs(addrs []net.Addr) {
|
||||
}
|
||||
|
||||
// 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.
|
||||
alias := lnwire.RandNodeAlias(t)
|
||||
|
||||
@@ -1647,7 +1646,7 @@ func genRandomNode(t *rapid.T) *models.LightningNode {
|
||||
extraOpaqueData = nil
|
||||
}
|
||||
|
||||
node := &models.LightningNode{
|
||||
node := &models.Node{
|
||||
HaveNodeAnnouncement: true,
|
||||
AuthSigBytes: sigBytes,
|
||||
LastUpdate: randTime,
|
||||
|
||||
+21
-21
@@ -248,7 +248,7 @@ func NewSQLStore(cfg *SQLStoreConfig, db BatchedSQLQueries,
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
func (s *SQLStore) AddLightningNode(ctx context.Context,
|
||||
node *models.LightningNode, opts ...batch.SchedulerOption) error {
|
||||
node *models.Node, opts ...batch.SchedulerOption) error {
|
||||
|
||||
r := &batch.Request[SQLQueries]{
|
||||
Opts: batch.NewSchedulerOptions(opts...),
|
||||
@@ -267,9 +267,9 @@ func (s *SQLStore) AddLightningNode(ctx context.Context,
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
func (s *SQLStore) FetchLightningNode(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 {
|
||||
var err error
|
||||
_, node, err = getNodeByPubKey(ctx, s.cfg.QueryCfg, db, pubKey)
|
||||
@@ -489,10 +489,10 @@ func (s *SQLStore) LookupAlias(ctx context.Context,
|
||||
// node based off the source node.
|
||||
//
|
||||
// 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) {
|
||||
|
||||
var node *models.LightningNode
|
||||
var node *models.Node
|
||||
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
||||
_, nodePub, err := s.getSourceNode(ctx, db, ProtocolV1)
|
||||
if err != nil {
|
||||
@@ -517,7 +517,7 @@ func (s *SQLStore) SourceNode(ctx context.Context) (*models.LightningNode,
|
||||
//
|
||||
// NOTE: part of the V1Store interface.
|
||||
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 {
|
||||
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.
|
||||
func (s *SQLStore) NodeUpdatesInHorizon(startTime,
|
||||
endTime time.Time) ([]models.LightningNode, error) {
|
||||
endTime time.Time) ([]models.Node, error) {
|
||||
|
||||
ctx := context.TODO()
|
||||
|
||||
var nodes []models.LightningNode
|
||||
var nodes []models.Node
|
||||
err := s.db.ExecTx(ctx, sqldb.ReadTxOpt(), func(db SQLQueries) error {
|
||||
dbNodes, err := db.GetNodesByLastUpdateRange(
|
||||
ctx, sqlc.GetNodesByLastUpdateRangeParams{
|
||||
@@ -571,7 +571,7 @@ func (s *SQLStore) NodeUpdatesInHorizon(startTime,
|
||||
|
||||
err = forEachNodeInBatch(
|
||||
ctx, s.cfg.QueryCfg, db, dbNodes,
|
||||
func(_ int64, node *models.LightningNode) error {
|
||||
func(_ int64, node *models.Node) error {
|
||||
nodes = append(nodes, *node)
|
||||
|
||||
return nil
|
||||
@@ -776,7 +776,7 @@ func (s *SQLStore) updateEdgeCache(e *models.ChannelEdgePolicy,
|
||||
// NOTE: part of the V1Store interface.
|
||||
func (s *SQLStore) ForEachSourceNodeChannel(ctx context.Context,
|
||||
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 {
|
||||
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.
|
||||
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 forEachNodePaginated(
|
||||
ctx, s.cfg.QueryCfg, db,
|
||||
ProtocolV1, func(_ context.Context, _ int64,
|
||||
node *models.LightningNode) error {
|
||||
node *models.Node) error {
|
||||
|
||||
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.
|
||||
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(
|
||||
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
|
||||
// fetched from the database and set on the node.
|
||||
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})
|
||||
if err != nil {
|
||||
@@ -3251,12 +3251,12 @@ func buildNode(ctx context.Context, cfg *sqldb.QueryConfig, db SQLQueries,
|
||||
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
|
||||
// features/addresses/extra fields, then the corresponding fields are expected
|
||||
// to be present in the batchNodeData.
|
||||
func buildNodeWithBatchData(dbNode sqlc.GraphNode,
|
||||
batchData *batchNodeData) (*models.LightningNode, error) {
|
||||
batchData *batchNodeData) (*models.Node, error) {
|
||||
|
||||
if dbNode.Version != int16(ProtocolV1) {
|
||||
return nil, fmt.Errorf("unsupported node version: %d",
|
||||
@@ -3266,7 +3266,7 @@ func buildNodeWithBatchData(dbNode sqlc.GraphNode,
|
||||
var pub [33]byte
|
||||
copy(pub[:], dbNode.PubKey)
|
||||
|
||||
node := &models.LightningNode{
|
||||
node := &models.Node{
|
||||
PubKeyBytes: pub,
|
||||
Features: lnwire.EmptyFeatureVector(),
|
||||
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.
|
||||
func forEachNodeInBatch(ctx context.Context, cfg *sqldb.QueryConfig,
|
||||
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.
|
||||
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
|
||||
// types are also updated. The node's DB ID is returned.
|
||||
func upsertNode(ctx context.Context, db SQLQueries,
|
||||
node *models.LightningNode) (int64, error) {
|
||||
node *models.Node) (int64, error) {
|
||||
|
||||
params := sqlc.UpsertNodeParams{
|
||||
Version: int16(ProtocolV1),
|
||||
@@ -5064,7 +5064,7 @@ func batchLoadChannelPolicyExtrasHelper(ctx context.Context,
|
||||
func forEachNodePaginated(ctx context.Context, cfg *sqldb.QueryConfig,
|
||||
db SQLQueries, protocol ProtocolVersion,
|
||||
processNode func(context.Context, int64,
|
||||
*models.LightningNode) error) error {
|
||||
*models.Node) error) error {
|
||||
|
||||
pageQueryFunc := func(ctx context.Context, lastID int64,
|
||||
limit int32) ([]sqlc.GraphNode, error) {
|
||||
|
||||
+5
-5
@@ -23,7 +23,7 @@ type ChannelGraphSource interface {
|
||||
// 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
|
||||
// channel, it will be ignored.
|
||||
AddNode(ctx context.Context, node *models.LightningNode,
|
||||
AddNode(ctx context.Context, node *models.Node,
|
||||
op ...batch.SchedulerOption) error
|
||||
|
||||
// AddEdge is used to add edge/channel to the topology of the router,
|
||||
@@ -87,7 +87,7 @@ type ChannelGraphSource interface {
|
||||
// public key. channeldb.ErrGraphNodeNotFound is returned if the node
|
||||
// doesn't exist within the graph.
|
||||
FetchLightningNode(context.Context,
|
||||
route.Vertex) (*models.LightningNode, error)
|
||||
route.Vertex) (*models.Node, error)
|
||||
|
||||
// MarkZombieEdge marks the channel with the given ID as a zombie edge.
|
||||
MarkZombieEdge(chanID uint64) error
|
||||
@@ -135,7 +135,7 @@ type DB interface {
|
||||
// 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
|
||||
// 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.
|
||||
// A channel is disabled when two of the associated ChanelEdgePolicies
|
||||
@@ -206,7 +206,7 @@ type DB interface {
|
||||
// update that node's 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 channel update.
|
||||
AddLightningNode(ctx context.Context, node *models.LightningNode,
|
||||
AddLightningNode(ctx context.Context, node *models.Node,
|
||||
op ...batch.SchedulerOption) error
|
||||
|
||||
// AddChannelEdge adds a new (undirected, blank) edge to the graph
|
||||
@@ -247,7 +247,7 @@ type DB interface {
|
||||
// public key. If the node isn't found in the database, then
|
||||
// ErrGraphNodeNotFound is returned.
|
||||
FetchLightningNode(ctx context.Context,
|
||||
nodePub route.Vertex) (*models.LightningNode, error)
|
||||
nodePub route.Vertex) (*models.Node, error)
|
||||
|
||||
// ForEachNodeChannel iterates through all channels of the given node,
|
||||
// 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()
|
||||
|
||||
priv, err := btcec.NewPrivateKey()
|
||||
require.NoError(t, err)
|
||||
|
||||
pub := priv.PubKey().SerializeCompressed()
|
||||
n := &models.LightningNode{
|
||||
n := &models.Node{
|
||||
HaveNodeAnnouncement: true,
|
||||
LastUpdate: time.Unix(updateTime, 0),
|
||||
Addresses: testAddrs,
|
||||
@@ -98,7 +98,7 @@ func createTestNode(t *testing.T) *models.LightningNode {
|
||||
}
|
||||
|
||||
func randEdgePolicy(chanID *lnwire.ShortChannelID,
|
||||
node *models.LightningNode) (*models.ChannelEdgePolicy, error) {
|
||||
node *models.Node) (*models.ChannelEdgePolicy, error) {
|
||||
|
||||
InboundFee := models.InboundFee{
|
||||
Base: prand.Int31() * -1,
|
||||
@@ -676,7 +676,7 @@ func TestNodeUpdateNotification(t *testing.T) {
|
||||
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) {
|
||||
|
||||
nodeKey, _ := ann.PubKey()
|
||||
|
||||
Reference in new issue
Block a user