From d59b8ef5638a0bf904ce8bea3a45873def95fd76 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 5 Aug 2013 09:18:52 +0200 Subject: [PATCH 01/30] Make block count on stats page configurable Fixes #549 --- public/include/config/global.inc.dist.php | 3 +++ public/include/pages/statistics/blocks.inc.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/public/include/config/global.inc.dist.php b/public/include/config/global.inc.dist.php index 359f74da..265dfc7a 100644 --- a/public/include/config/global.inc.dist.php +++ b/public/include/config/global.inc.dist.php @@ -109,6 +109,7 @@ $config['ap_threshold']['max'] = 250; * mobile : Enable/Disable mobile theme support * mobile_theme : Theme used for mobile browsers * api disabled : Disable the sites API functions + * blocks count : # of blocks to display on block statistics page * * Defaults: * title = `The Pool - Mining Evolved` @@ -119,6 +120,7 @@ $config['ap_threshold']['max'] = 250; * mobile = true * mobile_theme = `mobile` * api disbabled = false + * blocks count = 20 **/ $config['website']['title'] = 'The Pool - Mining Evolved'; $config['website']['name'] = 'The Pool'; @@ -128,6 +130,7 @@ $config['website']['theme'] = 'mmcFE'; $config['website']['mobile'] = true; $config['website']['mobile_theme'] = 'mobile'; $config['website']['api']['disabled'] = false; +$config['website']['blocks']['count'] = 20; /** * Account specific settings diff --git a/public/include/pages/statistics/blocks.inc.php b/public/include/pages/statistics/blocks.inc.php index 3218a9f4..494e6be3 100644 --- a/public/include/pages/statistics/blocks.inc.php +++ b/public/include/pages/statistics/blocks.inc.php @@ -7,7 +7,7 @@ if (!defined('SECURITY')) die('Hacking attempt'); if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { $debug->append('No cached version available, fetching from backend', 3); // Grab the last blocks found - $iLimit = 20; + !empty($config['website']['blocks']['count']) ? $iLimit = $config['website']['blocks']['count'] : $iLimit = 20; $aBlocksFoundData = $statistics->getBlocksFound($iLimit); // Propagate content our template From 769a85cbc0970304901ebc858eeda707c7d096d6 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 7 Aug 2013 08:54:38 +0200 Subject: [PATCH 02/30] Deduct TXFee from transferred balance This should fix #568 as proposed by @nicoschtein --- cronjobs/auto_payout.php | 2 +- cronjobs/manual_payout.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cronjobs/auto_payout.php b/cronjobs/auto_payout.php index 49984be6..5d646185 100755 --- a/cronjobs/auto_payout.php +++ b/cronjobs/auto_payout.php @@ -70,7 +70,7 @@ if (! empty($users)) { // Send balance, fees are reduced later by RPC Server try { - $bitcoin->sendtoaddress($aUserData['coin_address'], $dBalance); + $bitcoin->sendtoaddress($aUserData['coin_address'], $dBalance - $config['txfee']); } catch (BitcoinClientException $e) { $log->logError('Failed to send requested balance to coin address, please check payout process'); continue; diff --git a/cronjobs/manual_payout.php b/cronjobs/manual_payout.php index 4624fc93..094d4c02 100755 --- a/cronjobs/manual_payout.php +++ b/cronjobs/manual_payout.php @@ -62,7 +62,7 @@ if (count($aPayouts) > 0) { continue; } try { - $bitcoin->sendtoaddress($aData['coin_address'], $dBalance); + $bitcoin->sendtoaddress($aData['coin_address'], $dBalance - $config['txfee']); } catch (BitcoinClientException $e) { $log->logError('Failed to send requested balance to coin address, please check payout process'); continue; From fafd75d994f58cca91ec0bdaa7b8f01d36d2d9b8 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 7 Aug 2013 08:59:22 +0200 Subject: [PATCH 03/30] Honor anonymous flag on mobile template Fixes #535 --- public/templates/mobile/statistics/blocks/default.tpl | 2 +- public/templates/mobile/statistics/blocks/small_table.tpl | 2 +- .../mobile/statistics/pool/contributors_hashrate.tpl | 2 +- .../mobile/statistics/pool/contributors_shares.tpl | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/public/templates/mobile/statistics/blocks/default.tpl b/public/templates/mobile/statistics/blocks/default.tpl index b4f29b00..e4aa759a 100644 --- a/public/templates/mobile/statistics/blocks/default.tpl +++ b/public/templates/mobile/statistics/blocks/default.tpl @@ -53,7 +53,7 @@ target and network difficulty and assuming a zero variance scenario. {else if $BLOCKSFOUND[block].confirmations == -1} Orphan {else}{$GLOBAL.confirmations - $BLOCKSFOUND[block].confirmations} left{/if} - {$BLOCKSFOUND[block].finder|default:"unknown"} + {if $BLOCKSFOUND[block].is_anonymous|default:"0" == 1}anonymous{else}{$BLOCKSFOUND[block].finder|default:"unknown"|escape}{/if} {$BLOCKSFOUND[block].time|date_format:"%d/%m %H:%M:%S"} {$BLOCKSFOUND[block].difficulty|number_format:"2"} {(pow(2,32 - $GLOBAL.config.targetdiff) * $BLOCKSFOUND[block].difficulty)|number_format} diff --git a/public/templates/mobile/statistics/blocks/small_table.tpl b/public/templates/mobile/statistics/blocks/small_table.tpl index 2cfac05a..9ed3ec74 100644 --- a/public/templates/mobile/statistics/blocks/small_table.tpl +++ b/public/templates/mobile/statistics/blocks/small_table.tpl @@ -13,7 +13,7 @@ {section block $BLOCKSFOUND} {$BLOCKSFOUND[block].height} - {$BLOCKSFOUND[block].finder|default:"unknown"} + {if $BLOCKSFOUND[block].is_anonymous|default:"0" == 1}anonymous{else}{$BLOCKSFOUND[block].finder|default:"unknown"|escape}{/if} {$BLOCKSFOUND[block].time|date_format:"%d/%m %H:%M"} {$BLOCKSFOUND[block].shares|number_format} diff --git a/public/templates/mobile/statistics/pool/contributors_hashrate.tpl b/public/templates/mobile/statistics/pool/contributors_hashrate.tpl index 15fae80a..811e20a7 100644 --- a/public/templates/mobile/statistics/pool/contributors_hashrate.tpl +++ b/public/templates/mobile/statistics/pool/contributors_hashrate.tpl @@ -16,7 +16,7 @@ {if $GLOBAL.userdata.username == $CONTRIBSHARES[contrib].account}{assign var=listed value=1}{/if} {$rank++} - {$CONTRIBHASHES[contrib].account} + {if $CONTRIBHASHES[contrib].is_anonymous|default:"0" == 1}anonymous{else}{$CONTRIBHASHES[contrib].account|escape}{/if} {$CONTRIBHASHES[contrib].hashrate|number_format} {$estday|number_format:"3"} {($estday * $GLOBAL.price)|default:"n/a"|number_format:"2"} diff --git a/public/templates/mobile/statistics/pool/contributors_shares.tpl b/public/templates/mobile/statistics/pool/contributors_shares.tpl index e23b3998..1025a28f 100644 --- a/public/templates/mobile/statistics/pool/contributors_shares.tpl +++ b/public/templates/mobile/statistics/pool/contributors_shares.tpl @@ -9,12 +9,12 @@ {assign var=rank value=1} {assign var=listed value=0} -{section hashrate $CONTRIBSHARES} -{if $GLOBAL.userdata.username == $CONTRIBSHARES[hashrate].account}{assign var=listed value=1}{/if} +{section shares $CONTRIBSHARES} +{if $GLOBAL.userdata.username == $CONTRIBSHARES[shares].account}{assign var=listed value=1}{/if} {$rank++} - {$CONTRIBSHARES[hashrate].account} - {$CONTRIBSHARES[hashrate].shares|number_format} + {if $CONTRIBSHARES[shares].is_anonymous|default:"0" == 1}anonymous{else}{$CONTRIBSHARES[shares].account|escape}{/if} + {$CONTRIBSHARES[shares].shares|number_format} {/section} {if $listed != 1} From 073a42cfc8b49c856cf72b7711c4aae161d24860 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 7 Aug 2013 09:20:08 +0200 Subject: [PATCH 04/30] Fixing worker hashrates and activity status * Fix hashrate calculations and include archived shares * Fix worker activity to only check for our_result = Y shares * Mark as active if worker has a hashrate > 0, removes a query Addresses #561, crons need to be updated to remove the active flag from as the worker activity and check the hashrate instead. --- public/include/classes/worker.class.php | 41 +++++++++++++++---- .../mmcFE/account/workers/default.tpl | 4 +- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/public/include/classes/worker.class.php b/public/include/classes/worker.class.php index 7643a6d1..a049f8ea 100644 --- a/public/include/classes/worker.class.php +++ b/public/include/classes/worker.class.php @@ -95,15 +95,27 @@ class Worker { $this->debug->append("STA " . __METHOD__, 4); $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(COUNT(id) * POW(2, " . $this->config['difficulty'] . ")/600/1000) FROM " . $this->share->getTableName() . " WHERE username = $this->table.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)) AS hashrate - FROM $this->table + ( + SELECT + IFNULL(IF(our_result='Y', ROUND(COUNT(id) * POW(2, " . $this->config['difficulty'] . ") / 600 / 1000), 0), 0) AS hashrate + FROM " . $this->share->getTableName() . " + WHERE + username = w.username + AND time > DATE_SUB(now(), INTERVAL 10 MINUTE) + ) + ( + SELECT + IFNULL(IF(our_result='Y', ROUND(COUNT(id) * POW(2, " . $this->config['difficulty'] . ") / 600 / 1000), 0), 0) AS hashrate + FROM " . $this->share->getArchiveTableName() . " + WHERE + username = w.username + AND time > DATE_SUB(now(), INTERVAL 10 MINUTE) + ) AS hashrate + FROM $this->table AS w WHERE id = ? "); if ($this->checkStmt($stmt) && $stmt->bind_param('i', $id) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_assoc(); // Catchall - echo $this->mysqli->error; return false; } @@ -116,9 +128,22 @@ class Worker { $this->debug->append("STA " . __METHOD__, 4); $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(COUNT(id) * POW(2, " . $this->config['difficulty'] . ")/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 + ( + SELECT + IFNULL(IF(our_result='Y', ROUND(COUNT(id) * POW(2, " . $this->config['difficulty'] . ") / 600 / 1000), 0), 0) AS hashrate + FROM " . $this->share->getTableName() . " + WHERE + username = w.username + AND time > DATE_SUB(now(), INTERVAL 10 MINUTE) + ) + ( + SELECT + IFNULL(IF(our_result='Y', ROUND(COUNT(id) * POW(2, " . $this->config['difficulty'] . ") / 600 / 1000), 0), 0) AS hashrate + FROM " . $this->share->getArchiveTableName() . " + WHERE + username = w.username + AND time > DATE_SUB(now(), INTERVAL 10 MINUTE) + ) AS hashrate + FROM $this->table AS w WHERE account_id = ?"); if ($this->checkStmt($stmt) && $stmt->bind_param('i', $account_id) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_all(MYSQLI_ASSOC); @@ -135,7 +160,7 @@ class Worker { **/ public function getCountAllActiveWorkers() { $this->debug->append("STA " . __METHOD__, 4); - $stmt = $this->mysqli->prepare("SELECT IFNULL(COUNT(DISTINCT username), 0) AS total FROM " . $this->share->getTableName() . " WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE)"); + $stmt = $this->mysqli->prepare("SELECT IFNULL(IF(our_result='Y', COUNT(DISTINCT username), 0), 0) AS total FROM " . $this->share->getTableName() . " WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE)"); if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_object()->total; return false; diff --git a/public/templates/mmcFE/account/workers/default.tpl b/public/templates/mmcFE/account/workers/default.tpl index 85862cf5..65635b4b 100644 --- a/public/templates/mmcFE/account/workers/default.tpl +++ b/public/templates/mmcFE/account/workers/default.tpl @@ -19,9 +19,9 @@ {section worker $WORKERS} {assign var="username" value="."|escape|explode:$WORKERS[worker].username:2} - {$username.0|escape}. + 0} style="color: orange"{/if}>{$username.0|escape}. - + {if $GLOBAL.config.disable_notifications != 1} From cbf39f7905b2c24c20be35789a2fd93bfbff2326 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 7 Aug 2013 09:27:50 +0200 Subject: [PATCH 05/30] Fix IDLE worker detection * Also mark as IDLE if no valid shares were received Fixes #561 --- public/include/classes/worker.class.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/public/include/classes/worker.class.php b/public/include/classes/worker.class.php index a049f8ea..88999e1c 100644 --- a/public/include/classes/worker.class.php +++ b/public/include/classes/worker.class.php @@ -75,14 +75,15 @@ class Worker { $this->debug->append("STA " . __METHOD__, 4); $stmt = $this->mysqli->prepare(" SELECT account_id, id, username - FROM " . $this->table . " - WHERE monitor = 1 AND ( SELECT SIGN(COUNT(id)) FROM " . $this->share->getTableName() . " WHERE username = $this->table.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE)) = 0"); - + FROM " . $this->table . " AS w + WHERE monitor = 1 + AND ( + SELECT IFNULL(SIGN(IF(our_result = 'Y', COUNT(id), 0)), 0) FROM " . $this->share->getTableName() . " WHERE username = w.username AND time > DATE_SUB(now(), INTERVAL 10 MINUTE) + ) = 0"); if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) return $result->fetch_all(MYSQLI_ASSOC); // Catchall $this->setErrorMessage("Unable to fetch IDLE, monitored workers"); - echo $this->mysqli->error; return false; } From d5651764cd5b65c24e604747a6e4eb5b394861e3 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 8 Aug 2013 06:42:42 +0200 Subject: [PATCH 06/30] Update findblock.php * fixed typo --- cronjobs/findblock.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cronjobs/findblock.php b/cronjobs/findblock.php index 79dadeba..de18c3ce 100755 --- a/cronjobs/findblock.php +++ b/cronjobs/findblock.php @@ -59,7 +59,7 @@ if (empty($aTransactions['transactions'])) { $aData['difficulty'] . "\t" . strftime("%Y-%m-%d %H:%M:%S", $aData['time'])); if ( ! empty($aBlockInfo['flags']) && $aBlockInfo['flags'] == 'proof-of-stake' ) { - $logs->logInfo("Block above with height " . $aData['height'] . " not added to database, proof-of-stake block!"); + $log->logInfo("Block above with height " . $aData['height'] . " not added to database, proof-of-stake block!"); continue; } if (!$block->addBlock($aData) ) { From 03da52117a34b9c8e511fb37fd12dda324351493 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 8 Aug 2013 09:36:05 +0200 Subject: [PATCH 07/30] Fix user seeing other users transactions Fixes #577 --- public/include/classes/transaction.class.php | 26 +++++++++----------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/public/include/classes/transaction.class.php b/public/include/classes/transaction.class.php index 6da0ee49..3bb3e2a0 100644 --- a/public/include/classes/transaction.class.php +++ b/public/include/classes/transaction.class.php @@ -72,52 +72,50 @@ class Transaction extends Base { FROM $this->table AS t LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id LEFT JOIN " . $this->user->getTableName() . " AS a ON t.account_id = a.id"; + if (!empty($account_id)) { + $sql .= " WHERE ( t.account_id = ? ) "; + $this->addParam('i', $account_id); + } if (is_array($filter)) { $aFilter = array(); foreach ($filter as $key => $value) { if (!empty($value)) { switch ($key) { case 'type': - $aFilter[] = "t.type = ?"; + $aFilter[] = "( t.type = ? )"; $this->addParam('s', $value); break; case 'status': switch ($value) { case 'Confirmed': if (empty($filter['type']) || ($filter['type'] != 'Debit_AP' && $filter['type'] != 'Debit_MP' && $filter['type'] != 'TXFee' && $filter['type'] != 'Credit_PPS' && $filter['type'] != 'Fee_PPS' && $filter['type'] != 'Donation_PPS')) { - $aFilter[] = "b.confirmations >= " . $this->config['confirmations'] . " OR ISNULL(b.confirmations)"; + $aFilter[] = "( b.confirmations >= " . $this->config['confirmations'] . " OR ISNULL(b.confirmations) )"; } break; case 'Unconfirmed': - $aFilter[] = "b.confirmations < " . $this->config['confirmations'] . " AND b.confirmations >= 0"; + $aFilter[] = "( b.confirmations < " . $this->config['confirmations'] . " AND b.confirmations >= 0 )"; break; case 'Orphan': - $aFilter[] = "b.confirmations = -1"; + $aFilter[] = "( b.confirmations = -1 )"; break; } break; case 'account': - $aFilter[] = "LOWER(a.username) = LOWER(?)"; + $aFilter[] = "( LOWER(a.username) = LOWER(?) )"; $this->addParam('s', $value); break; case 'address': - $aFilter[] = "t.coin_address = ?"; + $aFilter[] = "( t.coin_address = ? )"; $this->addParam('s', $value); break; } } } if (!empty($aFilter)) { - $sql .= " WHERE " . implode(' AND ', $aFilter); + empty($account_id) ? $sql .= " WHERE " : $sql .= " AND "; + $sql .= implode(' AND ', $aFilter); } } - if (is_int($account_id) && empty($aFilter)) { - $sql .= " WHERE a.id = ?"; - $this->addParam('i', $account_id); - } else if (is_int($account_id)) { - $sql .= " AND a.id = ?"; - $this->addParam('i', $account_id); - } $sql .= " ORDER BY id DESC LIMIT ?,? From aad8271a13fc3cc430618a00043bc90a3d86436d Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 8 Aug 2013 09:42:10 +0200 Subject: [PATCH 08/30] Fix blockexplorer links to use blockhash not height Fixes #571 --- public/templates/mmcFE/statistics/blocks/default.tpl | 2 +- public/templates/mmcFE/statistics/blocks/small_table.tpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/templates/mmcFE/statistics/blocks/default.tpl b/public/templates/mmcFE/statistics/blocks/default.tpl index 2871cd01..72b3fc48 100644 --- a/public/templates/mmcFE/statistics/blocks/default.tpl +++ b/public/templates/mmcFE/statistics/blocks/default.tpl @@ -50,7 +50,7 @@ target and network difficulty and assuming a zero variance scenario. {assign var=rank value=1} {section block $BLOCKSFOUND} - {$BLOCKSFOUND[block].height} + {$BLOCKSFOUND[block].height} {if $BLOCKSFOUND[block].confirmations >= $GLOBAL.confirmations} Confirmed diff --git a/public/templates/mmcFE/statistics/blocks/small_table.tpl b/public/templates/mmcFE/statistics/blocks/small_table.tpl index 010b3557..7ddc03c8 100644 --- a/public/templates/mmcFE/statistics/blocks/small_table.tpl +++ b/public/templates/mmcFE/statistics/blocks/small_table.tpl @@ -13,7 +13,7 @@ {assign var=rank value=1} {section block $BLOCKSFOUND} - {$BLOCKSFOUND[block].height} + {$BLOCKSFOUND[block].height} {if $BLOCKSFOUND[block].is_anonymous|default:"0" == 1}anonymous{else}{$BLOCKSFOUND[block].finder|default:"unknown"|escape}{/if} {$BLOCKSFOUND[block].time|date_format:"%d/%m %H:%M:%S"} {$BLOCKSFOUND[block].shares|number_format} From 92623902b2d93675e42c2af520d9f6b29b934b03 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 8 Aug 2013 10:03:33 +0200 Subject: [PATCH 09/30] adding round shares back to PPS sidebar --- public/templates/mmcFE/global/sidebar_pps.tpl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/public/templates/mmcFE/global/sidebar_pps.tpl b/public/templates/mmcFE/global/sidebar_pps.tpl index 3fdc478a..1268880a 100644 --- a/public/templates/mmcFE/global/sidebar_pps.tpl +++ b/public/templates/mmcFE/global/sidebar_pps.tpl @@ -28,6 +28,10 @@ Pool Valid {$GLOBAL.roundshares.valid|number_format} + + Your Valid + {$GLOBAL.userdata.shares.valid|number_format} + Pool Invalid {$GLOBAL.roundshares.invalid|number_format}{if $GLOBAL.roundshares.valid > 0} ({($GLOBAL.roundshares.invalid / ($GLOBAL.roundshares.valid + $GLOBAL.roundshares.invalid) * 100)|number_format:"2"}%){/if} From 1a459a7913f9bc963ee3bfa1593a28d4b736d7af Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 8 Aug 2013 12:02:39 +0200 Subject: [PATCH 10/30] Adding transaction summary by types Addresses #581 --- public/include/classes/base.class.php | 3 ++ public/include/classes/transaction.class.php | 32 +++++++++++++++++++ .../pages/account/transactions.inc.php | 2 ++ .../include/pages/admin/transactions.inc.php | 2 ++ .../mmcFE/account/transactions/default.tpl | 19 +++++++++++ .../mmcFE/admin/transactions/default.tpl | 19 +++++++++++ 6 files changed, 77 insertions(+) diff --git a/public/include/classes/base.class.php b/public/include/classes/base.class.php index aea25d60..6dc88b02 100644 --- a/public/include/classes/base.class.php +++ b/public/include/classes/base.class.php @@ -103,6 +103,9 @@ class Base { } public function getParam() { $array = array_merge(array($this->types), $this->values); + // Clear the data + $this->values = NULL; + $this->types = NULL; // See here why we need this: http://stackoverflow.com/questions/16120822/mysqli-bind-param-expected-to-be-a-reference-value-given if (strnatcmp(phpversion(),'5.3') >= 0) { $refs = array(); diff --git a/public/include/classes/transaction.class.php b/public/include/classes/transaction.class.php index 3bb3e2a0..b706f7e4 100644 --- a/public/include/classes/transaction.class.php +++ b/public/include/classes/transaction.class.php @@ -47,6 +47,38 @@ class Transaction extends Base { return false; } + /** + * Fetch a transaction summary by type with total amounts + * @param account_id int Account ID, NULL for all + * @return data array type and total + **/ + public function getTransactionSummary($account_id=NULL) { + $sql = "SELECT SUM(t.amount) AS total, t.type AS type FROM $this->table AS t"; + if (!empty($account_id)) { + $sql .= " WHERE t.account_id = ? "; + $this->addParam('i', $account_id); + } + $sql .= " GROUP BY t.type"; + $stmt = $this->mysqli->prepare($sql); + if (!empty($account_id)) { + if (!($this->checkStmt($stmt) && call_user_func_array( array($stmt, 'bind_param'), $this->getParam()) && $stmt->execute())) + return false; + $result = $stmt->get_result(); + } else { + if (!($this->checkStmt($stmt) && $stmt->execute())) + return false; + $result = $stmt->get_result(); + } + if ($result) { + $aData = NULL; + while ($row = $result->fetch_assoc()) { + $aData[$row['type']] = $row['total']; + } + return $aData; + } + return false; + } + /** * Get all transactions from start for account_id * @param start int Starting point, id of transaction diff --git a/public/include/pages/account/transactions.inc.php b/public/include/pages/account/transactions.inc.php index bd8f2aa4..a06eae61 100644 --- a/public/include/pages/account/transactions.inc.php +++ b/public/include/pages/account/transactions.inc.php @@ -6,11 +6,13 @@ if ($user->isAuthenticated()) { $iLimit = 30; empty($_REQUEST['start']) ? $start = 0 : $start = $_REQUEST['start']; $aTransactions = $transaction->getTransactions($start, @$_REQUEST['filter'], $iLimit, $_SESSION['USERDATA']['id']); + $aTransactionSummary = $transaction->getTransactionSummary($_SESSION['USERDATA']['id']); $iCountTransactions = $transaction->num_rows; $aTransactionTypes = $transaction->getTypes(); if (!$aTransactions) $_SESSION['POPUP'][] = array('CONTENT' => 'Could not find any transaction', 'TYPE' => 'errormsg'); $smarty->assign('LIMIT', $iLimit); $smarty->assign('TRANSACTIONS', $aTransactions); + $smarty->assign('SUMMARY', $aTransactionSummary); $smarty->assign('TRANSACTIONTYPES', $aTransactionTypes); $smarty->assign('TXSTATUS', array('' => '', 'Confirmed' => 'Confirmed', 'Unconfirmed' => 'Unconfirmed', 'Orphan' => 'Orphan')); $smarty->assign('COUNTTRANSACTIONS', $iCountTransactions); diff --git a/public/include/pages/admin/transactions.inc.php b/public/include/pages/admin/transactions.inc.php index 505f25ab..92cdd2d8 100644 --- a/public/include/pages/admin/transactions.inc.php +++ b/public/include/pages/admin/transactions.inc.php @@ -14,11 +14,13 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { $debug->append('No cached version available, fetching from backend', 3); empty($_REQUEST['start']) ? $start = 0 : $start = $_REQUEST['start']; $aTransactions = $transaction->getTransactions($start, @$_REQUEST['filter'], $iLimit); + $aTransactionSummary = $transaction->getTransactionSummary($_SESSION['USERDATA']['id']); $iCountTransactions = $transaction->num_rows; $aTransactionTypes = $transaction->getTypes(); if (!$aTransactions) $_SESSION['POPUP'][] = array('CONTENT' => 'Could not find any transaction', 'TYPE' => 'errormsg'); $smarty->assign('LIMIT', $iLimit); $smarty->assign('TRANSACTIONS', $aTransactions); + $smarty->assign('SUMMARY', $aTransactionSummary); $smarty->assign('TRANSACTIONTYPES', $aTransactionTypes); $smarty->assign('TXSTATUS', array('' => '', 'Confirmed' => 'Confirmed', 'Unconfirmed' => 'Unconfirmed', 'Orphan' => 'Orphan')); $smarty->assign('COUNTTRANSACTIONS', $iCountTransactions); diff --git a/public/templates/mmcFE/account/transactions/default.tpl b/public/templates/mmcFE/account/transactions/default.tpl index 5563aee4..62a32a17 100644 --- a/public/templates/mmcFE/account/transactions/default.tpl +++ b/public/templates/mmcFE/account/transactions/default.tpl @@ -1,3 +1,22 @@ +{include file="global/block_header.tpl" BLOCK_HEADER="Transaction Summary"} + + + + {foreach $SUMMARY as $type=>$total} + + {/foreach} + + + + + {foreach $SUMMARY as $type=>$total} + + {/foreach} + + +
{$type}
{$total}
+{include file="global/block_footer.tpl"} + {include file="global/block_header.tpl" ALIGN="left" BLOCK_STYLE="width: 23%" BLOCK_HEADER="Transaction Filter"}
diff --git a/public/templates/mmcFE/admin/transactions/default.tpl b/public/templates/mmcFE/admin/transactions/default.tpl index cbbc7e86..cc2693d9 100644 --- a/public/templates/mmcFE/admin/transactions/default.tpl +++ b/public/templates/mmcFE/admin/transactions/default.tpl @@ -1,3 +1,22 @@ +{include file="global/block_header.tpl" BLOCK_HEADER="Transaction Summary"} + + + + {foreach $SUMMARY as $type=>$total} + + {/foreach} + + + + + {foreach $SUMMARY as $type=>$total} + + {/foreach} + + +
{$type}
{$total}
+{include file="global/block_footer.tpl"} + {include file="global/block_header.tpl" ALIGN="left" BLOCK_STYLE="width: 23%" BLOCK_HEADER="Transaction Filter"} From 031b4940cdec89bc7a200e057198e79a76718a9d Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 8 Aug 2013 12:05:06 +0200 Subject: [PATCH 11/30] admin should see all transactions in summary --- public/include/pages/admin/transactions.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/include/pages/admin/transactions.inc.php b/public/include/pages/admin/transactions.inc.php index 92cdd2d8..5b544da6 100644 --- a/public/include/pages/admin/transactions.inc.php +++ b/public/include/pages/admin/transactions.inc.php @@ -14,7 +14,7 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { $debug->append('No cached version available, fetching from backend', 3); empty($_REQUEST['start']) ? $start = 0 : $start = $_REQUEST['start']; $aTransactions = $transaction->getTransactions($start, @$_REQUEST['filter'], $iLimit); - $aTransactionSummary = $transaction->getTransactionSummary($_SESSION['USERDATA']['id']); + $aTransactionSummary = $transaction->getTransactionSummary(); $iCountTransactions = $transaction->num_rows; $aTransactionTypes = $transaction->getTypes(); if (!$aTransactions) $_SESSION['POPUP'][] = array('CONTENT' => 'Could not find any transaction', 'TYPE' => 'errormsg'); From d42b66d94e589f307a22e9bd2ca11f5fe8b3a9eb Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 8 Aug 2013 12:09:50 +0200 Subject: [PATCH 12/30] removing useless strings --- public/templates/mmcFE/account/transactions/default.tpl | 4 ++-- public/templates/mmcFE/admin/transactions/default.tpl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/templates/mmcFE/account/transactions/default.tpl b/public/templates/mmcFE/account/transactions/default.tpl index 62a32a17..169e7de2 100644 --- a/public/templates/mmcFE/account/transactions/default.tpl +++ b/public/templates/mmcFE/account/transactions/default.tpl @@ -44,11 +44,11 @@ - TX Type + Type {html_options name="filter[type]" options=$TRANSACTIONTYPES selected=$smarty.request.filter.type|default:""} - TX Status + Status {html_options name="filter[status]" options=$TXSTATUS selected=$smarty.request.filter.status|default:""} diff --git a/public/templates/mmcFE/admin/transactions/default.tpl b/public/templates/mmcFE/admin/transactions/default.tpl index cc2693d9..cb066607 100644 --- a/public/templates/mmcFE/admin/transactions/default.tpl +++ b/public/templates/mmcFE/admin/transactions/default.tpl @@ -44,11 +44,11 @@ - TX Type + Type {html_options name="filter[type]" options=$TRANSACTIONTYPES selected=$smarty.request.filter.type|default:""} - TX Status + Status {html_options name="filter[status]" options=$TXSTATUS selected=$smarty.request.filter.status|default:""} From 7214d27d9e3db0f94a147e109a0476d666469963 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Fri, 9 Aug 2013 14:58:46 +0200 Subject: [PATCH 13/30] make blocks list sortable --- public/templates/mmcFE/statistics/blocks/default.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/templates/mmcFE/statistics/blocks/default.tpl b/public/templates/mmcFE/statistics/blocks/default.tpl index 72b3fc48..c305d5a1 100644 --- a/public/templates/mmcFE/statistics/blocks/default.tpl +++ b/public/templates/mmcFE/statistics/blocks/default.tpl @@ -32,7 +32,7 @@ target and network difficulty and assuming a zero variance scenario. {include file="global/block_header.tpl" BLOCK_HEADER="Last $BLOCKLIMIT Blocks Found" BLOCK_STYLE="clear:none;"}
- +
From 581888fe1fa8b84a23d3d8284712ca21ca01be30 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 12 Aug 2013 08:45:25 +0200 Subject: [PATCH 14/30] Update POOLS.md --- POOLS.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/POOLS.md b/POOLS.md index f8321f31..21c0f83f 100644 --- a/POOLS.md +++ b/POOLS.md @@ -96,3 +96,9 @@ Small Time Miners are running various stratum only pools for different coins. | -------- | ---- | ------------: | ------------------: | ----- | | http://www.litecoinfor.me | Litecoin | 0 | 0 | | | http://www.fastcoinfor.me | Fastcoin | 0.830 MHash | 2 | | + +### ZC + +| Pool URL | Coin | Avg. Hashrate | Avg. Active Workers | Notes | +| -------- | ---- | ------------: | ------------------: | ----- | +| https://ltc.hashfaster.com | LTC | 70 MHash | 80 | Custom Template | From f3a0cf04178bc19f40e19385ebaa0367b02ff5d3 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 12 Aug 2013 09:35:45 +0200 Subject: [PATCH 15/30] Fixing PPLNS payouts when exceeding target Round shares are taken to only match PPLNS target. Round target was not re-adjusted to reflect the new, lower amount of round shares. * Fix: Properly adjust round target shares when exceeding PPLNS target Fixes #588 once merged --- cronjobs/pplns_payout.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/cronjobs/pplns_payout.php b/cronjobs/pplns_payout.php index d6d00c9d..c71f5659 100755 --- a/cronjobs/pplns_payout.php +++ b/cronjobs/pplns_payout.php @@ -73,6 +73,8 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { $monitoring->setStatus($cron_name . "_status", "okerror", 1); exit(1); } + $log->logInfo('Adjusting round target to PPLNS target ' . $pplns_target); + $iRoundShares = $pplns_target; } else { $log->logDebug("Not able to match PPLNS target of $pplns_target with $iRoundShares"); // We need to fill up with archived shares @@ -124,26 +126,26 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { // Loop through all accounts that have found shares for this round foreach ($aAccountShares as $key => $aData) { // Payout based on PPLNS target shares, proportional payout for all users - $aData['percentage'] = number_format(round(( 100 / $iRoundShares) * $aData['valid'], 8), 8); - $aData['payout'] = number_format(round(( $aData['percentage'] / 100 ) * $dReward, 8), 8); + $aData['percentage'] = round(( 100 / $iRoundShares) * $aData['valid'], 8); + $aData['payout'] = round(( $aData['percentage'] / 100 ) * $dReward, 8); // Defaults $aData['fee' ] = 0; $aData['donation'] = 0; if ($config['fees'] > 0 && $aData['no_fees'] == 0) - $aData['fee'] = number_format(round($config['fees'] / 100 * $aData['payout'], 8), 8); + $aData['fee'] = round($config['fees'] / 100 * $aData['payout'], 8); // Calculate donation amount, fees not included - $aData['donation'] = number_format(round($user->getDonatePercent($user->getUserId($aData['username'])) / 100 * ( $aData['payout'] - $aData['fee']), 8), 8); + $aData['donation'] = round($user->getDonatePercent($user->getUserId($aData['username'])) / 100 * ( $aData['payout'] - $aData['fee']), 8); // Verbose output of this users calculations $log->logInfo($aData['id'] . "\t" . $aData['username'] . "\t" . $aData['valid'] . "\t" . $aData['invalid'] . "\t" . - $aData['percentage'] . "\t" . - $aData['payout'] . "\t" . - $aData['donation'] . "\t" . - $aData['fee']); + number_format($aData['percentage'], 8) . "\t" . + number_format($aData['payout'], 8) . "\t" . + number_format($aData['donation'], 8) . "\t" . + number_format($aData['fee'], 8)); // Add full round share statistics, not just PPLNS foreach ($aRoundAccountShares as $key => $aRoundData) { From 85e22bc02f2a9fabb4e57eb47d1513ceaf45ddce Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 12 Aug 2013 10:07:19 +0200 Subject: [PATCH 16/30] Adding totals to block statistics * Total expected shares * Total actual shares * Average Percentage --- public/templates/mmcFE/statistics/blocks/default.tpl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/public/templates/mmcFE/statistics/blocks/default.tpl b/public/templates/mmcFE/statistics/blocks/default.tpl index c305d5a1..47f610c5 100644 --- a/public/templates/mmcFE/statistics/blocks/default.tpl +++ b/public/templates/mmcFE/statistics/blocks/default.tpl @@ -49,6 +49,7 @@ target and network difficulty and assuming a zero variance scenario. {assign var=rank value=1} {section block $BLOCKSFOUND} + {assign var="totalshares" value=$totalshares+$BLOCKSFOUND[block].shares} @@ -72,6 +74,13 @@ target and network difficulty and assuming a zero variance scenario. {/section} + + + + + {math assign="totalpercentage" equation="shares / estshares * 100" shares=$totalshares estshares=$totalexpectedshares} +
Block
{$BLOCKSFOUND[block].height} @@ -63,6 +64,7 @@ target and network difficulty and assuming a zero variance scenario. {$BLOCKSFOUND[block].amount|number_format:"2"} {math assign="estshares" equation="(pow(2,32 - targetdiff) * blockdiff)" targetdiff=$GLOBAL.config.targetdiff blockdiff=$BLOCKSFOUND[block].difficulty} + {assign var="totalexpectedshares" value=$totalexpectedshares+$estshares} {$estshares|number_format} {$BLOCKSFOUND[block].shares|number_format}
Totals{$totalexpectedshares|number_format}{$totalshares|number_format}{$totalpercentage|number_format:"2"} +
From 80d2cda39905638249e87da519220eb7692deae7 Mon Sep 17 00:00:00 2001 From: Nicolas Schteinschraber Date: Mon, 12 Aug 2013 22:55:40 -0300 Subject: [PATCH 17/30] Sustract fee to manual_payout cron too. --- cronjobs/manual_payout.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cronjobs/manual_payout.php b/cronjobs/manual_payout.php index fbd4d927..41b1629a 100755 --- a/cronjobs/manual_payout.php +++ b/cronjobs/manual_payout.php @@ -62,7 +62,7 @@ if (count($aPayouts) > 0) { continue; } try { - $bitcoin->sendtoaddress($aData['coin_address'], $dBalance); + $bitcoin->sendtoaddress($aData['coin_address'], $dBalance - $config['txfee']); } catch (BitcoinClientException $e) { $log->logError('Failed to send requested balance to coin address, please check payout process'); continue; From 22e7904da7e798212975bce70a88f6122e2c45d6 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 13 Aug 2013 09:20:06 +0200 Subject: [PATCH 18/30] Fixing round estimates on public stats page * Fix: Display round restimates when making pool stats public via ACL * Fix: Display proper pool efficiency when pool stats are public Fixes #585 --- public/include/smarty_globals.inc.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index 64dcf2dc..7ddeb583 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -12,14 +12,13 @@ $dDifficulty = 1; $aRoundShares = 1; // Only run these if the user is logged in -if (@$_SESSION['AUTHENTICATED']) { - $aRoundShares = $statistics->getRoundShares(); - if ($bitcoin->can_connect() === true) { - $dDifficulty = $bitcoin->query('getdifficulty'); - if (is_array($dDifficulty) && array_key_exists('proof-of-work', $dDifficulty)) - $dDifficulty = $dDifficulty['proof-of-work']; - } +$aRoundShares = $statistics->getRoundShares(); +if ($bitcoin->can_connect() === true) { + $dDifficulty = $bitcoin->query('getdifficulty'); + if (is_array($dDifficulty) && array_key_exists('proof-of-work', $dDifficulty)) + $dDifficulty = $dDifficulty['proof-of-work']; } + // Always fetch this since we need for ministats header $bitcoin->can_connect() === true ? $dNetworkHashrate = $bitcoin->query('getnetworkhashps') : $dNetworkHashrate = 0; From c0e84595196045bf3648bd7e2088c3fc21f18ad6 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 14 Aug 2013 10:59:50 +0200 Subject: [PATCH 19/30] fix coloring of total percentage --- public/templates/mmcFE/statistics/blocks/default.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/templates/mmcFE/statistics/blocks/default.tpl b/public/templates/mmcFE/statistics/blocks/default.tpl index 47f610c5..eea09ffb 100644 --- a/public/templates/mmcFE/statistics/blocks/default.tpl +++ b/public/templates/mmcFE/statistics/blocks/default.tpl @@ -79,7 +79,7 @@ target and network difficulty and assuming a zero variance scenario. {$totalexpectedshares|number_format} {$totalshares|number_format} {math assign="totalpercentage" equation="shares / estshares * 100" shares=$totalshares estshares=$totalexpectedshares} - {$totalpercentage|number_format:"2"} + {$totalpercentage|number_format:"2"} From 0679601fbdf97b4a346bbaa8d2a0bf41076b65f2 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 14 Aug 2013 11:03:56 +0200 Subject: [PATCH 20/30] Initilize totals with 0 values Addresses #596 --- public/templates/mmcFE/statistics/blocks/default.tpl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/public/templates/mmcFE/statistics/blocks/default.tpl b/public/templates/mmcFE/statistics/blocks/default.tpl index eea09ffb..fb2a799d 100644 --- a/public/templates/mmcFE/statistics/blocks/default.tpl +++ b/public/templates/mmcFE/statistics/blocks/default.tpl @@ -48,6 +48,8 @@ target and network difficulty and assuming a zero variance scenario. {assign var=rank value=1} +{assign var=totalexpectedshares value=0} +{assign var=totalshares value=0} {section block $BLOCKSFOUND} {assign var="totalshares" value=$totalshares+$BLOCKSFOUND[block].shares} From 567b8e165554a2abd9ca3fa92eb15d7d133a02bd Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 14 Aug 2013 11:10:58 +0200 Subject: [PATCH 21/30] Fix rounding issues on total row * Use actual percentages to calculate the total to ensure the rows average matches the totals average Fixes #596 --- public/templates/mmcFE/statistics/blocks/default.tpl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/public/templates/mmcFE/statistics/blocks/default.tpl b/public/templates/mmcFE/statistics/blocks/default.tpl index fb2a799d..87b9ecb5 100644 --- a/public/templates/mmcFE/statistics/blocks/default.tpl +++ b/public/templates/mmcFE/statistics/blocks/default.tpl @@ -47,11 +47,13 @@ target and network difficulty and assuming a zero variance scenario. -{assign var=rank value=1} +{assign var=count value=0} {assign var=totalexpectedshares value=0} {assign var=totalshares value=0} +{assign var=totalpercentage value=0} {section block $BLOCKSFOUND} {assign var="totalshares" value=$totalshares+$BLOCKSFOUND[block].shares} + {assign var="count" value=$count+1} {$BLOCKSFOUND[block].height} @@ -72,6 +74,7 @@ target and network difficulty and assuming a zero variance scenario. {$BLOCKSFOUND[block].shares|number_format} {math assign="percentage" equation="shares / estshares * 100" shares=$BLOCKSFOUND[block].shares estshares=$estshares} + {assign var="totalpercentage" value=$totalpercentage+$percentage} {$percentage|number_format:"2"} @@ -80,8 +83,7 @@ target and network difficulty and assuming a zero variance scenario. Totals {$totalexpectedshares|number_format} {$totalshares|number_format} - {math assign="totalpercentage" equation="shares / estshares * 100" shares=$totalshares estshares=$totalexpectedshares} - {$totalpercentage|number_format:"2"} + {($totalpercentage / $count)|number_format:"2"} From 184ad5d58bdae95c508fc8e2e8fd0b7f7ac5c047 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 14 Aug 2013 11:15:49 +0200 Subject: [PATCH 22/30] fixing color of total percentage again --- public/templates/mmcFE/statistics/blocks/default.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/templates/mmcFE/statistics/blocks/default.tpl b/public/templates/mmcFE/statistics/blocks/default.tpl index 87b9ecb5..8aeb21e6 100644 --- a/public/templates/mmcFE/statistics/blocks/default.tpl +++ b/public/templates/mmcFE/statistics/blocks/default.tpl @@ -83,7 +83,7 @@ target and network difficulty and assuming a zero variance scenario. Totals {$totalexpectedshares|number_format} {$totalshares|number_format} - {($totalpercentage / $count)|number_format:"2"} + {($totalpercentage / $count)|number_format:"2"} From a10b5099ce1cc8dfd5caaec7ffa7846e33350168 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 14 Aug 2013 11:21:21 +0200 Subject: [PATCH 23/30] Update POOLS.md Added @nutnut pools --- POOLS.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/POOLS.md b/POOLS.md index 21c0f83f..42ffd0b4 100644 --- a/POOLS.md +++ b/POOLS.md @@ -102,3 +102,12 @@ Small Time Miners are running various stratum only pools for different coins. | Pool URL | Coin | Avg. Hashrate | Avg. Active Workers | Notes | | -------- | ---- | ------------: | ------------------: | ----- | | https://ltc.hashfaster.com | LTC | 70 MHash | 80 | Custom Template | + +### nutnut + + +| Pool URL | Coin | Avg. Hashrate | Avg. Active Workers | Notes | +| -------- | ---- | ------------: | ------------------: | ----- | +| http://ftc.nut2pools.com | Feathercoin | 45-50Mhs | 25 workers | New style, PPLNS | +| http://wdc.nut2pools.com | Worldcoin | 3.5 Mhs | 3 workers | New style, PPLNS | +| http://pxc.nut2pools.com | Phenixcoin | 0 | 0 | New style | PPLNS | From e5cb4d0886cb2e533c2736ff3d3570a8033156e0 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 14 Aug 2013 11:23:14 +0200 Subject: [PATCH 24/30] Fixing combined hashrate graph This shouuld fix #598 with graphs being completely off --- public/templates/mmcFE/statistics/graphs/both.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/templates/mmcFE/statistics/graphs/both.tpl b/public/templates/mmcFE/statistics/graphs/both.tpl index 03832b5f..878a5b4d 100644 --- a/public/templates/mmcFE/statistics/graphs/both.tpl +++ b/public/templates/mmcFE/statistics/graphs/both.tpl @@ -29,7 +29,7 @@ {$POOLHASHRATES.$i|default:"0"} {/for} {for $i=0 to date('G', time() - 60 * 60)} - {$POOLHASHRATES.$i - $YOURHASHRATES.$i|default:"0"} + {$POOLHASHRATES.$i|default:"0"} {/for} From ad6ceed77ec6169e6d42cb76c0ea7dd9a594a458 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 14 Aug 2013 11:47:46 +0200 Subject: [PATCH 25/30] fixing worker activity on mobile template --- public/templates/mobile/account/workers/default.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/templates/mobile/account/workers/default.tpl b/public/templates/mobile/account/workers/default.tpl index 0e171ba6..09ebf867 100644 --- a/public/templates/mobile/account/workers/default.tpl +++ b/public/templates/mobile/account/workers/default.tpl @@ -9,7 +9,7 @@ {assign var="username" value="."|escape|explode:$WORKERS[worker].username:2} {$username.0|escape}.{$username.1|escape} - + {$WORKERS[worker].hashrate|number_format} {/section} From 020d1ef01b13afa0418f82c6e1c299788c632ff5 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 14 Aug 2013 11:48:41 +0200 Subject: [PATCH 26/30] Fixing notification reset for active workers Fixes #600 --- cronjobs/notifications.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cronjobs/notifications.php b/cronjobs/notifications.php index c3f2f29c..4a8931d6 100755 --- a/cronjobs/notifications.php +++ b/cronjobs/notifications.php @@ -58,7 +58,7 @@ if (!empty($aNotifications)) { $aData = json_decode($aNotification['data'], true); $aWorker = $worker->getWorker($aData['id']); $log->logInfo(" " . $aWorker['username'] . " ..."); - if ($aWorker['active'] == 1) { + if ($aWorker['hashrate'] > 0) { if ($notification->setInactive($aNotification['id'])) { $log->logInfo(" updated #" . $aNotification['id'] . " for " . $aWorker['username'] . " as inactive\n"); } else { From 50f380c25e2716668f7b8a90aa8ca7371e617996 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 15 Aug 2013 09:14:02 +0200 Subject: [PATCH 27/30] first test to fill with data --- public/include/classes/statistics.class.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index 1452db89..70a2e986 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -406,6 +406,17 @@ class Statistics { while ($row = $result->fetch_assoc()) { $aData[$row['hour']] = $row['hashrate']; } + // We have no data, so we fill with 0 + if (empty($aData)) { + for ($i = 0; $i <= 24; $i++) $aData[$i] = 0; + } else { + $count = -1; + foreach ($aData as $hour => $hashrate) { + $count++; + if ($count == $hour) continue; + $aData[$count] = 0; + } + } return $this->memcache->setCache(__FUNCTION__ . $account_id, $aData); } // Catchall From 14c0535b106a8b13bcd5bcd807a5dab0efd8f6a0 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 15 Aug 2013 09:58:33 +0200 Subject: [PATCH 28/30] Fill empty hours with proper data * Properly sort the array prior to sending it back * Sort from current to one hour earlier for proper data display * Adjusted templates to use new sorted arrays Fixes #606 --- public/include/classes/statistics.class.php | 30 +++++++------------ .../mmcFE/statistics/graphs/both.tpl | 27 ++++++----------- .../mmcFE/statistics/graphs/mine.tpl | 18 ++++------- .../mmcFE/statistics/graphs/pool.tpl | 18 ++++------- 4 files changed, 32 insertions(+), 61 deletions(-) diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index 70a2e986..d61222b0 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -402,21 +402,11 @@ class Statistics { AND a.id = ? GROUP BY HOUR(time)"); if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $account_id, $account_id) && $stmt->execute() && $result = $stmt->get_result()) { - $aData = array(); - while ($row = $result->fetch_assoc()) { - $aData[$row['hour']] = $row['hashrate']; - } - // We have no data, so we fill with 0 - if (empty($aData)) { - for ($i = 0; $i <= 24; $i++) $aData[$i] = 0; - } else { - $count = -1; - foreach ($aData as $hour => $hashrate) { - $count++; - if ($count == $hour) continue; - $aData[$count] = 0; - } - } + $iStartHour = date('G'); + for ($i = $iStartHour; $i <= 24; $i++) $aData[$i] = 0; + while ($row = $result->fetch_assoc()) $aData[$row['hour']] = $row['hashrate']; + // Fill any non-existing hours with 0 hashrate + for ($i = 0; $i <= 24; $i++) if (!array_key_exists($i, $aData)) $aData[$i] = 0; return $this->memcache->setCache(__FUNCTION__ . $account_id, $aData); } // Catchall @@ -449,10 +439,12 @@ class Statistics { AND time > NOW() - INTERVAL 25 HOUR GROUP BY HOUR(time)"); if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) { - while ($row = $result->fetch_assoc()) { - $aData[$row['hour']] = $row['hashrate']; - } - return $this->memcache->setCache(__FUNCTION__, @$aData); + $iStartHour = date('G'); + for ($i = $iStartHour; $i <= 24; $i++) $aData[$i] = 0; + while ($row = $result->fetch_assoc()) $aData[$row['hour']] = (int) $row['hashrate']; + // Fill any non-existing hours with 0 hashrate + for ($i = 0; $i <= 24; $i++) if (!array_key_exists($i, $aData)) $aData[$i] = 0; + return $this->memcache->setCache(__FUNCTION__, $aData); } // Catchall $this->debug->append("Failed to fetch hourly hashrate: " . $this->mysqli->error); diff --git a/public/templates/mmcFE/statistics/graphs/both.tpl b/public/templates/mmcFE/statistics/graphs/both.tpl index 878a5b4d..a8011e90 100644 --- a/public/templates/mmcFE/statistics/graphs/both.tpl +++ b/public/templates/mmcFE/statistics/graphs/both.tpl @@ -5,32 +5,23 @@ -{for $i=date('G') to 23} - {$i}:00 -{/for} -{for $i=0 to date('G', time () - 60 * 60)} - {$i}:00 -{/for} +{foreach $YOURHASHRATES as $hour=>$hashrate} + {$hour|default:"0"}:00 +{/foreach} {$smarty.session.USERDATA.username} -{for $i=date('G') to 23} - {$YOURHASHRATES.$i|default:"0"} -{/for} -{for $i=0 to date('G', time() - 60 * 60)} - {$YOURHASHRATES.$i|default:"0"} -{/for} +{foreach $YOURHASHRATES as $hour=>$hashrate} + {$hashrate|default:"0"} +{/foreach} Pool -{for $i=date('G') to 23} - {$POOLHASHRATES.$i|default:"0"} -{/for} -{for $i=0 to date('G', time() - 60 * 60)} - {$POOLHASHRATES.$i|default:"0"} -{/for} +{foreach $POOLHASHRATES as $hour=>$hashrate} + {$hashrate|default:"0"} +{/foreach} diff --git a/public/templates/mmcFE/statistics/graphs/mine.tpl b/public/templates/mmcFE/statistics/graphs/mine.tpl index 4d4259f2..05c8e2b1 100644 --- a/public/templates/mmcFE/statistics/graphs/mine.tpl +++ b/public/templates/mmcFE/statistics/graphs/mine.tpl @@ -5,23 +5,17 @@ -{for $i=date('G') to 23} - {$i}:00 -{/for} -{for $i=0 to date('G', time () - 60 * 60)} - {$i}:00 -{/for} +{foreach $YOURHASHRATES as $hour=>$hashrate} + {$hour|default:"0"}:00 +{/foreach} {$smarty.session.USERDATA.username} -{for $i=date('G') to 23} - {$YOURHASHRATES.$i|default:"0"} -{/for} -{for $i=0 to date('G', time() - 60 * 60)} - {$YOURHASHRATES.$i|default:"0"} -{/for} +{foreach $YOURHASHRATES as $hour=>$hashrate} + {$hashrate|default:"0"} +{/foreach} diff --git a/public/templates/mmcFE/statistics/graphs/pool.tpl b/public/templates/mmcFE/statistics/graphs/pool.tpl index f8d118c7..704dd2bf 100644 --- a/public/templates/mmcFE/statistics/graphs/pool.tpl +++ b/public/templates/mmcFE/statistics/graphs/pool.tpl @@ -5,23 +5,17 @@ -{for $i=date('G') to 23} - {$i}:00 -{/for} -{for $i=0 to date('G', time () - 60 * 60)} - {$i}:00 -{/for} +{foreach $POOLHASHRATES as $hour=>$hashrate} + {$hour|default:"0"}:00 +{/foreach} Pool -{for $i=date('G') to 23} - {$POOLHASHRATES.$i|default:"0"} -{/for} -{for $i=0 to date('G', time() - 60 * 60)} - {$POOLHASHRATES.$i|default:"0"} -{/for} +{foreach $POOLHASHRATES as $hour=>$hashrate} + {$hashrate|default:"0"} +{/foreach} From 1708e5d2b5d5077fb6c06b531a78c4946dfa3321 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Thu, 15 Aug 2013 10:03:22 +0200 Subject: [PATCH 29/30] Do not add 24th hour, use 0 hour --- public/include/classes/statistics.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/public/include/classes/statistics.class.php b/public/include/classes/statistics.class.php index d61222b0..e4e06167 100644 --- a/public/include/classes/statistics.class.php +++ b/public/include/classes/statistics.class.php @@ -403,10 +403,10 @@ class Statistics { GROUP BY HOUR(time)"); if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $account_id, $account_id) && $stmt->execute() && $result = $stmt->get_result()) { $iStartHour = date('G'); - for ($i = $iStartHour; $i <= 24; $i++) $aData[$i] = 0; + for ($i = $iStartHour; $i < 24; $i++) $aData[$i] = 0; while ($row = $result->fetch_assoc()) $aData[$row['hour']] = $row['hashrate']; // Fill any non-existing hours with 0 hashrate - for ($i = 0; $i <= 24; $i++) if (!array_key_exists($i, $aData)) $aData[$i] = 0; + for ($i = 0; $i < 24; $i++) if (!array_key_exists($i, $aData)) $aData[$i] = 0; return $this->memcache->setCache(__FUNCTION__ . $account_id, $aData); } // Catchall @@ -440,10 +440,10 @@ class Statistics { GROUP BY HOUR(time)"); if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) { $iStartHour = date('G'); - for ($i = $iStartHour; $i <= 24; $i++) $aData[$i] = 0; + for ($i = $iStartHour; $i < 24; $i++) $aData[$i] = 0; while ($row = $result->fetch_assoc()) $aData[$row['hour']] = (int) $row['hashrate']; // Fill any non-existing hours with 0 hashrate - for ($i = 0; $i <= 24; $i++) if (!array_key_exists($i, $aData)) $aData[$i] = 0; + for ($i = 0; $i < 24; $i++) if (!array_key_exists($i, $aData)) $aData[$i] = 0; return $this->memcache->setCache(__FUNCTION__, $aData); } // Catchall From e7b8cb8d4a14c3f9573e7f3ffb05259c5fc8e958 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Mon, 19 Aug 2013 08:48:27 +0200 Subject: [PATCH 30/30] Remove number_format for transaction generation * Fixes: Incorrect payouts due to number formatting * Moved number_format to output only Fixes #611 --- cronjobs/pps_payout.php | 20 ++++++++++---------- cronjobs/proportional_payout.php | 16 ++++++++-------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cronjobs/pps_payout.php b/cronjobs/pps_payout.php index fc66ecff..a02b8fd2 100755 --- a/cronjobs/pps_payout.php +++ b/cronjobs/pps_payout.php @@ -44,13 +44,13 @@ if ( $bitcoin->can_connect() === true ){ // Value per share calculation if ($config['reward_type'] != 'block') { - $pps_value = number_format(round($config['reward'] / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12) ,12); + $pps_value = round($config['reward'] / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 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 = round($aLastBlock['amount'] / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12); } else { - $pps_value = number_format(round($config['reward'] / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12) ,12); + $pps_value = round($config['reward'] / (pow(2,32) * $dDifficulty) * pow(2, $config['difficulty']), 12); } } @@ -65,7 +65,7 @@ $log->logInfo("ID\tUsername\tInvalid\tValid\t\tPPS Value\t\tPayout\t\tDonation\t foreach ($aAccountShares as $aData) { // Take our valid shares and multiply by per share value - $aData['payout'] = number_format(round($aData['valid'] * $pps_value, 8), 8); + $aData['payout'] = round($aData['valid'] * $pps_value, 8); // Defaults $aData['fee' ] = 0; @@ -73,18 +73,18 @@ foreach ($aAccountShares as $aData) { // Calculate block fees if ($config['fees'] > 0 && $aData['no_fees'] == 0) - $aData['fee'] = number_format(round($config['fees'] / 100 * $aData['payout'], 8), 8); + $aData['fee'] = round($config['fees'] / 100 * $aData['payout'], 8); // Calculate donation amount - $aData['donation'] = number_format(round($user->getDonatePercent($user->getUserId($aData['username'])) / 100 * ( $aData['payout'] - $aData['fee']), 8), 8); + $aData['donation'] = round($user->getDonatePercent($user->getUserId($aData['username'])) / 100 * ( $aData['payout'] - $aData['fee']), 8); $log->logInfo($aData['id'] . "\t" . $aData['username'] . "\t" . $aData['invalid'] . "\t" . $aData['valid'] . "\t*\t" . - $pps_value . "\t=\t" . - $aData['payout'] . "\t" . - $aData['donation'] . "\t" . - $aData['fee']); + number_format($pps_value, 12) . "\t=\t" . + number_format($aData['payout'], 8) . "\t" . + number_format($aData['donation'], 8) . "\t" . + number_format($aData['fee']), 8); // Add new credit transaction if (!$transaction->addTransaction($aData['id'], $aData['payout'], 'Credit_PPS')) diff --git a/cronjobs/proportional_payout.php b/cronjobs/proportional_payout.php index 47e55dc3..a591da22 100755 --- a/cronjobs/proportional_payout.php +++ b/cronjobs/proportional_payout.php @@ -60,26 +60,26 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { // Loop through all accounts that have found shares for this round foreach ($aAccountShares as $key => $aData) { // Payout based on shares, PPS system - $aData['percentage'] = number_format(round(( 100 / $iRoundShares ) * $aData['valid'], 8), 8); - $aData['payout'] = number_format(round(( $aData['percentage'] / 100 ) * $dReward, 8), 8); + $aData['percentage'] = round(( 100 / $iRoundShares ) * $aData['valid'], 8); + $aData['payout'] = round(( $aData['percentage'] / 100 ) * $dReward, 8); // Defaults $aData['fee' ] = 0; $aData['donation'] = 0; if ($config['fees'] > 0 && $aData['no_fees'] == 0) - $aData['fee'] = number_format(round($config['fees'] / 100 * $aData['payout'], 8), 8); + $aData['fee'] = round($config['fees'] / 100 * $aData['payout'], 8); // Calculate donation amount, fees not included - $aData['donation'] = number_format(round($user->getDonatePercent($user->getUserId($aData['username'])) / 100 * ( $aData['payout'] - $aData['fee']), 8), 8); + $aData['donation'] = round($user->getDonatePercent($user->getUserId($aData['username'])) / 100 * ( $aData['payout'] - $aData['fee']), 8); // Verbose output of this users calculations $log->logInfo($aData['id'] . "\t" . $aData['username'] . "\t" . $aData['valid'] . "\t" . $aData['invalid'] . "\t" . - $aData['percentage'] . "\t" . - $aData['payout'] . "\t" . - $aData['donation'] . "\t" . - $aData['fee']); + number_format($aData['percentage'], 8) . "\t" . + number_format($aData['payout'], 8) . "\t" . + number_format($aData['donation'], 8) . "\t" . + number_format($aData['fee']), 8); // Update user share statistics if (!$statistics->updateShareStatistics($aData, $aBlock['id']))