Vardiff/pushpool and pps payout support
This commit is contained in:
parent
1fd896dc44
commit
ef234fe80b
@ -45,16 +45,56 @@ if ( $bitcoin->can_connect() === true ){
|
||||
// Value per share calculation
|
||||
// We need to use this instead when running VARDIFF
|
||||
// $pps_value = number_format(round((1/(65536 * $dDifficulty) * $config['reward']), 12) ,12);
|
||||
// pps base payout target, default 16 = difficulty 1 shares for vardiff
|
||||
// (1/(65536 * difficulty) * reward) = (reward / (pow(2,32) * difficulty) * pow(2, 16))
|
||||
|
||||
// We support some dynamic reward targets but fall back to our fixed value
|
||||
// Re-calculate after each run due to re-targets in this loop
|
||||
if ($config['pps']['reward']['type'] == 'blockavg' && $block->getBlockCount() > 0) {
|
||||
$pps_reward = round($block->getAvgBlockReward($config['pps']['blockavg']['blockcount']));
|
||||
$log->logInfo("PPS reward using block average, amount: " . $pps_reward . "\tdifficulty: " . $dDifficulty);
|
||||
} else {
|
||||
if ($config['pps']['reward']['type'] == 'block') {
|
||||
if ($aLastBlock = $block->getLast()) {
|
||||
$pps_reward = $aLastBlock['amount'];
|
||||
$log->logInfo("PPS reward using last block, amount: " . $pps_reward . "\tdifficulty: " . $dDifficulty);
|
||||
} else {
|
||||
$pps_reward = $config['pps']['reward']['default'];
|
||||
$log->logInfo("PPS reward using default, amount: " . $pps_reward . "\tdifficulty: " . $dDifficulty);
|
||||
}
|
||||
} else {
|
||||
$pps_reward = $config['pps']['reward']['default'];
|
||||
$log->logInfo("PPS reward fixed default, amount: " . $pps_reward . "\tdifficulty: " . $dDifficulty);
|
||||
}
|
||||
}
|
||||
|
||||
$pps_value = number_format(round($pps_reward / (pow(2,32) * $dDifficulty) * pow(2, $config['pps_target']), 12) ,12);
|
||||
//$pps_value = number_format(round((1/(65536 * $dDifficulty) * $pps_reward), 12) ,12);
|
||||
|
||||
/**
|
||||
if ($config['reward_type'] != 'block') {
|
||||
$pps_value = number_format(round($config['reward'] / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12) ,12);
|
||||
$pps_value = number_format(round($config['reward'] / (pow(2,32) * $dDifficulty) * pow(2, $config['pps_target']), 12) ,12);
|
||||
} else {
|
||||
// Try to find the last block value and use that for future payouts, revert to fixed reward if none found
|
||||
if ($aLastBlock = $block->getLast()) {
|
||||
$pps_value = number_format(round($aLastBlock['amount'] / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12) ,12);
|
||||
$pps_value = number_format(round($aLastBlock['amount'] / (pow(2,32) * $dDifficulty) * pow(2, $config['pps_target']), 12) ,12);
|
||||
} else {
|
||||
$pps_value = number_format(round($config['reward'] / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12) ,12);
|
||||
$pps_value = number_format(round($config['reward'] / (pow(2,32) * $dDifficulty) * pow(2, $config['pps_target']), 12) ,12);
|
||||
}
|
||||
}
|
||||
**/
|
||||
/**
|
||||
if ($config['reward_type'] != 'block') {
|
||||
$pps_value = number_format(round((1/(65536 * $dDifficulty) * $config['reward']), 12) ,12);
|
||||
} else {
|
||||
// Try to find the last block value and use that for future payouts, revert to fixed reward if none found
|
||||
if ($aLastBlock = $block->getLast()) {
|
||||
$pps_value = number_format(round((1/(65536 * $dDifficulty) * $aLastBlock['amount']), 12) ,12);
|
||||
} else {
|
||||
$pps_value = number_format(round((1/(65536 * $dDifficulty) * $config['reward']), 12) ,12);
|
||||
}
|
||||
}
|
||||
**/
|
||||
|
||||
// Find our last share accounted and last inserted share for PPS calculations
|
||||
$iPreviousShareId = $setting->getValue('pps_last_share_id');
|
||||
|
||||
@ -115,6 +115,18 @@ class Block {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch our average rewards for the past N blocks
|
||||
* @param limit int Maximum blocks to check
|
||||
* @return data float Float value of average shares
|
||||
**/
|
||||
public function getAvgBlockReward($limit=1) {
|
||||
$stmt = $this->mysqli->prepare("SELECT AVG(x.amount) AS average FROM (SELECT amount FROM $this->table ORDER BY height DESC LIMIT ?) AS x");
|
||||
if ($this->checkStmt($stmt) && $stmt->bind_param('i', $limit) && $stmt->execute() && $result = $stmt->get_result())
|
||||
return (float)$result->fetch_object()->average;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch all unconfirmed blocks from table
|
||||
* @param confirmations int Required confirmations to consider block confirmed
|
||||
|
||||
@ -70,7 +70,7 @@ class Share {
|
||||
**/
|
||||
public function getRoundShares($previous_upstream=0, $current_upstream) {
|
||||
$stmt = $this->mysqli->prepare("SELECT
|
||||
IFNULL(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, difficulty)), 0) as total
|
||||
IFNULL(ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)), 8), 0) as total
|
||||
FROM $this->table
|
||||
WHERE our_result = 'Y'
|
||||
AND id > ? AND id <= ?
|
||||
@ -98,8 +98,8 @@ class Share {
|
||||
a.id,
|
||||
SUBSTRING_INDEX( s.username , '.', 1 ) as username,
|
||||
a.no_fees AS no_fees,
|
||||
IFNULL(SUM(IF(our_result='Y', IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, difficulty), 0)), 0) AS valid,
|
||||
IFNULL(SUM(IF(our_result='N', IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, difficulty), 0)), 0) AS invalid
|
||||
IFNULL(ROUND(SUM(IF(our_result='Y', IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty), 0)), 8), 0) AS valid,
|
||||
IFNULL(ROUND(SUM(IF(our_result='N', IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty), 0)), 8), 0) AS invalid
|
||||
FROM $this->table AS s
|
||||
LEFT JOIN " . $this->user->getTableName() . " AS a
|
||||
ON a.username = SUBSTRING_INDEX( s.username , '.', 1 )
|
||||
@ -137,8 +137,8 @@ class Share {
|
||||
a.id,
|
||||
SUBSTRING_INDEX( s.username , '.', 1 ) as account,
|
||||
a.no_fees AS no_fees,
|
||||
IFNULL(SUM(IF(our_result='Y', 1, 0)), 0) AS valid,
|
||||
IFNULL(SUM(IF(our_result='N', 1, 0)), 0) AS invalid
|
||||
IFNULL(ROUND(SUM(IF(our_result='Y', IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty), 0)), 8), 0) AS valid,
|
||||
IFNULL(ROUND(SUM(IF(our_result='N', IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty), 0)), 8), 0) AS invalid
|
||||
FROM $this->tableArchive AS s
|
||||
LEFT JOIN " . $this->user->getTableName() . " AS a
|
||||
ON a.username = SUBSTRING_INDEX( s.username , '.', 1 )
|
||||
@ -189,7 +189,7 @@ class Share {
|
||||
public function moveArchive($current_upstream, $block_id, $previous_upstream=0) {
|
||||
$archive_stmt = $this->mysqli->prepare("
|
||||
INSERT INTO $this->tableArchive (share_id, username, our_result, upstream_result, block_id, time, difficulty)
|
||||
SELECT id, username, our_result, upstream_result, ?, time
|
||||
SELECT id, username, our_result, upstream_result, ?, time, IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty) AS difficulty
|
||||
FROM $this->table
|
||||
WHERE id > ? AND id <= ?");
|
||||
if ($this->checkStmt($archive_stmt) && $archive_stmt->bind_param('iii', $block_id, $previous_upstream, $current_upstream) && $archive_stmt->execute()) {
|
||||
|
||||
@ -105,11 +105,11 @@ class Statistics {
|
||||
SELECT
|
||||
(
|
||||
(
|
||||
SELECT IFNULL(ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, 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() . "
|
||||
WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE)
|
||||
) + (
|
||||
SELECT IFNULL(ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, 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() . "
|
||||
WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE)
|
||||
)
|
||||
@ -130,12 +130,9 @@ class Statistics {
|
||||
$this->debug->append("STA " . __METHOD__, 4);
|
||||
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT ROUND(SUM(sharerate) / 600, 2) AS sharerate FROM
|
||||
(
|
||||
SELECT IFNULL(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, difficulty)), 0) AS sharerate FROM " . $this->share->getTableName() . " WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE)
|
||||
UNION ALL
|
||||
SELECT IFNULL(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, difficulty)), 0) AS sharerate FROM " . $this->share->getArchiveTableName() . " WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE)
|
||||
) AS sum");
|
||||
SELECT ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) / 600, 2) AS sharerate
|
||||
FROM " . $this->share->getTableName() . "
|
||||
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);
|
||||
// Catchall
|
||||
$this->debug->append("Failed to fetch share rate: " . $this->mysqli->error);
|
||||
@ -152,8 +149,8 @@ class Statistics {
|
||||
if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__)) return $data;
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT
|
||||
IFNULL(SUM(IF(our_result='Y', IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, difficulty), 0)), 0) AS valid,
|
||||
IFNULL(SUM(IF(our_result='N', IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, difficulty), 0)), 0) AS invalid
|
||||
IFNULL(SUM(IF(our_result='Y', IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty), 0)), 0) AS valid,
|
||||
IFNULL(SUM(IF(our_result='N', IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty), 0)), 0) AS invalid
|
||||
FROM " . $this->share->getTableName() . "
|
||||
WHERE UNIX_TIMESTAMP(time) >IFNULL((SELECT MAX(time) FROM " . $this->block->getTableName() . "),0)");
|
||||
if ( $this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result() )
|
||||
@ -174,8 +171,8 @@ class Statistics {
|
||||
if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__)) return $data;
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT
|
||||
IFNULL(SUM(IF(our_result='Y', IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, s.difficulty), 0)), 0) AS valid,
|
||||
IFNULL(SUM(IF(our_result='N', IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, s.difficulty), 0)), 0) AS invalid,
|
||||
IFNULL(SUM(IF(our_result='Y', IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty), 0)), 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,
|
||||
u.id AS id,
|
||||
u.username AS username
|
||||
FROM " . $this->share->getTableName() . " AS s,
|
||||
@ -200,8 +197,8 @@ class Statistics {
|
||||
if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__ . $account_id)) return $data;
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT
|
||||
IFNULL(SUM(IF(our_result='Y', IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, s.difficulty), 0)), 0) AS valid,
|
||||
IFNULL(SUM(IF(our_result='N', IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, s.difficulty), 0)), 0) AS invalid
|
||||
IFNULL(SUM(IF(our_result='Y', IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty), 0)), 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
|
||||
FROM " . $this->share->getTableName() . " AS s,
|
||||
" . $this->user->getTableName() . " AS u
|
||||
WHERE
|
||||
@ -231,7 +228,7 @@ class Statistics {
|
||||
a.username AS username,
|
||||
a.donate_percent AS donate_percent,
|
||||
a.email AS email,
|
||||
SUM(s.difficulty) 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
|
||||
LEFT JOIN " . $this->share->getTableName() . " AS s
|
||||
ON a.username = SUBSTRING_INDEX( s.username, '.', 1 )
|
||||
@ -255,14 +252,14 @@ class Statistics {
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT
|
||||
(
|
||||
SELECT ROUND(SUM(IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, s.difficulty)) * 65536/600/1000) 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,
|
||||
" . $this->user->getTableName() . " AS u
|
||||
WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 )
|
||||
AND s.time > DATE_SUB(now(), INTERVAL 10 MINUTE)
|
||||
AND u.id = ?
|
||||
) + (
|
||||
SELECT ROUND(SUM(IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, s.difficulty)) * 65536/600/1000) 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,
|
||||
" . $this->user->getTableName() . " AS u
|
||||
WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 )
|
||||
@ -286,7 +283,7 @@ class Statistics {
|
||||
$this->debug->append("STA " . __METHOD__, 4);
|
||||
if ($data = $this->memcache->get(__FUNCTION__ . $account_id)) return $data;
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT IFNULL(SUM(IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, s.difficulty)), 0)/600 AS sharerate
|
||||
SELECT IFNULL(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)), 0)/600 AS sharerate
|
||||
FROM " . $this->share->getTableName() . " AS s,
|
||||
" . $this->user->getTableName() . " AS u
|
||||
WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 )
|
||||
@ -308,7 +305,7 @@ class Statistics {
|
||||
$this->debug->append("STA " . __METHOD__, 4);
|
||||
if ($data = $this->memcache->get(__FUNCTION__ . $worker_id)) return $data;
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT IFNULL(ROUND(SUM(IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, s.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,
|
||||
" . $this->user->getTableName() . " AS u
|
||||
WHERE u.username = SUBSTRING_INDEX( s.username, '.', 1 )
|
||||
@ -336,7 +333,7 @@ class Statistics {
|
||||
SELECT
|
||||
a.donate_percent AS donate_percent,
|
||||
a.is_anonymous AS is_anonymous,
|
||||
IFNULL(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, difficulty)), 0) AS shares,
|
||||
IFNULL(SUM(IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty)), 0) AS shares,
|
||||
SUBSTRING_INDEX( s.username, '.', 1 ) AS account
|
||||
FROM " . $this->share->getTableName() . " AS s
|
||||
LEFT JOIN " . $this->user->getTableName() . " AS a
|
||||
@ -353,16 +350,16 @@ class Statistics {
|
||||
|
||||
case 'hashes':
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT
|
||||
SELECT
|
||||
a.donate_percent AS donate_percent,
|
||||
a.is_anonymous AS is_anonymous,
|
||||
IFNULL(ROUND(SUM(IF(t1.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, t1.difficulty)) * 65536/600/1000), 0) AS hashrate,
|
||||
IFNULL(ROUND(SUM(t1.difficulty) * 65536/600/1000, 2), 0) AS hashrate,
|
||||
SUBSTRING_INDEX( t1.username, '.', 1 ) AS account
|
||||
FROM
|
||||
(
|
||||
SELECT id, username, difficulty FROM " . $this->share->getTableName() . " WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE) AND our_result = 'Y'
|
||||
UNION
|
||||
SELECT id, username, difficulty FROM " . $this->share->getArchiveTableName() ." WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE) AND our_result = 'Y'
|
||||
SELECT IFNULL(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty), 0) AS difficulty, username FROM " . $this->share->getTableName() . " WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE) AND our_result = 'Y'
|
||||
UNION ALL
|
||||
SELECT IFNULL(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty), 0) AS difficulty, username FROM " . $this->share->getArchiveTableName() ." WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE) AND our_result = 'Y'
|
||||
) AS t1
|
||||
LEFT JOIN " . $this->user->getTableName() . " AS a
|
||||
ON SUBSTRING_INDEX( t1.username, '.', 1 ) = a.username
|
||||
@ -386,7 +383,7 @@ class Statistics {
|
||||
if ($data = $this->memcache->get(__FUNCTION__ . $account_id)) return $data;
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT
|
||||
ROUND(SUM(IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, s.difficulty)) * 65536/3600/1000) AS hashrate,
|
||||
IFNULL(ROUND(SUM(IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty)) * 65536/3600/1000), 0) AS hashrate,
|
||||
HOUR(s.time) AS hour
|
||||
FROM " . $this->share->getArchiveTableName() . " AS s, accounts AS a
|
||||
WHERE time < NOW() - INTERVAL 1 HOUR
|
||||
@ -396,7 +393,7 @@ class Statistics {
|
||||
GROUP BY HOUR(time)
|
||||
UNION ALL
|
||||
SELECT
|
||||
ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 3600 / 1000) AS hashrate,
|
||||
IFNULL(ROUND(SUM(IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty)) * 65536/3600/1000), 0) AS hashrate,
|
||||
HOUR(s.time) AS hour
|
||||
FROM " . $this->share->getArchiveTableName() . " AS s, accounts AS a
|
||||
WHERE time < NOW() - INTERVAL 1 HOUR
|
||||
@ -426,7 +423,7 @@ class Statistics {
|
||||
if ($this->getGetCache() && $data = $this->memcache->get(__FUNCTION__)) return $data;
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT
|
||||
ROUND(SUM(IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, s.difficulty)) * 65536/3600/1000) AS hashrate,
|
||||
IFNULL(ROUND(SUM(IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty)) * 65536/3600/1000), 0) AS hashrate,
|
||||
HOUR(s.time) AS hour
|
||||
FROM " . $this->share->getArchiveTableName() . " AS s
|
||||
WHERE time < NOW() - INTERVAL 1 HOUR
|
||||
@ -434,7 +431,7 @@ class Statistics {
|
||||
GROUP BY HOUR(time)
|
||||
UNION ALL
|
||||
SELECT
|
||||
IFNULL(ROUND(COUNT(s.id) * POW(2, " . $this->config['difficulty'] . ") / 3600 / 1000), 0) AS hashrate,
|
||||
IFNULL(ROUND(SUM(IF(s.difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), s.difficulty)) * 65536/3600/1000), 0) AS hashrate,
|
||||
HOUR(s.time) AS hour
|
||||
FROM " . $this->share->getArchiveTableName() . " AS s
|
||||
WHERE time < NOW() - INTERVAL 1 HOUR
|
||||
|
||||
@ -96,7 +96,7 @@ class Worker {
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT id, username, password, monitor,
|
||||
( SELECT SIGN(COUNT(id)) FROM " . $this->share->getTableName() . " WHERE username = $this->table.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)) AS active,
|
||||
( SELECT ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, difficulty)) * 65536/600/1000) FROM " . $this->share->getTableName() . " WHERE username = $this->table.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)) AS hashrate
|
||||
( SELECT ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536/600/1000) FROM " . $this->share->getTableName() . " WHERE username = $this->table.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)) AS hashrate
|
||||
FROM $this->table
|
||||
WHERE id = ?
|
||||
");
|
||||
@ -117,7 +117,7 @@ class Worker {
|
||||
$stmt = $this->mysqli->prepare("
|
||||
SELECT id, username, password, monitor,
|
||||
( SELECT SIGN(COUNT(id)) FROM " . $this->share->getTableName() . " WHERE our_result = 'Y' AND username = $this->table.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)) AS active,
|
||||
( SELECT ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)) - 1, difficulty)) * 65536/600/1000) FROM " . $this->share->getTableName() . " WHERE our_result = 'Y' AND username = $this->table.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)) AS hashrate
|
||||
( SELECT ROUND(SUM(IF(difficulty=0, pow(2, (" . $this->config['difficulty'] . " - 16)), difficulty)) * 65536/600/1000) FROM " . $this->share->getTableName() . " WHERE our_result = 'Y' AND username = $this->table.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)) AS hashrate
|
||||
FROM $this->table
|
||||
WHERE account_id = ?");
|
||||
if ($this->checkStmt($stmt) && $stmt->bind_param('i', $account_id) && $stmt->execute() && $result = $stmt->get_result())
|
||||
|
||||
@ -347,6 +347,27 @@ $config['reward'] = 50;
|
||||
// Confirmations per block required to credit transactions, default: 120
|
||||
$config['confirmations'] = 120;
|
||||
|
||||
/**
|
||||
* Available pps options:
|
||||
* reward_type:
|
||||
* fixed : Fixed value according to `reward` setting
|
||||
* blockavg : Dynamic value based on average of x number of block rewards
|
||||
* block : Dynamic value based on LAST block amount
|
||||
* reward:
|
||||
* float value : Any value of your choice but should reflect base block values
|
||||
* blockcount : amount of blocks to average, any integer
|
||||
* Default:
|
||||
* pps_reward_type = `fixed` default $config['pps']['reward']['default']
|
||||
* reward = 50
|
||||
*
|
||||
**/
|
||||
$config['pps']['reward']['default'] = 50;
|
||||
$config['pps']['reward']['type'] = 'blockavg';
|
||||
$config['pps']['blockavg']['blockcount'] = 10;
|
||||
|
||||
// pps base payout target, default 16 = difficulty 1 shares for vardiff
|
||||
// (1/(65536 * difficulty) * reward) = (reward / (pow(2,32) * difficulty) * pow(2, 16))
|
||||
$config['pps_target'] = 16; // do not change unless you know what it does
|
||||
|
||||
/**
|
||||
* Memcache configuration
|
||||
|
||||
@ -38,7 +38,6 @@ $aGlobal = array(
|
||||
'hashrate' => $iCurrentPoolHashrate,
|
||||
'nethashrate' => $dNetworkHashrate,
|
||||
'sharerate' => $iCurrentPoolShareRate,
|
||||
'ppsvalue' => number_format(round((1/(65536 * $dDifficulty) * $config['reward']), 12) ,12),
|
||||
'workers' => $iCurrentActiveWorkers,
|
||||
'roundshares' => $aRoundShares,
|
||||
'fees' => $config['fees'],
|
||||
@ -65,18 +64,24 @@ $aGlobal = array(
|
||||
)
|
||||
);
|
||||
|
||||
// We support some dynamic reward targets but fall back to our fixed value
|
||||
// Special calculations for PPS Values based on reward_type setting and/or available blocks
|
||||
if ($config['reward_type'] != 'block') {
|
||||
$aGlobal['ppsvalue'] = number_format(round(50 / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12) ,12);
|
||||
if ($config['pps']['reward']['type'] == 'blockavg' && $block->getBlockCount() > 0) {
|
||||
$pps_reward = round($block->getAvgBlockReward($config['pps']['blockavg']['blockcount']));
|
||||
} else {
|
||||
// Try to find the last block value and use that for future payouts, revert to fixed reward if none found
|
||||
if ($aLastBlock = $block->getLast()) {
|
||||
$aGlobal['ppsvalue'] = number_format(round($aLastBlock['amount'] / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12) ,12);
|
||||
if ($config['pps']['reward']['type'] == 'block') {
|
||||
if ($aLastBlock = $block->getLast()) {
|
||||
$pps_reward = $aLastBlock['amount'];
|
||||
} else {
|
||||
$pps_reward = $config['pps']['reward']['default'];
|
||||
}
|
||||
} else {
|
||||
$aGlobal['ppsvalue'] = number_format(round($config['reward'] / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12) ,12);
|
||||
$pps_reward = $config['pps']['reward']['default'];
|
||||
}
|
||||
}
|
||||
|
||||
$aGlobal['ppsvalue'] = number_format(round($pps_reward / (pow(2,32) * $dDifficulty) * pow(2, $config['pps_target']), 12) ,12);
|
||||
|
||||
// We don't want these session infos cached
|
||||
if (@$_SESSION['USERDATA']['id']) {
|
||||
$aGlobal['userdata'] = $_SESSION['USERDATA']['id'] ? $user->getUserData($_SESSION['USERDATA']['id']) : array();
|
||||
|
||||
@ -62,8 +62,8 @@ target and network difficulty and assuming a zero variance scenario.
|
||||
<td class="right">{$BLOCKSFOUND[block].difficulty|number_format:"2"}</td>
|
||||
<td class="right">{$BLOCKSFOUND[block].amount|number_format:"2"}</td>
|
||||
<td class="right">
|
||||
{math assign="estshares" equation="(65536 * blockdiff)" targetdiff=$GLOBAL.config.targetdiff blockdiff=$BLOCKSFOUND[block].difficulty}
|
||||
{$estshares}
|
||||
{math assign="estshares" equation="(65536 * blockdiff)" blockdiff=$BLOCKSFOUND[block].difficulty}
|
||||
{$estshares|number_format}
|
||||
</td>
|
||||
<td class="right">{$BLOCKSFOUND[block].shares|number_format}</td>
|
||||
<td class="right">
|
||||
|
||||
@ -56,9 +56,9 @@ target and network difficulty and assuming a zero variance scenario.
|
||||
<td>{$BLOCKSFOUND[block].finder|default:"unknown"}</td>
|
||||
<td class="center">{$BLOCKSFOUND[block].time|date_format:"%d/%m %H:%M:%S"}</td>
|
||||
<td class="right">{$BLOCKSFOUND[block].difficulty|number_format:"2"}</td>
|
||||
<td class="right">{(pow(2,32 - $GLOBAL.config.targetdiff) * $BLOCKSFOUND[block].difficulty)|number_format}</td>
|
||||
<td class="right">{(65536 * $BLOCKSFOUND[block].difficulty)|number_format}</td>
|
||||
<td class="right">{$BLOCKSFOUND[block].shares|number_format}</td>
|
||||
<td class="right">{($BLOCKSFOUND[block].shares / (pow(2,32 - $GLOBAL.config.targetdiff) * $BLOCKSFOUND[block].difficulty) * 100)|number_format:"2"}</td>
|
||||
<td class="right">{($BLOCKSFOUND[block].shares / (65536 * $BLOCKSFOUND[block].difficulty) * 100)|number_format:"2"}</td>
|
||||
</tr>
|
||||
{/section}
|
||||
</tbody>
|
||||
|
||||
@ -51,7 +51,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="leftheader">Est. Shares this Round</td>
|
||||
<td>{(pow(2, 32 - $GLOBAL.config.targetdiff) * $DIFFICULTY)|number_format:"0"} <font size="1">(done: {(100 / (pow(2, 32 - $GLOBAL.config.targetdiff) * $DIFFICULTY) * $GLOBAL.roundshares.valid)|number_format:"2"} %)</td>
|
||||
<td>{(65536 * $DIFFICULTY)|number_format:"0"} <font size="1">(done: {(100 / (65536 * $DIFFICULTY) * $GLOBAL.roundshares.valid)|number_format:"2"} %)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="leftheader">Time Since Last Block</td>
|
||||
|
||||
@ -80,8 +80,8 @@ CREATE TABLE IF NOT EXISTS `pool_worker` (
|
||||
`account_id` int(255) NOT NULL,
|
||||
`username` char(50) DEFAULT NULL,
|
||||
`password` char(255) DEFAULT NULL,
|
||||
`difficulty` float NOT NULL DEFAULT '0',
|
||||
`monitor` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`difficulty` int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `username` (`username`),
|
||||
KEY `account_id` (`account_id`)
|
||||
@ -102,8 +102,8 @@ CREATE TABLE IF NOT EXISTS `shares` (
|
||||
`upstream_result` enum('Y','N') DEFAULT NULL,
|
||||
`reason` varchar(50) DEFAULT NULL,
|
||||
`solution` varchar(257) NOT NULL,
|
||||
`difficulty` float NOT NULL DEFAULT '0',
|
||||
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`difficulty` int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `time` (`time`),
|
||||
KEY `upstream_result` (`upstream_result`),
|
||||
@ -118,8 +118,8 @@ CREATE TABLE IF NOT EXISTS `shares_archive` (
|
||||
`our_result` enum('Y','N') DEFAULT NULL,
|
||||
`upstream_result` enum('Y','N') DEFAULT NULL,
|
||||
`block_id` int(10) unsigned NOT NULL,
|
||||
`difficulty` float NOT NULL DEFAULT '0',
|
||||
`time` datetime NOT NULL,
|
||||
`difficulty` int(11) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `share_id` (`share_id`),
|
||||
KEY `time` (`time`)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user