File size: 1,523 Bytes
ea775bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
CREATE TABLE IF NOT EXISTS nodes_static (
	hash             TEXT PRIMARY KEY,
	raw_options_json TEXT NOT NULL,
	created_at_ns    INTEGER NOT NULL
);

CREATE TABLE IF NOT EXISTS nodes_dynamic (
	hash                                TEXT PRIMARY KEY,
	failure_count                       INTEGER NOT NULL DEFAULT 0,
	circuit_open_since                  INTEGER NOT NULL DEFAULT 0,
	egress_ip                           TEXT NOT NULL DEFAULT '',
	egress_region                       TEXT NOT NULL DEFAULT '',
	egress_updated_at_ns                INTEGER NOT NULL DEFAULT 0,
	last_latency_probe_attempt_ns       INTEGER NOT NULL DEFAULT 0,
	last_authority_latency_probe_attempt_ns INTEGER NOT NULL DEFAULT 0,
	last_egress_update_attempt_ns       INTEGER NOT NULL DEFAULT 0
);

CREATE TABLE IF NOT EXISTS node_latency (
	node_hash       TEXT NOT NULL,
	domain          TEXT NOT NULL,
	ewma_ns         INTEGER NOT NULL,
	last_updated_ns INTEGER NOT NULL,
	PRIMARY KEY (node_hash, domain)
);

CREATE TABLE IF NOT EXISTS leases (
	platform_id      TEXT NOT NULL,
	account          TEXT NOT NULL,
	node_hash        TEXT NOT NULL,
	egress_ip        TEXT NOT NULL DEFAULT '',
	created_at_ns    INTEGER NOT NULL DEFAULT 0,
	expiry_ns        INTEGER NOT NULL,
	last_accessed_ns INTEGER NOT NULL,
	PRIMARY KEY (platform_id, account)
);

CREATE TABLE IF NOT EXISTS subscription_nodes (
	subscription_id TEXT NOT NULL,
	node_hash       TEXT NOT NULL,
	tags_json       TEXT NOT NULL DEFAULT '[]',
	PRIMARY KEY (subscription_id, node_hash)
);