fixing difficulty per worker value

This commit is contained in:
Sebastian Grewe 2013-08-22 12:33:29 +02:00
parent 6522fb2747
commit eb435b4072

View File

@ -96,6 +96,8 @@ class Worker {
$this->debug->append("STA " . __METHOD__, 4); $this->debug->append("STA " . __METHOD__, 4);
$stmt = $this->mysqli->prepare(" $stmt = $this->mysqli->prepare("
SELECT id, username, password, monitor, SELECT id, username, password, monitor,
( SELECT COUNT(id) FROM " . $this->share->getTableName() . " WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)) AS count_all,
( SELECT COUNT(id) FROM " . $this->share->getArchiveTableName() . " WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)) AS count_all_archive,
( (
SELECT SELECT
IFNULL(IF(our_result='Y', ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536/600/1000), 0), 0) AS hashrate IFNULL(IF(our_result='Y', ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536/600/1000), 0), 0) AS hashrate
@ -112,11 +114,11 @@ class Worker {
AND time > DATE_SUB(now(), INTERVAL 10 MINUTE) AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)
) AS hashrate, ) AS hashrate,
( (
SELECT IFNULL(IF(our_result='Y', ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) / COUNT(id), 2), 0), 0) SELECT IFNULL(ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) / count_all, 2), 0)
FROM " . $this->share->getTableName() . " FROM " . $this->share->getTableName() . "
WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE) WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)
) + ( ) + (
SELECT IFNULL(IF(our_result='Y', ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) / COUNT(id), 2), 0), 0) SELECT IFNULL(ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) / count_all_archive, 2), 0)
FROM " . $this->share->getArchiveTableName() . " FROM " . $this->share->getArchiveTableName() . "
WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE) WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)
) AS difficulty ) AS difficulty
@ -138,6 +140,8 @@ class Worker {
$this->debug->append("STA " . __METHOD__, 4); $this->debug->append("STA " . __METHOD__, 4);
$stmt = $this->mysqli->prepare(" $stmt = $this->mysqli->prepare("
SELECT id, username, password, monitor, SELECT id, username, password, monitor,
( SELECT COUNT(id) FROM " . $this->share->getTableName() . " WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)) AS count_all,
( SELECT COUNT(id) FROM " . $this->share->getArchiveTableName() . " WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)) AS count_all_archive,
( (
SELECT SELECT
IFNULL(IF(our_result='Y', ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536/600/1000), 0), 0) AS hashrate IFNULL(IF(our_result='Y', ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536/600/1000), 0), 0) AS hashrate
@ -154,11 +158,11 @@ class Worker {
AND time > DATE_SUB(now(), INTERVAL 10 MINUTE) AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)
) AS hashrate, ) AS hashrate,
( (
SELECT IFNULL(IF(our_result='Y', ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) / COUNT(id), 2), 0), 0) SELECT IFNULL(ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) / count_all, 2), 0)
FROM " . $this->share->getTableName() . " FROM " . $this->share->getTableName() . "
WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE) WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)
) + ( ) + (
SELECT IFNULL(IF(our_result='Y', ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) / COUNT(id), 2), 0), 0) SELECT IFNULL(ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) / count_all_archive, 2), 0)
FROM " . $this->share->getArchiveTableName() . " FROM " . $this->share->getArchiveTableName() . "
WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE) WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)
) AS difficulty ) AS difficulty