@@ -7,31 +7,31 @@ def __patch():
77 global miners
88 if miners == None :
99 miners = load_from_db ()
10-
10+
1111def load_from_db ():
1212 """
1313 Load miners from database
1414 """
1515 columns = [ 'Username TEXT' ,
1616 'Password TEXT' ]
17-
17+
1818 bitHopper .Database .Commands .Create_Table ('Miners' , columns )
1919 results = bitHopper .Database .execute ('SELECT Username, Password FROM Miners' )
20-
20+
2121 miners = set ()
22-
22+
2323 for username , password in results :
2424 miners .add ((username , password ))
25-
25+
2626 return miners
27-
27+
2828def len_miners ():
2929 """
3030 Returns the length of the worker table
3131 """
3232 __patch ()
3333 return len (miners )
34-
34+
3535def get_miners ():
3636 """
3737 Returns a list of workers
@@ -40,16 +40,16 @@ def get_miners():
4040 miners_l = list (miners )
4141 miners_l .sort ()
4242 return miners_l
43-
43+
4444def valid (username , password ):
4545 """
4646 Check if a username, password combination is valid
4747 """
4848 __patch ()
4949 if len (miners ) == 0 :
5050 return True
51- return (username , password ) in miners
52-
51+ return (username , password ) in miners
52+
5353def add (username , password ):
5454 """
5555 Adds a miner into the database and the local cache
@@ -58,7 +58,7 @@ def add(username, password):
5858 if (username , password ) not in miners :
5959 miners .add ((username , password ))
6060 bitHopper .Database .execute ("INSERT INTO Miners VALUES ('%s','%s')" % (username , password ))
61-
61+
6262def remove (username , password ):
6363 """
6464 Removes a miner from the local cache and the database
0 commit comments