node: Don't panic if we can't decode announcements

Bubble up the error instead.

Also, as part of the migration, delete existing announcements that won't
decode properly.
This commit is contained in:
cloudhead 2024-06-13 21:38:30 +02:00
parent 83786fbd80
commit 484cf0220c
No known key found for this signature in database
2 changed files with 5 additions and 3 deletions

View File

@ -363,15 +363,15 @@ mod parse {
let gt = row.read::<GossipType, _>("type");
let message = match gt {
GossipType::Refs => {
let ann = row.read::<RefsAnnouncement, _>("message");
let ann = row.try_read::<RefsAnnouncement, _>("message")?;
AnnouncementMessage::Refs(ann)
}
GossipType::Inventory => {
let ann = row.read::<InventoryAnnouncement, _>("message");
let ann = row.try_read::<InventoryAnnouncement, _>("message")?;
AnnouncementMessage::Inventory(ann)
}
GossipType::Node => {
let ann = row.read::<NodeAnnouncement, _>("message");
let ann = row.try_read::<NodeAnnouncement, _>("message")?;
AnnouncementMessage::Node(ann)
}
};

View File

@ -1,3 +1,5 @@
-- Add the version and user-agent columns.
alter table "nodes" add column "version" integer not null default 1;
alter table "nodes" add column "agent" text not null default "/radicle/";
-- Delete all cached announcements, since they no longer match our format.
delete from "announcements";