Skip to content

Commit 4335d9c

Browse files
authored
Merge pull request #9937 from ellemouton/graphSQL-zombie-index
[13] graph/db: SQL-ize the zombie index
2 parents 29ff13d + 2a6e668 commit 4335d9c

File tree

10 files changed

+672
-14
lines changed

10 files changed

+672
-14
lines changed

docs/release-notes/release-notes-0.20.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ circuit. The indices are only available for forwarding events saved after v0.20.
8686
* [4](https://github.com/lightningnetwork/lnd/pull/9931)
8787
* [5](https://github.com/lightningnetwork/lnd/pull/9935)
8888
* [6](https://github.com/lightningnetwork/lnd/pull/9936)
89+
* [7](https://github.com/lightningnetwork/lnd/pull/9937)
8990

9091
## RPC Updates
9192

graph/db/graph_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3811,7 +3811,7 @@ func TestGraphZombieIndex(t *testing.T) {
38113811
ctx := context.Background()
38123812

38133813
// We'll start by creating our test graph along with a test edge.
3814-
graph := MakeTestGraph(t)
3814+
graph := MakeTestGraphNew(t)
38153815

38163816
node1 := createTestVertex(t)
38173817
node2 := createTestVertex(t)

graph/db/kv_store.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,7 +2747,17 @@ func (c *KVStore) delChannelEdgeUnsafe(edges, edgeIndex, chanIndex,
27472747

27482748
nodeKey1, nodeKey2 := edgeInfo.NodeKey1Bytes, edgeInfo.NodeKey2Bytes
27492749
if strictZombie {
2750-
nodeKey1, nodeKey2 = makeZombiePubkeys(&edgeInfo, edge1, edge2)
2750+
var e1UpdateTime, e2UpdateTime *time.Time
2751+
if edge1 != nil {
2752+
e1UpdateTime = &edge1.LastUpdate
2753+
}
2754+
if edge2 != nil {
2755+
e2UpdateTime = &edge2.LastUpdate
2756+
}
2757+
2758+
nodeKey1, nodeKey2 = makeZombiePubkeys(
2759+
&edgeInfo, e1UpdateTime, e2UpdateTime,
2760+
)
27512761
}
27522762

27532763
return &edgeInfo, markEdgeZombie(
@@ -2772,7 +2782,7 @@ func (c *KVStore) delChannelEdgeUnsafe(edges, edgeIndex, chanIndex,
27722782
// marked with the correct lagging channel since we received an update from only
27732783
// one side.
27742784
func makeZombiePubkeys(info *models.ChannelEdgeInfo,
2775-
e1, e2 *models.ChannelEdgePolicy) ([33]byte, [33]byte) {
2785+
e1, e2 *time.Time) ([33]byte, [33]byte) {
27762786

27772787
switch {
27782788
// If we don't have either edge policy, we'll return both pubkeys so
@@ -2784,7 +2794,7 @@ func makeZombiePubkeys(info *models.ChannelEdgeInfo,
27842794
// older, we'll return edge1's pubkey and a blank pubkey for edge2. This
27852795
// means that only an update from edge1 will be able to resurrect the
27862796
// channel.
2787-
case e1 == nil || (e2 != nil && e1.LastUpdate.Before(e2.LastUpdate)):
2797+
case e1 == nil || (e2 != nil && e1.Before(*e2)):
27882798
return info.NodeKey1Bytes, [33]byte{}
27892799

27902800
// Otherwise, we're missing edge2 or edge2 is the older side, so we

0 commit comments

Comments
 (0)