Permalink
Browse files

Merge pull request #2738 from MPOS/development

UPDATE : Development to Master
  • Loading branch information...
TheSerapher committed May 24, 2018
2 parents 8fa8d6c + e5b1ec5 commit 236cccd5d3178e99504bf2665db8bddfed6aa176
Showing with 177 additions and 116 deletions.
  1. +3 −3 composer.json
  2. +5 −1 include/autoloader.inc.php
  3. +3 −1 include/classes/bitcoin.class.php
  4. +17 −1 include/classes/bitcoinwrapper.class.php
  5. +1 −1 include/classes/block.class.php
  6. +1 −1 include/classes/coins/coin_base.class.php
  7. +6 −6 include/classes/statistics.class.php
  8. +1 −1 include/classes/worker.class.php
  9. +33 −33 include/config/global.inc.dist.php
  10. +4 −4 include/config/security.inc.dist.php
  11. +6 −1 include/pages/api/getusertransactions.inc.php
  12. +1 −1 include/pages/statistics.inc.php
  13. +2 −2 include/version.inc.php
  14. +6 −6 sql/000_base_structure.sql
  15. +3 −3 templates/bootstrap/dashboard/blocks/default.tpl
  16. +3 −3 templates/bootstrap/dashboard/js/api.tpl
  17. +1 −1 templates/bootstrap/dashboard/overview/_with_price_graph.tpl
  18. +1 −1 templates/bootstrap/dashboard/overview/_without_price_graph.tpl
  19. +1 −1 templates/bootstrap/dashboard/round_statistics/prop/round.tpl
  20. +12 −12 templates/bootstrap/statistics/blocks/block_overview_time.tpl
  21. +6 −6 templates/bootstrap/statistics/blocks/blocks_found_details.tpl
  22. +1 −1 templates/bootstrap/statistics/blocks/small_table.tpl
  23. +4 −3 templates/bootstrap/statistics/graphs/default.tpl
  24. +1 −1 templates/bootstrap/statistics/pool/contributors_hashrate.tpl
  25. +3 −3 templates/bootstrap/statistics/pool/contributors_shares.tpl
  26. +1 −1 templates/bootstrap/statistics/pool/general_stats.tpl
  27. +1 −1 templates/bootstrap/statistics/round/block_stats.tpl
  28. +3 −3 templates/bootstrap/statistics/round/pplns_block_stats.tpl
  29. +3 −3 templates/bootstrap/statistics/round/pplns_block_stats_small.tpl
  30. +2 −2 templates/bootstrap/statistics/round/pplns_round_shares.tpl
  31. +2 −2 templates/bootstrap/statistics/round/pplns_transactions.tpl
  32. +4 −4 templates/bootstrap/statistics/round/pplns_transactions_small.tpl
  33. +2 −2 templates/bootstrap/statistics/round/round_shares.tpl
  34. +1 −1 templates/bootstrap/statistics/round/round_transactions.tpl
  35. +33 −0 upgrade/definitions/1.0.2_to_1.0.3.inc.php
@@ -1,13 +1,13 @@
{
"name": "delboy1978uk/mpos",
"name": "MPOS/php-mpos",
"description": "MPOS stands for Mining Portal Open Source. A unified mining interface for various Scrypt and SHA256d Crypto-currencies!",
"require-dev": {
"codeception/codeception": "~2.0"
},
"authors": [
{
"name": "Derek Stephen McLean",
"email": "delboy1978uk@gmail.com"
"name": "Sebastian Grewe",
"email": "sebastian.grewe@gmail.com"
}
],
"require": {
@@ -2,7 +2,11 @@
(SECURITY == "*)WT#&YHfd" && SECHASH_CHECK) ? die("public/index.php -> Set a new SECURITY value to continue") : 0;
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
require_once(INCLUDE_DIR . '/../vendor/autoload.php');
if (file_exists(INCLUDE_DIR . '/../vendor/autoload.php')) {
require_once(INCLUDE_DIR . '/../vendor/autoload.php');
} else {
die("Unable to load vendor libraries, please run `php composer.phar install` in root folder.");
}
// Default classes
require_once(INCLUDE_DIR . '/lib/KLogger.php');
4 include/classes/bitcoin.class.php 100644 → 100755
@@ -284,13 +284,15 @@ public function __construct($scheme, $username, $password, $address = "localhost
* The check is done by calling the server's getinfo() method and checking
* for a fault.
*
* To turn code compatible with BTC >= 0.16, getmininginfo() method used instead of getinfo()
*
* @return mixed boolean TRUE if successful, or a fault string otherwise
* @access public
* @throws none
*/
public function can_connect() {
try {
$r = $this->getinfo();
$r = $this->getmininginfo();
} catch (Exception $e) {
return $e->getMessage();
}
@@ -24,13 +24,29 @@ public function __construct($type, $username, $password, $host, $debug_level, $d
public function getinfo() {
$this->oDebug->append("STA " . __METHOD__, 4);
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
return $this->memcache->setCache(__FUNCTION__, parent::getinfo(), 30);
try {
return $this->memcache->setCache(__FUNCTION__, parent::getnetworkinfo()+parent::getmininginfo()+parent::getwalletinfo(), 30);
} catch (Exception $e) {
$this->oDebug->append("DEPRECATED : RPC version < 0.16, fallback to `getinfo` RPC call", 2);
return $this->memcache->setCache(__FUNCTION__, parent::getinfo(), 30);
}
}
public function is_testnet() {
$this->oDebug->append("STA " . __METHOD__, 4);
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
if (!(parent::getblockchaininfo()))
return $this->memcache->setCache(__FUNCTION__, parent::is_testnet(), 30);
else
return $this->memcache->setCache(__FUNCTION__, parent::getblockchaininfo()['chain'] == 'test', 30);
}
public function getmininginfo() {
$this->oDebug->append("STA " . __METHOD__, 4);
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
return $this->memcache->setCache(__FUNCTION__, parent::getmininginfo(), 30);
}
public function getblockcount() {
$this->oDebug->append("STA " . __METHOD__, 4);
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
@@ -237,7 +237,7 @@ public function setShareId($block_id, $share_id) {
* @return bool
**/
public function setShares($block_id, $shares=NULL) {
$field = array( 'name' => 'shares', 'value' => $shares, 'type' => 'i');
$field = array( 'name' => 'shares', 'value' => $shares, 'type' => 'd');
return $this->updateSingle($block_id, $field);
}
@@ -60,7 +60,7 @@ public function calcHashrate($shares, $interval) {
* according to our configuration difficulty
**/
public function calcEstaimtedShares($dDifficulty) {
return (int)round(pow(2, (32 - $this->target_bits)) * $dDifficulty, 0);
return (float)round(pow(2, (32 - $this->target_bits)) * $dDifficulty, $this->share_difficulty_precision);
}
/**
@@ -111,7 +111,7 @@ public function getBlocksFound($limit=10) {
b.*,
a.username AS finder,
a.is_anonymous AS is_anonymous,
ROUND(difficulty * POW(2, 32 - " . $this->coin->getTargetBits() . "), 0) AS estshares
ROUND(difficulty * POW(2, 32 - " . $this->coin->getTargetBits() . "), " . $this->coin->getShareDifficultyPrecision() . ") AS estshares
FROM " . $this->block->getTableName() . " AS b
LEFT JOIN " . $this->user->getTableName() . " AS a
ON b.account_id = a.id
@@ -203,7 +203,7 @@ public function getBlocksSolvedbyWorker($account_id, $limit=25) {
public function updateShareStatistics($aStats, $iBlockId) {
$this->debug->append("STA " . __METHOD__, 4);
$stmt = $this->mysqli->prepare("INSERT INTO $this->table (account_id, valid, invalid, block_id) VALUES (?, ?, ?, ?)");
if ($this->checkStmt($stmt) && $stmt->bind_param('iiii', $aStats['id'], $aStats['valid'], $aStats['invalid'], $iBlockId) && $stmt->execute()) return true;
if ($this->checkStmt($stmt) && $stmt->bind_param('iddi', $aStats['id'], $aStats['valid'], $aStats['invalid'], $iBlockId) && $stmt->execute()) return true;
return $this->sqlError();
}
@@ -213,7 +213,7 @@ public function updateShareStatistics($aStats, $iBlockId) {
public function insertPPLNSStatistics($aStats, $iBlockId) {
$this->debug->append("STA " . __METHOD__, 4);
$stmt = $this->mysqli->prepare("INSERT INTO $this->table (account_id, valid, invalid, pplns_valid, pplns_invalid, block_id) VALUES (?, ?, ?, ?, ?, ?)");
if ($this->checkStmt($stmt) && $stmt->bind_param('iiiiii', $aStats['id'], $aStats['valid'], $aStats['invalid'], $aStats['pplns_valid'], $aStats['pplns_invalid'], $iBlockId) && $stmt->execute()) return true;
if ($this->checkStmt($stmt) && $stmt->bind_param('iddddi', $aStats['id'], $aStats['valid'], $aStats['invalid'], $aStats['pplns_valid'], $aStats['pplns_invalid'], $iBlockId) && $stmt->execute()) return true;
return $this->sqlError();
}
@@ -261,12 +261,12 @@ public function getCurrentShareRate($interval=180) {
SELECT
(
(
SELECT ROUND(SUM(difficulty) / ?, 2) AS sharerate
SELECT ROUND(SUM(difficulty) / ?, " . $this->coin->getShareDifficultyPrecision() . ") AS sharerate
FROM " . $this->share->getTableName() . "
WHERE time > DATE_SUB(now(), INTERVAL ? SECOND)
AND our_result = 'Y'
) + (
SELECT ROUND(SUM(difficulty) / ?, 2) AS sharerate
SELECT ROUND(SUM(difficulty) / ?, " . $this->coin->getShareDifficultyPrecision() . ") AS sharerate
FROM " . $this->share->getArchiveTableName() . "
WHERE time > DATE_SUB(now(), INTERVAL ? SECOND)
AND our_result = 'Y'
@@ -470,7 +470,7 @@ public function fetchAllUserMiningStats($interval=180) {
a.username AS account,
COUNT(DISTINCT t1.username) AS workers,
IFNULL(SUM(t1.difficulty), 0) AS shares,
ROUND(SUM(t1.difficulty) / ?, 2) AS sharerate,
ROUND(SUM(t1.difficulty) / ?, " . $this->coin->getShareDifficultyPrecision() . ") AS sharerate,
IFNULL(AVG(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)), 0) AS avgsharediff
FROM (
SELECT
@@ -174,7 +174,7 @@ public function getWorkers($account_id, $interval=600) {
while ($row = $result->fetch_assoc()) {
$row['hashrate'] = round($this->coin->calcHashrate($row['shares'], $interval), 2);
if ($row['count_all'] > 0) {
$row['difficulty'] = round($row['shares'] / $row['count_all'], 2);
$row['difficulty'] = round($row['shares'] / $row['count_all'], $this->coin->getShareDifficultyPrecision());
} else {
$row['difficulty'] = 0.00;
}
Oops, something went wrong.

0 comments on commit 236cccd

Please sign in to comment.