From f51adaf31fdc6473fbcd91a41e7f05b997e98fc3 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Tue, 5 Aug 2025 13:51:13 +0200 Subject: [PATCH] graph/db: refactor makeZombiePubkeys Let the helper method only take the params it needs so that we dont need to construct an entire models.ChannelEdgeInfo object to pass to it. This will be useful later on. --- graph/db/kv_store.go | 13 +++++++------ graph/db/sql_store.go | 3 ++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go index 49191d7c2..1abe34ba4 100644 --- a/graph/db/kv_store.go +++ b/graph/db/kv_store.go @@ -2789,7 +2789,8 @@ func (c *KVStore) delChannelEdgeUnsafe(edges, edgeIndex, chanIndex, } nodeKey1, nodeKey2 = makeZombiePubkeys( - &edgeInfo, e1UpdateTime, e2UpdateTime, + edgeInfo.NodeKey1Bytes, edgeInfo.NodeKey2Bytes, + e1UpdateTime, e2UpdateTime, ) } @@ -2814,27 +2815,27 @@ func (c *KVStore) delChannelEdgeUnsafe(edges, edgeIndex, chanIndex, // the channel. If the channel were to be marked zombie again, it would be // marked with the correct lagging channel since we received an update from only // one side. -func makeZombiePubkeys(info *models.ChannelEdgeInfo, - e1, e2 *time.Time) ([33]byte, [33]byte) { +func makeZombiePubkeys(node1, node2 [33]byte, e1, e2 *time.Time) ([33]byte, + [33]byte) { switch { // If we don't have either edge policy, we'll return both pubkeys so // that the channel can be resurrected by either party. case e1 == nil && e2 == nil: - return info.NodeKey1Bytes, info.NodeKey2Bytes + return node1, node2 // If we're missing edge1, or if both edges are present but edge1 is // older, we'll return edge1's pubkey and a blank pubkey for edge2. This // means that only an update from edge1 will be able to resurrect the // channel. case e1 == nil || (e2 != nil && e1.Before(*e2)): - return info.NodeKey1Bytes, [33]byte{} + return node1, [33]byte{} // Otherwise, we're missing edge2 or edge2 is the older side, so we // return a blank pubkey for edge1. In this case, only an update from // edge2 can resurect the channel. default: - return [33]byte{}, info.NodeKey2Bytes + return [33]byte{}, node1 } } diff --git a/graph/db/sql_store.go b/graph/db/sql_store.go index 7a7987855..c991c3b30 100644 --- a/graph/db/sql_store.go +++ b/graph/db/sql_store.go @@ -1680,7 +1680,8 @@ func (s *SQLStore) DeleteChannelEdges(strictZombiePruning, markZombie bool, } nodeKey1, nodeKey2 = makeZombiePubkeys( - info, e1UpdateTime, e2UpdateTime, + info.NodeKey1Bytes, info.NodeKey2Bytes, + e1UpdateTime, e2UpdateTime, ) }