mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-20 11:06:54 +01:00
channeldb+routing: extend edge lookup methods with zombie index check
In this commit, we extend the graph's FetchChannelEdgesByID and HasChannelEdge methods to also check the zombie index whenever the edge to be looked up doesn't exist within the edge index. We do this to signal to callers that the edge is known, but only as a zombie, and the only information that we have about the edge are the node public keys of the two parties involved in the edge. In the event that an edge does exist within the zombie index, we make an additional check on edge policies to ensure they are not within the router's pruning window, indicating that it is a fresh update.
This commit is contained in:
@@ -526,29 +526,38 @@ func TestDisconnectBlockAtHeight(t *testing.T) {
|
||||
}
|
||||
|
||||
// The two first edges should be removed from the db.
|
||||
_, _, has, err := graph.HasChannelEdge(edgeInfo.ChannelID)
|
||||
_, _, has, isZombie, err := graph.HasChannelEdge(edgeInfo.ChannelID)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to query for edge: %v", err)
|
||||
}
|
||||
if has {
|
||||
t.Fatalf("edge1 was not pruned from the graph")
|
||||
}
|
||||
_, _, has, err = graph.HasChannelEdge(edgeInfo2.ChannelID)
|
||||
if isZombie {
|
||||
t.Fatal("reorged edge1 should not be marked as zombie")
|
||||
}
|
||||
_, _, has, isZombie, err = graph.HasChannelEdge(edgeInfo2.ChannelID)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to query for edge: %v", err)
|
||||
}
|
||||
if has {
|
||||
t.Fatalf("edge2 was not pruned from the graph")
|
||||
}
|
||||
if isZombie {
|
||||
t.Fatal("reorged edge2 should not be marked as zombie")
|
||||
}
|
||||
|
||||
// Edge 3 should not be removed.
|
||||
_, _, has, err = graph.HasChannelEdge(edgeInfo3.ChannelID)
|
||||
_, _, has, isZombie, err = graph.HasChannelEdge(edgeInfo3.ChannelID)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to query for edge: %v", err)
|
||||
}
|
||||
if !has {
|
||||
t.Fatalf("edge3 was pruned from the graph")
|
||||
}
|
||||
if isZombie {
|
||||
t.Fatal("edge3 was marked as zombie")
|
||||
}
|
||||
|
||||
// PruneTip should be set to the blockHash we specified for the block
|
||||
// at height 155.
|
||||
@@ -759,12 +768,16 @@ func TestEdgeInfoUpdates(t *testing.T) {
|
||||
|
||||
// Check for existence of the edge within the database, it should be
|
||||
// found.
|
||||
_, _, found, err := graph.HasChannelEdge(chanID)
|
||||
_, _, found, isZombie, err := graph.HasChannelEdge(chanID)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to query for edge: %v", err)
|
||||
} else if !found {
|
||||
}
|
||||
if !found {
|
||||
t.Fatalf("graph should have of inserted edge")
|
||||
}
|
||||
if isZombie {
|
||||
t.Fatal("live edge should not be marked as zombie")
|
||||
}
|
||||
|
||||
// We should also be able to retrieve the channelID only knowing the
|
||||
// channel point of the channel.
|
||||
|
||||
Reference in New Issue
Block a user