commit
64801cfca1
@ -7,6 +7,7 @@ if (!defined('SECURITY'))
|
|||||||
class Share {
|
class Share {
|
||||||
private $sError = '';
|
private $sError = '';
|
||||||
private $table = 'shares';
|
private $table = 'shares';
|
||||||
|
private $tableArchive = 'shares_archive';
|
||||||
private $oUpstream;
|
private $oUpstream;
|
||||||
private $iLastUpstreamId;
|
private $iLastUpstreamId;
|
||||||
// This defines each share
|
// This defines each share
|
||||||
@ -26,6 +27,9 @@ class Share {
|
|||||||
return $this->sError;
|
return $this->sError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getArchiveTableName() {
|
||||||
|
return $this->tableArchive;
|
||||||
|
}
|
||||||
public function getTableName() {
|
public function getTableName() {
|
||||||
return $this->table;
|
return $this->table;
|
||||||
}
|
}
|
||||||
@ -93,8 +97,8 @@ class Share {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function moveArchive($previous_upstream=0, $current_upstream,$block_id) {
|
public function moveArchive($previous_upstream=0, $current_upstream,$block_id) {
|
||||||
$archive_stmt = $this->mysqli->prepare("INSERT INTO shares_archive (share_id, username, our_result, upstream_result, block_id)
|
$archive_stmt = $this->mysqli->prepare("INSERT INTO $this->tableArchive (share_id, username, our_result, upstream_result, block_id, time)
|
||||||
SELECT id, username, our_result, upstream_result, ?
|
SELECT id, username, our_result, upstream_result, ?, time
|
||||||
FROM $this->table
|
FROM $this->table
|
||||||
WHERE id BETWEEN ? AND ?");
|
WHERE id BETWEEN ? AND ?");
|
||||||
$delete_stmt = $this->mysqli->prepare("DELETE FROM $this->table WHERE id BETWEEN ? AND ?");
|
$delete_stmt = $this->mysqli->prepare("DELETE FROM $this->table WHERE id BETWEEN ? AND ?");
|
||||||
|
|||||||
@ -38,10 +38,33 @@ class Statistics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getCurrentHashrate() {
|
public function getCurrentHashrate() {
|
||||||
$stmt = $this->mysqli->prepare("SELECT ROUND(COUNT(id) * POW(2, " . $this->config['difficulty'] . ")/600/1000) AS hashrate FROM " . $this->share->getTableName() . " WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE)");
|
$stmt = $this->mysqli->prepare("
|
||||||
|
SELECT SUM(hashrate) AS hashrate FROM
|
||||||
|
(
|
||||||
|
SELECT ROUND(COUNT(id) * POW(2, " . $this->config['difficulty'] . ")/600/1000) AS hashrate FROM " . $this->share->getTableName() . " WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE)
|
||||||
|
UNION
|
||||||
|
SELECT ROUND(COUNT(id) * POW(2, " . $this->config['difficulty'] . ")/600/1000) AS hashrate FROM " . $this->share->getArchiveTableName() . " WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE)
|
||||||
|
) AS sum
|
||||||
|
");
|
||||||
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result() ) {
|
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result() ) {
|
||||||
return $result->fetch_object()->hashrate;
|
return $result->fetch_object()->hashrate;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCurrentShareRate() {
|
||||||
|
$stmt = $this->mysqli->prepare("
|
||||||
|
SELECT ROUND(SUM(sharerate) / 600, 2) AS sharerate FROM
|
||||||
|
(
|
||||||
|
SELECT COUNT(id) AS sharerate FROM " . $this->share->getTableName() . " WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE)
|
||||||
|
UNION ALL
|
||||||
|
SELECT COUNT(id) AS sharerate FROM " . $this->share->getArchiveTableName() . " WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE)
|
||||||
|
) AS sum
|
||||||
|
");
|
||||||
|
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result() ) {
|
||||||
|
return $result->fetch_object()->sharerate;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkStmt($bState) {
|
private function checkStmt($bState) {
|
||||||
|
|||||||
@ -31,6 +31,7 @@ $aGlobal = array(
|
|||||||
'websitename' => $settings->getValue('websitename'),
|
'websitename' => $settings->getValue('websitename'),
|
||||||
'ltc_usd' => $settings->getValue('btcesell'),
|
'ltc_usd' => $settings->getValue('btcesell'),
|
||||||
'hashrate' => $iCurrentPoolHashrate,
|
'hashrate' => $iCurrentPoolHashrate,
|
||||||
|
'sharerate' => $statistics->getCurrentShareRate(),
|
||||||
'workers' => $iCurrentActiveWorkers,
|
'workers' => $iCurrentActiveWorkers,
|
||||||
'roundshares' => $aRoundShares,
|
'roundshares' => $aRoundShares,
|
||||||
'statstime' => $settings->getValue('statstime'),
|
'statstime' => $settings->getValue('statstime'),
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td><li>Ł/usd: {$GLOBAL.ltc_usd} </li></td>
|
<td><li>Ł/usd: {$GLOBAL.ltc_usd} </li></td>
|
||||||
<td><li>Pool Hashrate: {$GLOBAL.hashrate / 1000} MH/s </li></td>
|
<td><li>Pool Hashrate: {$GLOBAL.hashrate / 1000} MH/s </li></td>
|
||||||
|
<td><li>Pool Sharerate: {$GLOBAL.sharerate} Shares/m </li></td>
|
||||||
<td><li>Pool Workers: {$GLOBAL.workers} </li></td>
|
<td><li>Pool Workers: {$GLOBAL.workers} </li></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
-- http://www.phpmyadmin.net
|
-- http://www.phpmyadmin.net
|
||||||
--
|
--
|
||||||
-- Host: localhost
|
-- Host: localhost
|
||||||
-- Erstellungszeit: 13. Mai 2013 um 16:03
|
-- Erstellungszeit: 14. Mai 2013 um 16:12
|
||||||
-- Server Version: 5.5.31-0ubuntu0.13.04.1
|
-- Server Version: 5.5.31-0ubuntu0.13.04.1
|
||||||
-- PHP-Version: 5.4.9-4ubuntu2
|
-- PHP-Version: 5.4.9-4ubuntu2
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ SET time_zone = "+00:00";
|
|||||||
/*!40101 SET NAMES utf8 */;
|
/*!40101 SET NAMES utf8 */;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Datenbank: `mmcfe_ng`
|
-- Datenbank: `mmcfe_ng_db`
|
||||||
--
|
--
|
||||||
|
|
||||||
-- --------------------------------------------------------
|
-- --------------------------------------------------------
|
||||||
@ -111,8 +111,10 @@ CREATE TABLE IF NOT EXISTS `shares_archive` (
|
|||||||
`our_result` enum('Y','N') DEFAULT NULL,
|
`our_result` enum('Y','N') DEFAULT NULL,
|
||||||
`upstream_result` enum('Y','N') DEFAULT NULL,
|
`upstream_result` enum('Y','N') DEFAULT NULL,
|
||||||
`block_id` int(10) unsigned NOT NULL,
|
`block_id` int(10) unsigned NOT NULL,
|
||||||
|
`time` datetime NOT NULL,
|
||||||
PRIMARY KEY (`id`),
|
PRIMARY KEY (`id`),
|
||||||
UNIQUE KEY `share_id` (`share_id`)
|
UNIQUE KEY `share_id` (`share_id`),
|
||||||
|
KEY `time` (`time`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Archive shares for potential later debugging purposes';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Archive shares for potential later debugging purposes';
|
||||||
|
|
||||||
-- --------------------------------------------------------
|
-- --------------------------------------------------------
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user