Skip to content

Commit caf7bae

Browse files
cis-muzahidshportix
authored andcommitted
SQL refactoring and testing
1 parent 427965c commit caf7bae

27 files changed

+1000
-616
lines changed

src/bitmessagemain.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
app_dir = pathmagic.setup()
2020

2121
import depends
22+
2223
depends.check_dependencies()
2324

25+
import helper_sql
2426
import getopt
2527
import multiprocessing
2628
# Used to capture a Ctrl-C keypress so that Bitmessage can shutdown gracefully.
@@ -81,6 +83,7 @@ def signal_handler(signum, frame):
8183

8284
class Main(object):
8385
"""Main PyBitmessage class"""
86+
8487
def start(self):
8588
"""Start main application"""
8689
# pylint: disable=too-many-statements,too-many-branches,too-many-locals
@@ -261,8 +264,8 @@ def start(self):
261264
while state.shutdown == 0:
262265
time.sleep(1)
263266
if (
264-
state.testmode
265-
and time.time() - state.last_api_response >= 30
267+
state.testmode
268+
and time.time() - state.last_api_response >= 30
266269
):
267270
self.stop()
268271
elif not state.enableGUI:
@@ -385,7 +388,6 @@ def main():
385388
if __name__ == "__main__":
386389
main()
387390

388-
389391
# So far, the creation of and management of the Bitmessage protocol and this
390392
# client is a one-man operation. Bitcoin tips are quite appreciated.
391393
# 1H5XaDA6fYENLbknwZyjiYXYPQaFjjLX2u

src/class_sqlThread.py

Lines changed: 324 additions & 572 deletions
Large diffs are not rendered by default.

src/sql/init_version_1.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE inventory ADD first20bytesofencryptedmessage blob DEFAULT '';
2+
3+
UPDATE settings SET value = 2 WHERE key = 'version';

src/sql/init_version_10.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ CREATE TABLE `addressbook` (
1313
INSERT INTO addressbook SELECT label, address FROM old_addressbook;
1414

1515
DROP TABLE old_addressbook;
16+
17+
UPDATE settings SET value = 11 WHERE key = 'version';

src/sql/init_version_2.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,5 @@ CREATE TABLE `inventory` (
2727
INSERT INTO inventory SELECT hash, objecttype, streamnumber, payload, receivedtime FROM inventory_backup;
2828

2929
DROP TABLE inventory_backup;
30+
31+
UPDATE settings SET value = 3 WHERE key = 'version';

src/sql/init_version_3.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
--
44

55
ALTER TABLE inventory ADD tag blob DEFAULT '';
6+
7+
UPDATE settings SET value = 4 WHERE key = 'version';

src/sql/init_version_4.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ CREATE TABLE `pubkeys` (
1515
) ;
1616

1717
DELETE FROM inventory WHERE objecttype = 'pubkey';
18+
19+
UPDATE settings SET value = 5 WHERE key = 'version';

src/sql/init_version_5.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ CREATE TABLE `objectprocessorqueue` (
1010
`data` blob,
1111
UNIQUE(objecttype, data) ON CONFLICT REPLACE
1212
) ;
13+
14+
UPDATE settings SET value = 6 WHERE key = 'version';

src/sql/init_version_6.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ CREATE TABLE `objectprocessorqueue` (
2323
`data` blob,
2424
UNIQUE(objecttype, data) ON CONFLICT REPLACE
2525
) ;
26+
27+
UPDATE settings SET value = 7 WHERE key = 'version';

src/sql/init_version_7.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ DELETE FROM inventory WHERE objecttype = 1;
99
DELETE FROM pubkeys;
1010

1111
UPDATE sent SET status='msgqueued' WHERE status='doingmsgpow' or status='badkey';
12+
13+
UPDATE settings SET value = 8 WHERE key = 'version';

0 commit comments

Comments
 (0)