sqldb/sqlc: add zombie index table

Note that this table will only contain entries for channels that we have
deleted from the `channels` table which is why we cannot use foreign
keys. Similarly, we may no longer have node entries for the nodes in the
table.
This commit is contained in:
Elle Mouton
2025-06-11 16:59:40 +02:00
parent cee872ad0e
commit c648c7a22d
3 changed files with 38 additions and 1 deletions

View File

@@ -26,3 +26,5 @@ DROP TABLE IF EXISTS node_addresses;
DROP TABLE IF EXISTS node_features; DROP TABLE IF EXISTS node_features;
DROP TABLE IF EXISTS node_extra_types; DROP TABLE IF EXISTS node_extra_types;
DROP TABLE IF EXISTS nodes; DROP TABLE IF EXISTS nodes;
DROP TABLE IF EXISTS channel_policy_extra_types;
DROP TABLE IF EXISTS zombie_channels;

View File

@@ -292,3 +292,31 @@ CREATE TABLE IF NOT EXISTS channel_policy_extra_types (
CREATE UNIQUE INDEX IF NOT EXISTS channel_policy_extra_types_unique ON channel_policy_extra_types ( CREATE UNIQUE INDEX IF NOT EXISTS channel_policy_extra_types_unique ON channel_policy_extra_types (
type, channel_policy_id type, channel_policy_id
); );
/* ─────────────────────────────────────────────
Other graph related tables
─────────────────────────────────────────────
*/
CREATE TABLE IF NOT EXISTS zombie_channels (
-- The channel id (short channel id) of the channel.
-- NOTE: we don't use a foreign key here to the `channels`
-- table since we may delete the channel record once it
-- is marked as a zombie.
scid BLOB NOT NULL,
-- The protocol version that this node was gossiped on.
version SMALLINT NOT NULL,
-- The public key of the node 1 node of the channel. If
-- this is not null, it means an update from this node
-- will be able to resurrect the channel.
node_key_1 BLOB,
-- The public key of the node 2 node of the channel. If
-- this is not null, it means an update from this node
-- will be able to resurrect the channel.
node_key_2 BLOB
);
CREATE UNIQUE INDEX IF NOT EXISTS zombie_channels_channel_id_version_idx
ON zombie_channels(scid, version);

View File

@@ -184,3 +184,10 @@ type NodeFeature struct {
type SourceNode struct { type SourceNode struct {
NodeID int64 NodeID int64
} }
type ZombieChannel struct {
Scid []byte
Version int16
NodeKey1 []byte
NodeKey2 []byte
}