mirror of
https://github.com/rightup/pyMC_Repeater.git
synced 2026-03-28 17:43:06 +01:00
Normalize companion_hash format in SQLite migrations to include 0x prefix
- Updated the SQLiteHandler to apply a migration that prefixes companion_hash values with '0x' for consistency with room_hash patterns. - Adjusted the main.py file to reflect the new formatting for companion_hash when generating its string representation.
This commit is contained in:
@@ -404,6 +404,25 @@ class SQLiteHandler:
|
||||
)
|
||||
logger.info(f"Migration '{migration_name}' applied successfully")
|
||||
|
||||
# Migration 6: Normalize companion_hash to 0x-prefixed hex (match room_hash pattern)
|
||||
migration_name = "companion_hash_0x_prefix"
|
||||
existing = conn.execute(
|
||||
"SELECT migration_name FROM migrations WHERE migration_name = ?",
|
||||
(migration_name,),
|
||||
).fetchone()
|
||||
|
||||
if not existing:
|
||||
for table in ("companion_contacts", "companion_channels", "companion_messages"):
|
||||
conn.execute(
|
||||
f"UPDATE {table} SET companion_hash = '0x' || companion_hash "
|
||||
"WHERE companion_hash NOT LIKE '0x%'"
|
||||
)
|
||||
conn.execute(
|
||||
"INSERT INTO migrations (migration_name, applied_at) VALUES (?, ?)",
|
||||
(migration_name, time.time()),
|
||||
)
|
||||
logger.info(f"Migration '{migration_name}' applied successfully")
|
||||
|
||||
conn.commit()
|
||||
|
||||
except Exception as e:
|
||||
|
||||
@@ -406,7 +406,7 @@ class RepeaterDaemon:
|
||||
identity = LocalIdentity(seed=identity_key_bytes)
|
||||
pubkey = identity.get_public_key()
|
||||
companion_hash = pubkey[0]
|
||||
companion_hash_str = f"{companion_hash:02x}"
|
||||
companion_hash_str = f"0x{companion_hash:02x}"
|
||||
|
||||
node_name = settings.get("node_name", name)
|
||||
tcp_port = settings.get("tcp_port", 5000)
|
||||
|
||||
Reference in New Issue
Block a user