From 9d0b9f9acea6e25c834befc0f644c1cac40384a7 Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Tue, 25 Feb 2025 11:31:03 +0200 Subject: [PATCH] graph/db: move cache write for MarkEdgeZombie From the KVStore to the ChannelGraph. --- graph/db/graph.go | 21 +++++++++++++++++++++ graph/db/kv_store.go | 4 ---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/graph/db/graph.go b/graph/db/graph.go index 1d53ad3c2..5d9ea819e 100644 --- a/graph/db/graph.go +++ b/graph/db/graph.go @@ -439,3 +439,24 @@ func (c *ChannelGraph) FilterKnownChanIDs(chansInfo []ChannelUpdateInfo, return unknown, nil } + +// MarkEdgeZombie attempts to mark a channel identified by its channel ID as a +// zombie. This method is used on an ad-hoc basis, when channels need to be +// marked as zombies outside the normal pruning cycle. +func (c *ChannelGraph) MarkEdgeZombie(chanID uint64, + pubKey1, pubKey2 [33]byte) error { + + c.cacheMu.Lock() + defer c.cacheMu.Unlock() + + err := c.KVStore.MarkEdgeZombie(chanID, pubKey1, pubKey2) + if err != nil { + return err + } + + if c.graphCache != nil { + c.graphCache.RemoveChannel(pubKey1, pubKey2, chanID) + } + + return nil +} diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go index 04e0d75ae..3dd336578 100644 --- a/graph/db/kv_store.go +++ b/graph/db/kv_store.go @@ -3588,10 +3588,6 @@ func (c *KVStore) MarkEdgeZombie(chanID uint64, "bucket: %w", err) } - if c.graphCache != nil { - c.graphCache.RemoveChannel(pubKey1, pubKey2, chanID) - } - return markEdgeZombie(zombieIndex, chanID, pubKey1, pubKey2) }) if err != nil {