channeldb: remove kvdb.Backend from ChannelEdgeInfo

This commit is contained in:
Elle Mouton committed 2023-11-08 14:50:34 +02:00
1 parent 9dc1a1dfec
commit f06f08f596
2 files changed
+2 -12

No files matched your search

-7
View File
@@ -1939,7 +1939,6 @@ func (c *ChannelGraph) ChanUpdatesInHorizon(startTime,
return fmt.Errorf("unable to fetch info for "+ return fmt.Errorf("unable to fetch info for "+
"edge with chan_id=%v: %v", chanID, err) "edge with chan_id=%v: %v", chanID, err)
} }
edgeInfo.db = c.db
// With the static information obtained, we'll now // With the static information obtained, we'll now
// fetch the dynamic policy info. // fetch the dynamic policy info.
@@ -2270,7 +2269,6 @@ func (c *ChannelGraph) FetchChanInfos(chanIDs []uint64) ([]ChannelEdge, error) {
case err != nil: case err != nil:
return err return err
} }
edgeInfo.db = c.db
// With the static information obtained, we'll now // With the static information obtained, we'll now
// fetch the dynamic policy info. // fetch the dynamic policy info.
@@ -2961,7 +2959,6 @@ func nodeTraversal(tx kvdb.RTx, nodePub []byte, db kvdb.Backend,
if err != nil { if err != nil {
return err return err
} }
edgeInfo.db = db
outgoingPolicy, err := fetchChanEdgePolicy( outgoingPolicy, err := fetchChanEdgePolicy(
edges, chanID, nodePub, nodes, edges, chanID, nodePub, nodes,
@@ -3082,8 +3079,6 @@ type ChannelEdgeInfo struct {
// and ensure we're able to make upgrades to the network in a forwards // and ensure we're able to make upgrades to the network in a forwards
// compatible manner. // compatible manner.
ExtraOpaqueData []byte ExtraOpaqueData []byte
db kvdb.Backend
} }
// AddNodeKeys is a setter-like method that can be used to replace the set of // AddNodeKeys is a setter-like method that can be used to replace the set of
@@ -3560,7 +3555,6 @@ func (c *ChannelGraph) FetchChannelEdgesByOutpoint(op *wire.OutPoint,
return err return err
} }
edgeInfo = &edge edgeInfo = &edge
edgeInfo.db = c.db
// Once we have the information about the channels' parameters, // Once we have the information about the channels' parameters,
// we'll fetch the routing policies for each for the directed // we'll fetch the routing policies for each for the directed
@@ -3666,7 +3660,6 @@ func (c *ChannelGraph) FetchChannelEdgesByID(chanID uint64,
} }
edgeInfo = &edge edgeInfo = &edge
edgeInfo.db = c.db
// Then we'll attempt to fetch the accompanying policies of this // Then we'll attempt to fetch the accompanying policies of this
// edge. // edge.
+2 -5
View File
@@ -2706,16 +2706,14 @@ func TestNodeIsPublic(t *testing.T) {
// participant's graph. // participant's graph.
nodes := []*LightningNode{aliceNode, bobNode, carolNode} nodes := []*LightningNode{aliceNode, bobNode, carolNode}
edges := []*ChannelEdgeInfo{&aliceBobEdge, &bobCarolEdge} edges := []*ChannelEdgeInfo{&aliceBobEdge, &bobCarolEdge}
dbs := []kvdb.Backend{aliceGraph.db, bobGraph.db, carolGraph.db}
graphs := []*ChannelGraph{aliceGraph, bobGraph, carolGraph} graphs := []*ChannelGraph{aliceGraph, bobGraph, carolGraph}
for i, graph := range graphs { for _, graph := range graphs {
for _, node := range nodes { for _, node := range nodes {
if err := graph.AddLightningNode(node); err != nil { if err := graph.AddLightningNode(node); err != nil {
t.Fatalf("unable to add node: %v", err) t.Fatalf("unable to add node: %v", err)
} }
} }
for _, edge := range edges { for _, edge := range edges {
edge.db = dbs[i]
if err := graph.AddChannelEdge(edge); err != nil { if err := graph.AddChannelEdge(edge); err != nil {
t.Fatalf("unable to add edge: %v", err) t.Fatalf("unable to add edge: %v", err)
} }
@@ -2775,7 +2773,7 @@ func TestNodeIsPublic(t *testing.T) {
// that allows it to be advertised. Within Alice's graph, we'll // that allows it to be advertised. Within Alice's graph, we'll
// completely remove the edge as it is not possible for her to know of // completely remove the edge as it is not possible for her to know of
// it without it being advertised. // it without it being advertised.
for i, graph := range graphs { for _, graph := range graphs {
err := graph.DeleteChannelEdges( err := graph.DeleteChannelEdges(
false, true, bobCarolEdge.ChannelID, false, true, bobCarolEdge.ChannelID,
) )
@@ -2788,7 +2786,6 @@ func TestNodeIsPublic(t *testing.T) {
} }
bobCarolEdge.AuthProof = nil bobCarolEdge.AuthProof = nil
bobCarolEdge.db = dbs[i]
if err := graph.AddChannelEdge(&bobCarolEdge); err != nil { if err := graph.AddChannelEdge(&bobCarolEdge); err != nil {
t.Fatalf("unable to add edge: %v", err) t.Fatalf("unable to add edge: %v", err)
} }