diff --git a/mining/DB_Mysql_Vardiff.py b/mining/DB_Mysql_Vardiff.py index 4075770..36ad69e 100644 --- a/mining/DB_Mysql_Vardiff.py +++ b/mining/DB_Mysql_Vardiff.py @@ -29,8 +29,7 @@ class DB_Mysql_Vardiff(DB_Mysql.DB_Mysql): checkin_times = {} total_shares = 0 best_diff = 0 - log.debug(data) - + for k, v in enumerate(data): # for database compatibility we are converting our_worker to Y/N format if v[5]: @@ -46,14 +45,13 @@ class DB_Mysql_Vardiff(DB_Mysql.DB_Mysql): VALUES (FROM_UNIXTIME(%(time)s), %(host)s, %(uname)s, - %(lres)s, %(result)s, %(reason)s, %(solution)s, %(difficulty)s) + %(lres)s, 'N', %(reason)s, %(solution)s, %(difficulty)s) """, { "time": v[4], "host": v[6], "uname": v[0], "lres": v[5], - "result": v[5], "reason": v[9], "solution": v[2], "difficulty": v[3] @@ -92,4 +90,30 @@ class DB_Mysql_Vardiff(DB_Mysql.DB_Mysql): self.dbh.commit() - + def get_workers_stats(self): + self.execute( + """ + SELECT `username`, `speed`, `last_checkin`, `total_shares`, + `total_rejects`, `total_found`, `alive`, `difficulty` + FROM `pool_worker` + WHERE `id` > 0 + """ + ) + + ret = {} + + for data in self.dbc.fetchall(): + ret[data[0]] = { + "username": data[0], + "speed": int(data[1]), + "last_checkin": time.mktime(data[2].timetuple()), + "total_shares": int(data[3]), + "total_rejects": int(data[4]), + "total_found": int(data[5]), + "alive": True if data[6] is 1 else False, + "difficulty": float(data[7]) + } + + return ret + +