Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UPDATE : Development to Master #2738

Merged
merged 26 commits into from
May 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
26d2915
First attempt to add support to BTC >= 0.16
lubuzzo Apr 17, 2018
3b23295
Merge pull request #2714 from lubuzzo/master
TheSerapher Apr 18, 2018
181a66b
don't hardcode wallet name
r4sas Apr 20, 2018
cdba6ce
fix "field doesn't have a default values" error
r4sas Apr 25, 2018
b007bfa
add database upgrade script, update version in initial database
r4sas Apr 25, 2018
832d67f
bump DB version, update db upgrade script
r4sas Apr 25, 2018
8f3dafd
Merge pull request #2720 from r4sas/sql-sharestats
TheSerapher Apr 25, 2018
3ddf6cb
Merge pull request #2717 from r4sas/statistics-patch
TheSerapher Apr 25, 2018
8cfc43e
implement low-diff shares counting (#2718 #2726)
May 11, 2018
363e2be
Merge pull request #2727 from r4sas/lowdiff-shares
TheSerapher May 11, 2018
b183ff1
lowdiff updates
r4sas May 11, 2018
ce78e8b
revert changes for mysql ifnull functions
r4sas May 12, 2018
1f8a332
Updated author/project in composer file
TheSerapher May 12, 2018
15de9e1
change to unsigned float
r4sas May 12, 2018
61670a1
[UPDATE] Print error if vendor libs are missing
TheSerapher May 12, 2018
e09db5c
update block statistics
r4sas May 12, 2018
01c75f4
[UPDATE][#2713] Adding transaction filter
TheSerapher May 12, 2018
d1d4a07
Merge pull request #2728 from r4sas/lowdiff-shares
TheSerapher May 12, 2018
e79b558
[UPDATE] Also detect testnet on RPC > 0.16
TheSerapher May 12, 2018
30668ed
fix sharerate precision and reduce graphics page size
r4sas May 12, 2018
b9dc229
Merge pull request #2729 from r4sas/lowdiff-shares
TheSerapher May 12, 2018
96ab98a
[UPDATE] Better getinfo detection
TheSerapher May 18, 2018
3f4efc9
[ADDED] DEBUG log if RPC > 0.16 getinfo wrapper fails
TheSerapher May 23, 2018
085dfa0
[VERSION] 1.1.0
TheSerapher May 23, 2018
20a9c59
fix documentation links
r4sas May 23, 2018
e5b1ec5
Merge pull request #2739 from r4sas/development
TheSerapher May 24, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
6 changes: 5 additions & 1 deletion include/autoloader.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 3 additions & 1 deletion include/classes/bitcoin.class.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
18 changes: 17 additions & 1 deletion include/classes/bitcoinwrapper.class.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion include/classes/block.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion include/classes/coins/coin_base.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions include/classes/statistics.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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();
}

Expand All @@ -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();
}

Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion include/classes/worker.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading