mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-29 14:00:31 +08:00
node: Handle node announcements
To build an address book, peers communicate via gossip, sending `NodeAnnouncement` messages. These need to be handled by storing the addresses in an address book and the addresses need to be persisted to disk. Node announcement messages should also be relayed to peers like other gossip messages.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
--
|
||||
-- Address book SQL schema.
|
||||
--
|
||||
create table if not exists "nodes" (
|
||||
-- Node ID.
|
||||
"id" text primary key not null,
|
||||
-- Node features.
|
||||
"features" integer not null,
|
||||
-- Node alias.
|
||||
"alias" text default null,
|
||||
-- Node announcement timestamp.
|
||||
"timestamp" integer not null,
|
||||
-- Local time at which we last attempted to connect to this node.
|
||||
"last_attempt" integer default null,
|
||||
-- Local time at which we successfully connected to this node.
|
||||
"last_success" integer default null
|
||||
--
|
||||
) strict;
|
||||
|
||||
create table if not exists "addresses" (
|
||||
-- Node ID.
|
||||
"node" text not null references "nodes" ("id"),
|
||||
-- Address type.
|
||||
"type" text not null,
|
||||
-- Address value.
|
||||
"value" text not null,
|
||||
-- Where we got this address from.
|
||||
"source" text not null,
|
||||
-- When this address was announced.
|
||||
"timestamp" integer not null,
|
||||
-- Nb. This constraint allows more than one node to share the same address.
|
||||
-- This is useful in circumstances when a node wants to rotate its key, but
|
||||
-- remain reachable at the same address. The old entry will eventually be
|
||||
-- pruned.
|
||||
unique ("node", "type", "value")
|
||||
--
|
||||
) strict;
|
||||
Reference in New Issue
Block a user