Merge pull request #2 from ahmedbodi/master

Cleanup
This commit is contained in:
ahmedbodi 2014-02-27 11:46:45 +00:00
commit 094f8d464d
3 changed files with 50 additions and 64 deletions

View File

@ -9,14 +9,14 @@ You NEED to set the parameters in BASIC SETTINGS
# ******************** BASIC SETTINGS *************** # ******************** BASIC SETTINGS ***************
# These are the MUST BE SET parameters! # These are the MUST BE SET parameters!
CENTRAL_WALLET = 'set_valid_addresss_in_config!' # local coin address where money goes CENTRAL_WALLET = 'set_valid_addresss_in_config!' # Local coin address where money goes
COINDAEMON_TRUSTED_HOST = 'localhost' COINDAEMON_TRUSTED_HOST = 'localhost'
COINDAEMON_TRUSTED_PORT = 8332 COINDAEMON_TRUSTED_PORT = 8332
COINDAEMON_TRUSTED_USER = 'user' COINDAEMON_TRUSTED_USER = 'user'
COINDAEMON_TRUSTED_PASSWORD = 'somepassword' COINDAEMON_TRUSTED_PASSWORD = 'somepassword'
# Coin Algorithm is the option used to determine the algortithm used by stratum # Coin algorithm is the option used to determine the algorithm used by stratum
# This currently works with POW and POS coins # This currently works with POW and POS coins
# The available options are: # The available options are:
# scrypt, sha256d, scrypt-jane, skeinhash, and quark # scrypt, sha256d, scrypt-jane, skeinhash, and quark
@ -24,6 +24,7 @@ COINDAEMON_TRUSTED_PASSWORD = 'somepassword'
# For Coins which support TX Messages please enter yes in the TX selection # For Coins which support TX Messages please enter yes in the TX selection
COINDAEMON_ALGO = 'scrypt' COINDAEMON_ALGO = 'scrypt'
COINDAEMON_TX = 'no' COINDAEMON_TX = 'no'
# ******************** BASIC SETTINGS *************** # ******************** BASIC SETTINGS ***************
# Backup Coin Daemon address's (consider having at least 1 backup) # Backup Coin Daemon address's (consider having at least 1 backup)
# You can have up to 99 # You can have up to 99
@ -54,7 +55,7 @@ LOGFILE = None # eg. 'stratum.log'
LOGLEVEL = 'DEBUG' LOGLEVEL = 'DEBUG'
# Logging Rotation can be enabled with the following settings # Logging Rotation can be enabled with the following settings
# It if not enabled here, you can set up logrotate to rotate the files. # It if not enabled here, you can set up logrotate to rotate the files.
# For built in log rotation set LOG_ROTATION = True and configrue the variables # For built in log rotation set LOG_ROTATION = True and configure the variables
LOG_ROTATION = True LOG_ROTATION = True
LOG_SIZE = 10485760 # Rotate every 10M LOG_SIZE = 10485760 # Rotate every 10M
LOG_RETENTION = 10 # Keep 10 Logs LOG_RETENTION = 10 # Keep 10 Logs
@ -65,7 +66,6 @@ LOG_RETENTION = 10 # Keep 10 Logs
THREAD_POOL_SIZE = 300 THREAD_POOL_SIZE = 300
# ******************** TRANSPORTS ********************* # ******************** TRANSPORTS *********************
# Hostname or external IP to expose # Hostname or external IP to expose
HOSTNAME = 'localhost' HOSTNAME = 'localhost'
@ -87,9 +87,8 @@ LISTEN_WSS_TRANSPORT = None
PASSWORD_SALT = 'some_crazy_string' PASSWORD_SALT = 'some_crazy_string'
# ******************** Database ********************* # ******************** Database *********************
DATABASE_DRIVER = 'mysql' # Options: none, sqlite, postgresql or mysql
DATABASE_DRIVER = 'mysql' # Options: none, sqlite, postgresql or mysql DATABASE_EXTEND = False # SQLite and PGSQL Only!
DATABASE_EXTEND = False # SQLite and PGSQL Only!
# SQLite # SQLite
DB_SQLITE_FILE = 'pooldb.sqlite' DB_SQLITE_FILE = 'pooldb.sqlite'
@ -104,7 +103,7 @@ DB_MYSQL_HOST = 'localhost'
DB_MYSQL_DBNAME = 'pooldb' DB_MYSQL_DBNAME = 'pooldb'
DB_MYSQL_USER = 'pooldb' DB_MYSQL_USER = 'pooldb'
DB_MYSQL_PASS = '**empty**' DB_MYSQL_PASS = '**empty**'
DB_MYSQL_PORT = 3306 # Default port for MySQL DB_MYSQL_PORT = 3306 # Default port for MySQL
# ******************** Adv. DB Settings ********************* # ******************** Adv. DB Settings *********************
# Don't change these unless you know what you are doing # Don't change these unless you know what you are doing
@ -120,7 +119,7 @@ DB_USERCACHE_TIME = 600 # How long the usercache is good for before we r
# ******************** Pool Settings ********************* # ******************** Pool Settings *********************
# User Auth Options # User Auth Options
USERS_AUTOADD = False # Automatically add users to db when they connect. USERS_AUTOADD = False # Automatically add users to database when they connect.
# This basically disables User Auth for the pool. # This basically disables User Auth for the pool.
USERS_CHECK_PASSWORD = False # Check the workers password? (Many pools don't) USERS_CHECK_PASSWORD = False # Check the workers password? (Many pools don't)
@ -129,70 +128,69 @@ COINBASE_EXTRAS = '/stratumPool/' # Extra Descriptive String to incorp
ALLOW_NONLOCAL_WALLET = False # Allow valid, but NON-Local wallet's ALLOW_NONLOCAL_WALLET = False # Allow valid, but NON-Local wallet's
# Coin Daemon communication polling settings (In Seconds) # Coin Daemon communication polling settings (In Seconds)
PREVHASH_REFRESH_INTERVAL = 5 # How often to check for new Blocks PREVHASH_REFRESH_INTERVAL = 5 # How often to check for new Blocks
# If using the blocknotify script (recommended) set = to MERKLE_REFRESH_INTERVAL # If using the blocknotify script (recommended) set = to MERKLE_REFRESH_INTERVAL
# (No reason to poll if we're getting pushed notifications) # (No reason to poll if we're getting pushed notifications)
MERKLE_REFRESH_INTERVAL = 60 # How often check memorypool MERKLE_REFRESH_INTERVAL = 60 # How often check memorypool
# This effectively resets the template and incorporates new transactions. # This effectively resets the template and incorporates new transactions.
# This should be "slow" # This should be "slow"
INSTANCE_ID = 31 # Used for extranonce and needs to be 0-31 INSTANCE_ID = 31 # Used for extranonce and needs to be 0-31
# ******************** Pool Difficulty Settings ********************* # ******************** Pool Difficulty Settings *********************
VDIFF_X2_TYPE = True # powers of 2 e.g. 2,4,8,16,32,64,128,256,512,1024 VDIFF_X2_TYPE = True # Powers of 2 e.g. 2,4,8,16,32,64,128,256,512,1024
VDIFF_FLOAT = False # Use float difficulty VDIFF_FLOAT = False # Use float difficulty
# Pool Target (Base Difficulty) # Pool Target (Base Difficulty)
POOL_TARGET = 32 # Pool-wide difficulty target int >= 1 POOL_TARGET = 32 # Pool-wide difficulty target int >= 1
# Variable Difficulty Enable # Variable Difficulty Enable
VARIABLE_DIFF = True # Master variable difficulty enable VARIABLE_DIFF = True # Master variable difficulty enable
# Variable diff tuning variables # Variable diff tuning variables
#VARDIFF will start at the POOL_TARGET. It can go as low as the VDIFF_MIN and as high as min(VDIFF_MAX or Liteconin's difficulty) #VARDIFF will start at the POOL_TARGET. It can go as low as the VDIFF_MIN and as high as min(VDIFF_MAX or coindaemons difficulty)
USE_COINDAEMON_DIFF = False # Set the maximum difficulty to the litecoin difficulty. USE_COINDAEMON_DIFF = False # Set the maximum difficulty to the coindaemon difficulty.
DIFF_UPDATE_FREQUENCY = 86400 # Update the litecoin difficulty once a day for the VARDIFF maximum DIFF_UPDATE_FREQUENCY = 86400 # Update the coindaemon difficulty once a day for the VARDIFF maximum
VDIFF_MIN_TARGET = 16 # Minimum Target difficulty VDIFF_MIN_TARGET = 16 # Minimum target difficulty
VDIFF_MAX_TARGET = 1024 # Maximum Target difficulty VDIFF_MAX_TARGET = 1024 # Maximum target difficulty
VDIFF_TARGET_TIME = 15 # Target time per share (i.e. try to get 1 share per this many seconds) VDIFF_TARGET_TIME = 15 # Target time per share (i.e. try to get 1 share per this many seconds)
VDIFF_RETARGET_TIME = 120 # Check to see if we should retarget this often VDIFF_RETARGET_TIME = 120 # Check to see if we should retarget this often
VDIFF_VARIANCE_PERCENT = 30 # Allow average time to very this % from target without retarget VDIFF_VARIANCE_PERCENT = 30 # Allow average time to very this % from target without retarget
# Allow external setting of worker difficulty, checks pool_worker table datarow[6] position for target difficulty # Allow external setting of worker difficulty, checks pool_worker table datarow[6] position for target difficulty
# if present or else defaults to pool target, over rides all other difficulty settings, no checks are made # if present or else defaults to pool target, over rides all other difficulty settings, no checks are made
#for min or max limits this sould be done by your front end software # for min or max limits this should be done by your front end software
ALLOW_EXTERNAL_DIFFICULTY = False ALLOW_EXTERNAL_DIFFICULTY = False
#### Advanced Option ##### #### Advanced Option #####
# For backwards compatibility, we send the scrypt hash to the solutions column in the shares table # For backwards compatibility, we send the scrypt hash to the solutions column in the shares table
# For block confirmation, we have an option to send the block hash in # For block confirmation, we have an option to send the block hash in
# Please make sure your front end is compatible with the block hash in the solutions table. # Please make sure your front end is compatible with the block hash in the solutions table.
# For People using the MPOS frontend enabling this is recommended. It allows the frontend to compare the block hash to the coin daemon reducing the liklihood of missing share error's for blocks # For People using the MPOS frontend enabling this is recommended. It allows the frontend to compare the block hash to the coin daemon reducing the likelihood of missing share error's for blocks
SOLUTION_BLOCK_HASH = True # If enabled, enter the block hash. If false enter the scrypt/sha hash into the shares table SOLUTION_BLOCK_HASH = True # If enabled, enter the block hash. If false enter the scrypt/sha hash into the shares table
#Pass scrypt hash to submit block check. #Pass scrypt hash to submit block check.
#Use if submit block is returning errors and marking submitted blocks invaild upstream, but the submitted blocks are being a accepted by the coin daemon into the block chain. #Use if submit block is returning errors and marking submitted blocks invalid upstream, but the submitted blocks are being a accepted by the coin daemon into the block chain.
BLOCK_CHECK_SCRYPT_HASH = False BLOCK_CHECK_SCRYPT_HASH = False
# ******************** Worker Ban Options ********************* # ******************** Worker Ban Options *********************
ENABLE_WORKER_BANNING = True # enable/disable temporary worker banning ENABLE_WORKER_BANNING = True # Enable/disable temporary worker banning
WORKER_CACHE_TIME = 600 # How long the worker stats cache is good before we check and refresh WORKER_CACHE_TIME = 600 # How long the worker stats cache is good before we check and refresh
WORKER_BAN_TIME = 300 # How long we temporarily ban worker WORKER_BAN_TIME = 300 # How long we temporarily ban worker
INVALID_SHARES_PERCENT = 50 # Allow average invalid shares vary this % before we ban INVALID_SHARES_PERCENT = 50 # Allow average invalid shares vary this % before we ban
# ******************** E-Mail Notification Settings ********************* # ******************** E-Mail Notification Settings *********************
NOTIFY_EMAIL_TO = '' # Where to send Start/Found block notifications NOTIFY_EMAIL_TO = '' # Where to send Start/Found block notifications
NOTIFY_EMAIL_TO_DEADMINER = '' # Where to send dead miner notifications NOTIFY_EMAIL_TO_DEADMINER = '' # Where to send dead miner notifications
NOTIFY_EMAIL_FROM = 'root@localhost' # Sender address NOTIFY_EMAIL_FROM = 'root@localhost' # Sender address
NOTIFY_EMAIL_SERVER = 'localhost' # E-Mail Sender NOTIFY_EMAIL_SERVER = 'localhost' # E-Mail sender
NOTIFY_EMAIL_USERNAME = '' # E-Mail server SMTP Logon NOTIFY_EMAIL_USERNAME = '' # E-Mail server SMTP logon
NOTIFY_EMAIL_PASSWORD = '' NOTIFY_EMAIL_PASSWORD = ''
NOTIFY_EMAIL_USETLS = True NOTIFY_EMAIL_USETLS = True
#### Memcache #### # ******************** Memcache Settings *********************
# Memcahce is a requirement. Enter the settings below # Memcahce is a requirement. Enter the settings below
MEMCACHE_HOST = "localhost" # hostname or IP that runs memcached MEMCACHE_HOST = "localhost" # Hostname or IP that runs memcached
MEMCACHE_PORT = 11211 # Port MEMCACHE_PORT = 11211 # Port
MEMCACHE_TIMEOUT = 900 # Key timeout MEMCACHE_TIMEOUT = 900 # Key timeout
MEMCACHE_PREFIX = "stratum_" # Prefix for keys MEMCACHE_PREFIX = "stratum_" # Prefix for keys

View File

@ -187,7 +187,10 @@ class DBInterface():
return self.dbi.list_users() return self.dbi.list_users()
def get_user(self, id): def get_user(self, id):
return self.dbi.get_user(id) if self.cache.get(id) is None:
self.cache.set(id,self.dbi.get_user(id))
return self.cache.get(id)
def user_exists(self, username): def user_exists(self, username):
if self.cache.get(username) is not None: if self.cache.get(username) is not None:

View File

@ -342,28 +342,13 @@ class DB_Mysql():
} }
return ret return ret
def get_uid(self, id_or_username):
log.debug("Finding user id of %s", id_or_username)
uname = id_or_username.split(".", 1)[0]
self.execute("SELECT `id` FROM `accounts` where username = %s", (uname))
row = self.dbc.fetchone()
if row is None:
return False
else:
uid = row[0]
return uid
def insert_worker(self, account_id, username, password): def insert_worker(self, account_id, username, password):
log.debug("Adding new worker %s", username) log.debug("Adding new worker %s", username)
query = "INSERT INTO pool_worker" query = "INSERT INTO pool_worker"
self.execute(query + '(account_id, username, password) VALUES (%s, %s, %s);', (account_id, username, password)) self.execute(query + '(account_id, username, password) VALUES (%s, %s, %s);', (account_id, username, password))
self.dbh.commit() self.dbh.commit()
return str(username) return str(username)
def close(self): def close(self):
self.dbh.close() self.dbh.close()