Skip to content

Commit 359553b

Browse files
committed
refactor code
1 parent 16a1177 commit 359553b

27 files changed

+1000
-246
lines changed

src/class_sqlThread.py

Lines changed: 226 additions & 234 deletions
Large diffs are not rendered by default.

src/helper_startup.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
"""
22
Startup operations.
33
"""
4-
# pylint: disable=too-many-branches,too-many-statements
5-
64
import logging
75
import os
86
import platform
9-
import sys
107
import time
118
from distutils.version import StrictVersion
12-
139
import sys
1410
if sys.version_info[0] == 3:
1511
from . import defaults
@@ -29,6 +25,8 @@
2925
except ImportError:
3026
get_plugin = None
3127

28+
# pylint: disable=too-many-branches,too-many-statements
29+
3230

3331
logger = logging.getLogger('default')
3432

src/sql/__init__.py

Whitespace-only changes.

src/sql/init_version_1.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
--
3+
-- Alter table `inventory`
4+
--
5+
6+
ALTER TABLE inventory ADD tag blob DEFAULT '';

src/sql/init_version_10.sql

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
ALTER TABLE addressbook RENAME TO old_addressbook;
2+
3+
CREATE TABLE `addressbook` (
4+
`label` text NOT NULL,
5+
`address` text NOT NULL,
6+
UNIQUE(address) ON CONFLICT IGNORE
7+
) ;
8+
9+
10+
INSERT INTO addressbook SELECT label, address FROM old_addressbook;
11+
12+
DROP TABLE old_addressbook;

src/sql/init_version_2.sql

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
--
2+
-- Temp Table structure for table `inventory_backup`
3+
--
4+
5+
CREATE TEMP TABLE `inventory_backup` (
6+
`hash` blob NOT NULL,
7+
`objecttype` text DEFAULT NULL,
8+
`streamnumber` int NOT NULL,
9+
`receivedtime` int NOT NULL,
10+
`payload` blob DEFAULT NULL,
11+
-- `integer` integer NOT NULL,
12+
-- `tag` blob DEFAULT NULL,
13+
UNIQUE(hash) ON CONFLICT REPLACE
14+
) ;
15+
16+
--
17+
-- Dumping data for table `inventory_backup`
18+
--
19+
20+
INSERT INTO `inventory_backup` SELECT hash, objecttype, streamnumber, payload, receivedtime FROM inventory;
21+
22+
23+
--
24+
-- Drop table `inventory`
25+
--
26+
27+
DROP TABLE inventory;
28+
29+
30+
--
31+
-- Table structure for table `inventory`
32+
--
33+
34+
35+
CREATE TABLE `inventory` (
36+
`hash` blob NOT NULL,
37+
`objecttype` text DEFAULT NULL,
38+
`streamnumber` int NOT NULL,
39+
`receivedtime` int NOT NULL,
40+
`payload` blob DEFAULT NULL,
41+
UNIQUE(hash) ON CONFLICT REPLACE
42+
) ;
43+
44+
45+
--
46+
-- Dumping data for table `inventory`
47+
--
48+
49+
INSERT INTO inventory SELECT hash, objecttype, streamnumber, payload, receivedtime FROM inventory_backup;
50+
51+
--
52+
-- Drop data for table `inventory_backup`
53+
--
54+
55+
DROP TABLE inventory_backup;

src/sql/init_version_4.sql

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--
2+
-- Drop Table `pubkeys`
3+
--
4+
5+
DROP TABLE pubkeys;
6+
7+
8+
--
9+
-- Table structure for table `pubkeys`
10+
--
11+
12+
13+
CREATE TABLE `pubkeys` (
14+
`hash` blob NOT NULL,
15+
`addressversion` int DEFAULT NULL,
16+
`transmitdata` blob NOT NULL,
17+
`time` int NOT NULL,
18+
`usedpersonally` text DEFAULT NULL,
19+
UNIQUE(hash, addressversion) ON CONFLICT REPLACE
20+
) ;
21+
22+
--
23+
-- Drop from Table `pubkeys`
24+
--
25+
26+
DELETE FROM inventory WHERE objecttype = 'pubkey';

src/sql/init_version_5.sql

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--
2+
-- Drop Table `knownnodes`
3+
--
4+
5+
DROP TABLE knownnodes;
6+
7+
8+
--
9+
-- Table structure for table `objectprocessorqueue`
10+
--
11+
12+
13+
CREATE TABLE `objectprocessorqueue` (
14+
`objecttype` text DEFAULT NULL,
15+
`data` blob DEFAULT NULL,
16+
UNIQUE(objecttype, data) ON CONFLICT REPLACE
17+
) ;

src/sql/init_version_6.sql

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
-- --
2+
-- -- Drop table `inventory`
3+
-- --
4+
5+
DROP TABLE inventory;
6+
7+
8+
-- --
9+
-- -- Table structure for table `inventory`
10+
-- --
11+
12+
13+
CREATE TABLE `inventory` (
14+
`hash` blob NOT NULL,
15+
`objecttype` int DEFAULT NULL,
16+
`streamnumber` int NOT NULL,
17+
`payload` blob NOT NULL,
18+
`expirestime` integer DEFAULT NULL,
19+
`tag` blob DEFAULT NULL,
20+
UNIQUE(hash) ON CONFLICT REPLACE
21+
) ;
22+
23+
-- --
24+
-- -- Drop table `inventory`
25+
-- --
26+
27+
DROP TABLE objectprocessorqueue;
28+
29+
30+
-- --
31+
-- -- Table structure for table `objectprocessorqueue`
32+
-- --
33+
34+
35+
CREATE TABLE `objectprocessorqueue` (
36+
`objecttype` int DEFAULT NULL,
37+
`data` blob DEFAULT NULL,
38+
UNIQUE(objecttype, data) ON CONFLICT REPLACE
39+
) ;

src/sql/init_version_7.sql

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- --
2+
-- -- Drop table `inventory`
3+
-- --
4+
5+
DELETE FROM inventory WHERE objecttype = 1;
6+
7+
-- --
8+
-- -- Drop table `pubkeys`
9+
-- --
10+
11+
DELETE FROM pubkeys;
12+
13+
14+
-- --
15+
-- -- Update table `pubkeys`
16+
-- --
17+
18+
UPDATE sent SET status='msgqueued' WHERE status='doingmsgpow' or status='badkey';

src/sql/init_version_8.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- --
2+
-- -- Alter table `inbox`
3+
-- --
4+
5+
ALTER TABLE inbox ADD sighash blob DEFAULT '';

src/sql/init_version_9.sql

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
-- --
2+
-- -- Table structure for table `sent_backup`
3+
-- --
4+
5+
6+
CREATE TEMPORARY TABLE `sent_backup` (
7+
`msgid` blob DEFAULT NULL,
8+
`toaddress` text DEFAULT NULL,
9+
`toripe` blob DEFAULT NULL,
10+
`fromaddress` text DEFAULT NULL,
11+
`subject` text DEFAULT NULL,
12+
`message` text DEFAULT NULL,
13+
`ackdata` blob DEFAULT NULL,
14+
`lastactiontime` integer DEFAULT NULL,
15+
`status` text DEFAULT NULL,
16+
`retrynumber` integer DEFAULT NULL,
17+
`folder` text DEFAULT NULL,
18+
`encodingtype` int DEFAULT NULL
19+
) ;
20+
21+
22+
-- --
23+
-- -- Dumping data for table `sent_backup`
24+
-- --
25+
26+
INSERT INTO sent_backup SELECT msgid, toaddress, toripe, fromaddress, subject, message, ackdata, lastactiontime, status, 0, folder, encodingtype FROM sent;
27+
28+
29+
-- --
30+
-- -- Drope table `sent`
31+
-- --
32+
33+
DROP TABLE sent;
34+
35+
36+
-- --
37+
-- -- Table structure for table `sent_backup`
38+
-- --
39+
40+
41+
CREATE TABLE `sent` (
42+
`msgid` blob DEFAULT NULL,
43+
`toaddress` text DEFAULT NULL,
44+
`toripe` blob DEFAULT NULL,
45+
`fromaddress` text DEFAULT NULL,
46+
`subject` text DEFAULT NULL,
47+
`message` text DEFAULT NULL,
48+
`ackdata` blob DEFAULT NULL,
49+
`senttime` integer DEFAULT NULL,
50+
`lastactiontime` integer DEFAULT NULL,
51+
`sleeptill` int DEFAULT NULL,
52+
`status` text DEFAULT NULL,
53+
`retrynumber` integer DEFAULT NULL,
54+
`folder` text DEFAULT NULL,
55+
`encodingtype` int DEFAULT NULL,
56+
`ttl` int DEFAULT NULL
57+
) ;
58+
59+
60+
-- --
61+
-- -- Dumping data for table `sent`
62+
-- --
63+
64+
65+
INSERT INTO sent SELECT msgid, toaddress, toripe, fromaddress, subject, message, ackdata, lastactiontime, lastactiontime, 0, status, 0, folder, encodingtype, 216000 FROM sent_backup;
66+
67+
68+
--UPDATE pubkeys SET address= (select enaddr(?, ?, ?)", (addressVersion, 1, addressHash)) WHERE hash=?
69+
70+
-- --
71+
-- -- Drop table `sent`
72+
-- --
73+
74+
DROP TABLE sent_backup;

src/sql/init_version_9_1.sql

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
-- --
2+
-- -- Table structure for table `pubkeys_backup`
3+
-- --
4+
5+
6+
CREATE TEMPORARY TABLE `pubkeys_backup` (
7+
`address` text DEFAULT NULL,
8+
`addressversion` int DEFAULT NULL,
9+
`transmitdata` blob DEFAULT NULL,
10+
`time` int DEFAULT NULL,
11+
`usedpersonally` text DEFAULT NULL,
12+
UNIQUE(address) ON CONFLICT REPLACE
13+
) ;
14+
15+
16+
-- --
17+
-- -- Dumping data for table `pubkeys_backup`
18+
-- --
19+
20+
INSERT INTO pubkeys_backup SELECT address, addressversion, transmitdata, time, usedpersonally FROM pubkeys;
21+
22+
23+
-- --
24+
-- -- Drope table `pubkeys`
25+
-- --
26+
27+
DROP TABLE pubkeys;
28+
29+
30+
-- --
31+
-- -- Table structure for table `pubkeys`
32+
-- --
33+
34+
CREATE TABLE `pubkeys` (
35+
`address` text DEFAULT NULL,
36+
`addressversion` int DEFAULT NULL,
37+
`transmitdata` blob DEFAULT NULL,
38+
`time` int DEFAULT NULL,
39+
`usedpersonally` text DEFAULT NULL,
40+
UNIQUE(address) ON CONFLICT REPLACE
41+
) ;
42+
43+
44+
-- --
45+
-- -- Dumping data for table `pubkeys`
46+
-- --
47+
48+
INSERT INTO pubkeys SELECT address, addressversion, transmitdata, time, usedpersonally FROM pubkeys_backup;
49+
50+
51+
-- --
52+
-- -- Dropping table `pubkeys_backup`
53+
-- --
54+
55+
DROP TABLE pubkeys_backup;
56+
57+

0 commit comments

Comments
 (0)