@@ -106,8 +106,8 @@ CREATE INDEX "addresses_accounts" ON "addresses" (
106
106
///
107
107
/// All but the last `GAP_LIMIT` addresses are defined to be "reserved" addresses. Since the next
108
108
/// index to reserve is determined by dead reckoning from the last stored address, we use dummy
109
- /// entries after the maximum valid index in order to allow the last `GAP_LIMIT` addresses at the
110
- /// end of the index range to be used.
109
+ /// entries having `NULL` for the value of the `address` column after the maximum valid index in
110
+ /// order to allow the last `GAP_LIMIT` addresses at the end of the index range to be used.
111
111
///
112
112
/// Note that the fact that `used_in_tx` references a specific transaction is just a debugging aid.
113
113
/// The same is mostly true of `seen_in_tx`, but we also take into account whether the referenced
@@ -116,13 +116,15 @@ pub(super) const TABLE_EPHEMERAL_ADDRESSES: &str = r#"
116
116
CREATE TABLE ephemeral_addresses (
117
117
account_id INTEGER NOT NULL,
118
118
address_index INTEGER NOT NULL,
119
+ -- nullability of this column is controlled by the index_range_and_address_nullity check
119
120
address TEXT,
120
121
used_in_tx INTEGER,
121
122
seen_in_tx INTEGER,
122
123
FOREIGN KEY (account_id) REFERENCES accounts(id),
123
124
FOREIGN KEY (used_in_tx) REFERENCES transactions(id_tx),
124
125
FOREIGN KEY (seen_in_tx) REFERENCES transactions(id_tx),
125
126
PRIMARY KEY (account_id, address_index),
127
+ CONSTRAINT ephemeral_addr_uniq UNIQUE (address),
126
128
CONSTRAINT used_implies_seen CHECK (
127
129
used_in_tx IS NULL OR seen_in_tx IS NOT NULL
128
130
),
@@ -135,10 +137,6 @@ CREATE TABLE ephemeral_addresses (
135
137
// libsqlite3-sys requires at least version 3.14.0.
136
138
// "WITHOUT ROWID" tells SQLite to use a clustered index on the (composite) primary key.
137
139
const_assert_eq ! ( GAP_LIMIT , 20 ) ;
138
- pub ( super ) const INDEX_EPHEMERAL_ADDRESSES_ADDRESS : & str = r#"
139
- CREATE INDEX ephemeral_addresses_address ON ephemeral_addresses (
140
- address ASC
141
- )"# ;
142
140
143
141
/// Stores information about every block that the wallet has scanned.
144
142
///
0 commit comments