Extended batching, first draft

This commit is contained in:
kexkey
2020-06-19 17:47:56 -04:00
parent 2cf70ee746
commit 3efdd200d4
16 changed files with 1430 additions and 114 deletions

View File

@@ -64,9 +64,24 @@ CREATE TABLE recipient (
address TEXT,
amount REAL,
tx_id INTEGER REFERENCES tx,
inserted_ts INTEGER DEFAULT CURRENT_TIMESTAMP
inserted_ts INTEGER DEFAULT CURRENT_TIMESTAMP,
webhook_url TEXT,
calledback INTEGER DEFAULT FALSE,
calledback_ts INTEGER,
batch_id INTEGER REFERENCES batch,
label TEXT,
);
CREATE INDEX idx_recipient_address ON recipient (address);
CREATE INDEX idx_recipient_label ON recipient (label);
CREATE TABLE batch (
id INTEGER PRIMARY KEY AUTOINCREMENT,
label TEXT UNIQUE,
conf_target INTEGER,
feerate REAL,
inserted_ts INTEGER DEFAULT CURRENT_TIMESTAMP
);
INSERT INTO batch (id, label, conf_target, feerate) VALUES (1, "default", 6, NULL);
CREATE TABLE watching_by_txid (
id INTEGER PRIMARY KEY AUTOINCREMENT,

0
proxy_docker/app/data/sqlmigrate20181213_0-0.1.sh Normal file → Executable file
View File

0
proxy_docker/app/data/sqlmigrate20190104_0.1-0.2.sh Normal file → Executable file
View File

0
proxy_docker/app/data/sqlmigrate20190130_0.1-0.2.sh Normal file → Executable file
View File

View File

View File

@@ -0,0 +1,14 @@
#!/bin/sh
echo "Checking for extended batching support in DB..."
count=$(sqlite3 $DB_FILE "select count(*) from pragma_table_info('recipient') where name='batch_id'")
if [ "${count}" -eq "0" ]; then
# batch_id not there, we have to migrate
echo "Migrating database for extended batching support..."
echo "Backing up current DB..."
cp $DB_FILE $DB_FILE-sqlmigrate20200610_0.4.0-0.5.0
echo "Altering DB..."
cat sqlmigrate20200610_0.4.0-0.5.0.sql | sqlite3 $DB_FILE
else
echo "Database extended batching support migration already done, skipping!"
fi

View File

@@ -0,0 +1,16 @@
CREATE TABLE batch (
id INTEGER PRIMARY KEY AUTOINCREMENT,
label TEXT UNIQUE,
conf_target INTEGER,
feerate REAL,
inserted_ts INTEGER DEFAULT CURRENT_TIMESTAMP
);
INSERT INTO batch (id, label, conf_target, feerate) VALUES (1, "default", 6, NULL);
ALTER TABLE recipient ADD COLUMN webhook_url TEXT;
ALTER TABLE recipient ADD COLUMN batch_id INTEGER REFERENCES batch;
ALTER TABLE recipient ADD COLUMN label INTEGER REFERENCES batch;
ALTER TABLE recipient ADD COLUMN calledback INTEGER DEFAULT FALSE;
ALTER TABLE recipient ADD COLUMN calledback_ts INTEGER;
CREATE INDEX idx_recipient_label ON recipient (label);