Adding baseline shares to statistics class
* Calculate shares towards our base diff * Calculate share rate based on actual shares not diff
This commit is contained in:
parent
d28e728d6c
commit
b23dd56bc8
@ -64,7 +64,8 @@ class Statistics {
|
|||||||
SELECT
|
SELECT
|
||||||
b.*,
|
b.*,
|
||||||
a.username AS finder,
|
a.username AS finder,
|
||||||
a.is_anonymous AS is_anonymous
|
a.is_anonymous AS is_anonymous,
|
||||||
|
ROUND((difficulty * 65535) / POW(2, (" . $this->config['difficulty'] . " -16)), 0) AS estshares
|
||||||
FROM " . $this->block->getTableName() . " AS b
|
FROM " . $this->block->getTableName() . " AS b
|
||||||
LEFT JOIN " . $this->user->getTableName() . " AS a
|
LEFT JOIN " . $this->user->getTableName() . " AS a
|
||||||
ON b.account_id = a.id
|
ON b.account_id = a.id
|
||||||
@ -105,13 +106,13 @@ class Statistics {
|
|||||||
SELECT
|
SELECT
|
||||||
(
|
(
|
||||||
(
|
(
|
||||||
SELECT IFNULL(ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536/600/1000), 0) AS hashrate
|
SELECT IFNULL(ROUND(SUM(IF(difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536 / 600 / 1000), 0) AS hashrate
|
||||||
FROM " . $this->share->getTableName() . "
|
FROM " . $this->share->getTableName() . "
|
||||||
WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE)
|
WHERE time > DATE_SUB(now(), INTERVAL 600 SECOND)
|
||||||
) + (
|
) + (
|
||||||
SELECT IFNULL(ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536/600/1000), 0) AS hashrate
|
SELECT IFNULL(ROUND(SUM(IF(difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536 / 600 / 1000), 0) AS hashrate
|
||||||
FROM " . $this->share->getArchiveTableName() . "
|
FROM " . $this->share->getArchiveTableName() . "
|
||||||
WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE)
|
WHERE time > DATE_SUB(now(), INTERVAL 600 SECOND)
|
||||||
)
|
)
|
||||||
) AS hashrate
|
) AS hashrate
|
||||||
FROM DUAL");
|
FROM DUAL");
|
||||||
@ -130,7 +131,7 @@ class Statistics {
|
|||||||
$this->debug->append("STA " . __METHOD__, 4);
|
$this->debug->append("STA " . __METHOD__, 4);
|
||||||
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
|
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
|
||||||
$stmt = $this->mysqli->prepare("
|
$stmt = $this->mysqli->prepare("
|
||||||
SELECT ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) / 600, 2) AS sharerate
|
SELECT ROUND(SUM(IF(difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) / POW(2, (" . $this->config['difficulty'] . " - 16)) / 600, 2) AS sharerate
|
||||||
FROM " . $this->share->getTableName() . "
|
FROM " . $this->share->getTableName() . "
|
||||||
WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE)");
|
WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE)");
|
||||||
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result() ) return $this->memcache->setCache(__FUNCTION__, $result->fetch_object()->sharerate);
|
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result() ) return $this->memcache->setCache(__FUNCTION__, $result->fetch_object()->sharerate);
|
||||||
@ -149,10 +150,10 @@ class Statistics {
|
|||||||
if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__)) return $data;
|
if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__)) return $data;
|
||||||
$stmt = $this->mysqli->prepare("
|
$stmt = $this->mysqli->prepare("
|
||||||
SELECT
|
SELECT
|
||||||
IFNULL(SUM(IF(our_result='Y', IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty), 0)), 0) AS valid,
|
ROUND(IFNULL(SUM(IF(our_result='Y', IF(difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), difficulty), 0)), 0) / POW(2, (" . $this->config['difficulty'] . " - 16)), 0) AS valid,
|
||||||
IFNULL(SUM(IF(our_result='N', IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty), 0)), 0) AS invalid
|
ROUND(IFNULL(SUM(IF(our_result='N', IF(difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), difficulty), 0)), 0) / POW(2, (" . $this->config['difficulty'] . " - 16)), 0) AS invalid
|
||||||
FROM " . $this->share->getTableName() . "
|
FROM " . $this->share->getTableName() . "
|
||||||
WHERE UNIX_TIMESTAMP(time) >IFNULL((SELECT MAX(time) FROM " . $this->block->getTableName() . "),0)");
|
WHERE UNIX_TIMESTAMP(time) > IFNULL((SELECT MAX(time) FROM " . $this->block->getTableName() . "), 0)");
|
||||||
if ( $this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result() )
|
if ( $this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result() )
|
||||||
return $this->memcache->setCache(__FUNCTION__, $result->fetch_assoc());
|
return $this->memcache->setCache(__FUNCTION__, $result->fetch_assoc());
|
||||||
// Catchall
|
// Catchall
|
||||||
@ -171,8 +172,8 @@ class Statistics {
|
|||||||
if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__)) return $data;
|
if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__)) return $data;
|
||||||
$stmt = $this->mysqli->prepare("
|
$stmt = $this->mysqli->prepare("
|
||||||
SELECT
|
SELECT
|
||||||
IFNULL(SUM(IF(our_result='Y', IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty), 0)), 0) AS valid,
|
ROUND(IFNULL(SUM(IF(our_result='Y', IF(s.difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty), 0)), 0) / POW(2, (" . $this->config['difficulty'] . " - 16)), 0) AS valid,
|
||||||
IFNULL(SUM(IF(our_result='N', IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty), 0)), 0) AS invalid,
|
ROUND(IFNULL(SUM(IF(our_result='N', IF(s.difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty), 0)), 0) / POW(2, (" . $this->config['difficulty'] . " - 16)), 0) AS invalid,
|
||||||
u.id AS id,
|
u.id AS id,
|
||||||
u.username AS username
|
u.username AS username
|
||||||
FROM " . $this->share->getTableName() . " AS s,
|
FROM " . $this->share->getTableName() . " AS s,
|
||||||
@ -197,8 +198,8 @@ class Statistics {
|
|||||||
if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__ . $account_id)) return $data;
|
if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__ . $account_id)) return $data;
|
||||||
$stmt = $this->mysqli->prepare("
|
$stmt = $this->mysqli->prepare("
|
||||||
SELECT
|
SELECT
|
||||||
IFNULL(SUM(IF(our_result='Y', IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty), 0)), 0) AS valid,
|
ROUND(IFNULL(SUM(IF(our_result='Y', IF(s.difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty), 0)), 0) / POW(2, (" . $this->config['difficulty'] . " - 16)), 0) AS valid,
|
||||||
IFNULL(SUM(IF(our_result='N', IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty), 0)), 0) AS invalid
|
ROUND(IFNULL(SUM(IF(our_result='N', IF(s.difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty), 0)), 0) / POW(2, (" . $this->config['difficulty'] . " - 16)), 0) AS invalid
|
||||||
FROM " . $this->share->getTableName() . " AS s,
|
FROM " . $this->share->getTableName() . " AS s,
|
||||||
" . $this->user->getTableName() . " AS u
|
" . $this->user->getTableName() . " AS u
|
||||||
WHERE
|
WHERE
|
||||||
@ -228,7 +229,7 @@ class Statistics {
|
|||||||
a.username AS username,
|
a.username AS username,
|
||||||
a.donate_percent AS donate_percent,
|
a.donate_percent AS donate_percent,
|
||||||
a.email AS email,
|
a.email AS email,
|
||||||
IFNULL(SUM(IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty)), 0) AS shares
|
IFNULL(SUM(IF(s.difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty)), 0) AS shares
|
||||||
FROM " . $this->user->getTableName() . " AS a
|
FROM " . $this->user->getTableName() . " AS a
|
||||||
LEFT JOIN " . $this->share->getTableName() . " AS s
|
LEFT JOIN " . $this->share->getTableName() . " AS s
|
||||||
ON a.username = SUBSTRING_INDEX( s.username, '.', 1 )
|
ON a.username = SUBSTRING_INDEX( s.username, '.', 1 )
|
||||||
@ -252,18 +253,18 @@ class Statistics {
|
|||||||
$stmt = $this->mysqli->prepare("
|
$stmt = $this->mysqli->prepare("
|
||||||
SELECT
|
SELECT
|
||||||
(
|
(
|
||||||
SELECT IFNULL(ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536/600/1000), 0) AS hashrate
|
SELECT IFNULL(ROUND(SUM(IF(difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536 / 600 / 1000), 0) AS hashrate
|
||||||
FROM " . $this->share->getTableName() . " AS s,
|
FROM " . $this->share->getTableName() . " AS s,
|
||||||
" . $this->user->getTableName() . " AS u
|
" . $this->user->getTableName() . " AS u
|
||||||
WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 )
|
WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 )
|
||||||
AND s.time > DATE_SUB(now(), INTERVAL 10 MINUTE)
|
AND s.time > DATE_SUB(now(), INTERVAL 600 SECOND)
|
||||||
AND u.id = ?
|
AND u.id = ?
|
||||||
) + (
|
) + (
|
||||||
SELECT IFNULL(ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536/600/1000), 0) AS hashrate
|
SELECT IFNULL(ROUND(SUM(IF(difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536 / 600 / 1000), 0) AS hashrate
|
||||||
FROM " . $this->share->getArchiveTableName() . " AS s,
|
FROM " . $this->share->getArchiveTableName() . " AS s,
|
||||||
" . $this->user->getTableName() . " AS u
|
" . $this->user->getTableName() . " AS u
|
||||||
WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 )
|
WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 )
|
||||||
AND s.time > DATE_SUB(now(), INTERVAL 10 MINUTE)
|
AND s.time > DATE_SUB(now(), INTERVAL 600 SECOND)
|
||||||
AND u.id = ?
|
AND u.id = ?
|
||||||
) AS hashrate
|
) AS hashrate
|
||||||
FROM DUAL");
|
FROM DUAL");
|
||||||
@ -283,11 +284,11 @@ class Statistics {
|
|||||||
$this->debug->append("STA " . __METHOD__, 4);
|
$this->debug->append("STA " . __METHOD__, 4);
|
||||||
if ($data = $this->memcache->get(__FUNCTION__ . $account_id)) return $data;
|
if ($data = $this->memcache->get(__FUNCTION__ . $account_id)) return $data;
|
||||||
$stmt = $this->mysqli->prepare("
|
$stmt = $this->mysqli->prepare("
|
||||||
SELECT IFNULL(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)), 0)/600 AS sharerate
|
SELECT COUNT(s.id) / 600 AS sharerate
|
||||||
FROM " . $this->share->getTableName() . " AS s,
|
FROM " . $this->share->getTableName() . " AS s,
|
||||||
" . $this->user->getTableName() . " AS u
|
" . $this->user->getTableName() . " AS u
|
||||||
WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 )
|
WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 )
|
||||||
AND s.time > DATE_SUB(now(), INTERVAL 10 MINUTE)
|
AND s.time > DATE_SUB(now(), INTERVAL 600 SECOND)
|
||||||
AND u.id = ?");
|
AND u.id = ?");
|
||||||
if ($this->checkStmt($stmt) && $stmt->bind_param("i", $account_id) && $stmt->execute() && $result = $stmt->get_result() )
|
if ($this->checkStmt($stmt) && $stmt->bind_param("i", $account_id) && $stmt->execute() && $result = $stmt->get_result() )
|
||||||
return $this->memcache->setCache(__FUNCTION__ . $account_id, $result->fetch_object()->sharerate);
|
return $this->memcache->setCache(__FUNCTION__ . $account_id, $result->fetch_object()->sharerate);
|
||||||
@ -305,11 +306,11 @@ class Statistics {
|
|||||||
$this->debug->append("STA " . __METHOD__, 4);
|
$this->debug->append("STA " . __METHOD__, 4);
|
||||||
if ($data = $this->memcache->get(__FUNCTION__ . $worker_id)) return $data;
|
if ($data = $this->memcache->get(__FUNCTION__ . $worker_id)) return $data;
|
||||||
$stmt = $this->mysqli->prepare("
|
$stmt = $this->mysqli->prepare("
|
||||||
SELECT IFNULL(ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536/600/1000), 0) AS hashrate
|
SELECT IFNULL(ROUND(SUM(IF(difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536 / 600 / 1000), 0) AS hashrate
|
||||||
FROM " . $this->share->getTableName() . " AS s,
|
FROM " . $this->share->getTableName() . " AS s,
|
||||||
" . $this->user->getTableName() . " AS u
|
" . $this->user->getTableName() . " AS u
|
||||||
WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 )
|
WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 )
|
||||||
AND s.time > DATE_SUB(now(), INTERVAL 10 MINUTE)
|
AND s.time > DATE_SUB(now(), INTERVAL 600 SECOND)
|
||||||
AND u.id = ?");
|
AND u.id = ?");
|
||||||
if ($this->checkStmt($stmt) && $stmt->bind_param("i", $account_id) && $stmt->execute() && $result = $stmt->get_result() )
|
if ($this->checkStmt($stmt) && $stmt->bind_param("i", $account_id) && $stmt->execute() && $result = $stmt->get_result() )
|
||||||
return $this->memcache->setCache(__FUNCTION__ . $worker_id, $result->fetch_object()->hashrate);
|
return $this->memcache->setCache(__FUNCTION__ . $worker_id, $result->fetch_object()->hashrate);
|
||||||
@ -333,7 +334,7 @@ class Statistics {
|
|||||||
SELECT
|
SELECT
|
||||||
a.donate_percent AS donate_percent,
|
a.donate_percent AS donate_percent,
|
||||||
a.is_anonymous AS is_anonymous,
|
a.is_anonymous AS is_anonymous,
|
||||||
IFNULL(SUM(IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty)), 0) AS shares,
|
ROUND(IFNULL(SUM(IF(s.difficulty=0, POW(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty)), 0) / POW(2, (" . $this->config['difficulty'] . " - 16)), 0) AS shares,
|
||||||
SUBSTRING_INDEX( s.username, '.', 1 ) AS account
|
SUBSTRING_INDEX( s.username, '.', 1 ) AS account
|
||||||
FROM " . $this->share->getTableName() . " AS s
|
FROM " . $this->share->getTableName() . " AS s
|
||||||
LEFT JOIN " . $this->user->getTableName() . " AS a
|
LEFT JOIN " . $this->user->getTableName() . " AS a
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user