Skip to content

Commit ea2fb83

Browse files
committed
sqlc: add table+queries for sessions
1 parent baec262 commit ea2fb83

File tree

6 files changed

+173
-0
lines changed

6 files changed

+173
-0
lines changed

aperturedb/sqlc/lnc_sessions.sql.go

Lines changed: 99 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
DROP INDEX IF EXISTS lnc_sessions_passphrase_entropy_idx;
2+
DROP INDEX IF EXISTS lnc_sessions_label_idx;
3+
DROP TABLE IF EXISTS lnc_sessions;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
-- lnc_sessions is table used to store data about LNC sesssions.
2+
CREATE TABLE IF NOT EXISTS lnc_sessions (
3+
id INTEGER PRIMARY KEY,
4+
5+
-- The passphrase words used to derive the passphrase entropy.
6+
passphrase_words TEXT NOT NULL UNIQUE,
7+
8+
-- The entropy bytes to be used for mask the local ephemeral key during the
9+
-- first step of the Noise XX handshake.
10+
passphrase_entropy BLOB NOT NULL UNIQUE,
11+
12+
-- The remote static key being used for the connection.
13+
remote_static_pub_key BLOB UNIQUE,
14+
15+
-- The local static key being used for the connection.
16+
local_static_priv_key BLOB NOT NULL,
17+
18+
-- mailbox_addr is the address of the mailbox used for the session.
19+
mailbox_addr TEXT NOT NULL,
20+
21+
-- created_at is the time the session was created.
22+
created_at TIMESTAMP NOT NULL,
23+
24+
-- expiry is the time the session will expire.
25+
expiry TIMESTAMP,
26+
27+
-- dev_server signals if we need to skip the verification of the server's
28+
-- tls certificate.
29+
dev_server BOOL NOT NULL
30+
);
31+
32+
CREATE INDEX IF NOT EXISTS lnc_sessions_passphrase_entropy_idx ON lnc_sessions(passphrase_entropy);

aperturedb/sqlc/models.go

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

aperturedb/sqlc/querier.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
-- name: InsertSession :exec
2+
INSERT INTO lnc_sessions (
3+
passphrase_words, passphrase_entropy, local_static_priv_key, mailbox_addr,
4+
created_at, expiry, dev_server
5+
) VALUES (
6+
$1, $2, $3, $4, $5, $6, $7
7+
);
8+
9+
-- name: GetSession :one
10+
SELECT *
11+
FROM lnc_sessions
12+
WHERE passphrase_entropy = $1;
13+
14+
-- name: SetRemotePubKey :exec
15+
UPDATE lnc_sessions
16+
SET remote_static_pub_key=$1
17+
WHERE passphrase_entropy=$2;
18+
19+
-- name: SetExpiry :exec
20+
UPDATE lnc_sessions
21+
SET expiry=$1
22+
WHERE passphrase_entropy=$2;

0 commit comments

Comments
 (0)