feat(db): add channel_messages.raw_packet column for raw resend

Stores the full hex packet snapshot (header+transport_codes+path_len+payload)
captured at send time, enabling future "Resend (same packet hash)" feature
that lets repeaters deduplicate via Packet::calculatePacketHash while still
forwarding to nodes that didn't hear the original.

NULL for received and pre-migration rows (resend button stays disabled there).
PR #1 of 5; subsequent PRs wire up send-time capture, backend endpoint, echo
list merge, and UI.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
MarekWo
2026-06-09 12:15:44 +02:00
parent d16093b459
commit bed838c365
2 changed files with 7 additions and 0 deletions
+6
View File
@@ -69,6 +69,12 @@ class Database:
conn.execute("ALTER TABLE read_status ADD COLUMN is_favorite INTEGER DEFAULT 0")
logger.info("Migration: added read_status.is_favorite column")
# Add raw_packet column to channel_messages (raw resend support)
cm_columns = {r[1] for r in conn.execute("PRAGMA table_info(channel_messages)").fetchall()}
if 'raw_packet' not in cm_columns:
conn.execute("ALTER TABLE channel_messages ADD COLUMN raw_packet TEXT")
logger.info("Migration: added channel_messages.raw_packet column")
@contextmanager
def _connect(self):
"""Yield a connection with auto-commit/rollback."""
+1
View File
@@ -86,6 +86,7 @@ CREATE TABLE IF NOT EXISTS channel_messages (
snr REAL,
path_len INTEGER,
pkt_payload TEXT, -- for echo matching
raw_packet TEXT, -- full hex packet (header+codes+path_len+payload) for raw resend; NULL for received/legacy rows
raw_json TEXT, -- original JSON line
created_at TEXT NOT NULL DEFAULT (datetime('now'))
);