Files
simplexmq/migrations/20210602_introductions.sql
T
Evgeny Poberezkin ab89963f45 introduction protocol (#156)
* commands to support introduction

* agent messages / envelopes to support introductions

* introductions and invitations table; insert record with random unique ID

* store class methods and types for introductions

* process INTRO and ACPT commands for connection introductions

* fix tests: add MonadFail constraint, remove OK response to JOIN

* process agent messages for introductions

* ICON notification when introduction is completed

* replace multiway if with case

* correction

* support random connection IDs

* save additional connection fields, refactor create connection funcs

* refactor

* refactor

* test duplex connection with random IDs

* store methods for introductions

* test introduction

* fix parsing of CON agent message

* test introduction with random connection IDs

* broadcast with random connection and broadcast IDs

* clean up sql
2021-06-11 21:33:13 +01:00

28 lines
1.1 KiB
SQL

CREATE TABLE conn_intros (
intro_id BLOB NOT NULL PRIMARY KEY,
to_conn BLOB NOT NULL REFERENCES connections (conn_alias) ON DELETE CASCADE,
to_info BLOB, -- info about "to" connection sent to "re" connection
to_status TEXT NOT NULL DEFAULT '', -- '', INV, CON
re_conn BLOB NOT NULL REFERENCES connections (conn_alias) ON DELETE CASCADE,
re_info BLOB NOT NULL, -- info about "re" connection sent to "to" connection
re_status TEXT NOT NULL DEFAULT '', -- '', INV, CON
queue_info BLOB
) WITHOUT ROWID;
CREATE TABLE conn_invitations (
inv_id BLOB NOT NULL PRIMARY KEY,
via_conn BLOB REFERENCES connections (conn_alias) ON DELETE SET NULL,
external_intro_id BLOB NOT NULL,
conn_info BLOB, -- info about another connection
queue_info BLOB, -- NULL if it's an initial introduction
conn_id BLOB REFERENCES connections (conn_alias) -- created connection
ON DELETE CASCADE
DEFERRABLE INITIALLY DEFERRED,
status TEXT DEFAULT '' -- '', 'ACPT', 'CON'
) WITHOUT ROWID;
ALTER TABLE connections
ADD via_inv BLOB REFERENCES conn_invitations (inv_id) ON DELETE RESTRICT;
ALTER TABLE connections
ADD conn_level INTEGER DEFAULT 0;