From 7f759708c8b77814823007ba2bcec680eab8359c Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 9 Jul 2013 11:43:12 +0200 Subject: [PATCH] Adding share type to log output This will display which detection mechanism caught the share. Fixed stratum detection Fixes #405 --- cronjobs/findblock.php | 5 +++-- public/include/classes/share.class.php | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cronjobs/findblock.php b/cronjobs/findblock.php index 5c168448..b98bbc3a 100755 --- a/cronjobs/findblock.php +++ b/cronjobs/findblock.php @@ -68,7 +68,7 @@ if (empty($aAllBlocks)) { $log->logDebug('No new blocks without share_id found in database'); } else { // Loop through our unaccounted blocks - $log->logInfo("Block ID\t\tHeight\tAmount\tShare ID\tShares\tFinder"); + $log->logInfo("Block ID\t\tHeight\tAmount\tShare ID\tShares\tFinder\tType"); foreach ($aAllBlocks as $iIndex => $aBlock) { if (empty($aBlock['share_id'])) { // Fetch this blocks upstream ID @@ -105,7 +105,8 @@ if (empty($aAllBlocks)) { . $aBlock['amount'] . "\t" . $iCurrentUpstreamId . "\t\t" . $iRoundShares . "\t" - . "[$iAccountId] " . $user->getUserName($iAccountId) + . "[$iAccountId] " . $user->getUserName($iAccountId) . "\t" + . $share->share_type ); // Notify users diff --git a/public/include/classes/share.class.php b/public/include/classes/share.class.php index 4fea43c5..e3f6e33d 100644 --- a/public/include/classes/share.class.php +++ b/public/include/classes/share.class.php @@ -193,8 +193,9 @@ class Share { $ppheader = sprintf('%08d', $aBlock['version']) . word_reverse($aBlock['previousblockhash']) . word_reverse($aBlock['merkleroot']) . dechex($aBlock['time']) . $aBlock['bits'] . dechex($aBlock['nonce']); $stmt = $this->mysqli->prepare("SELECT SUBSTRING_INDEX( `username` , '.', 1 ) AS account, id FROM $this->table WHERE solution = ? LIMIT 1"); - if ($this->checkStmt($stmt) && $stmt->bind_param('s', $scrypt_hash) && $stmt->execute() && $result = $stmt->get_result()->num_rows > 0) { + if ($this->checkStmt($stmt) && $stmt->bind_param('s', $scrypt_hash) && $stmt->execute() && $result = $stmt->get_result()) { $this->oUpstream = $result->fetch_object(); + $this->share_type = 'startum_solution'; if (!empty($this->oUpstream->account) && is_int($this->oUpstream->id)) return true; } @@ -203,6 +204,7 @@ class Share { $stmt = $this->mysqli->prepare("SELECT SUBSTRING_INDEX( `username` , '.', 1 ) AS account, id FROM $this->table WHERE solution LIKE CONCAT(?, '%') LIMIT 1"); if ($this->checkStmt($stmt) && $stmt->bind_param('s', $ppheader) && $stmt->execute() && $result = $stmt->get_result()) { $this->oUpstream = $result->fetch_object(); + $this->share_type = 'pp_solution'; if (!empty($this->oUpstream->account) && is_int($this->oUpstream->id)) return true; } @@ -219,6 +221,7 @@ class Share { ORDER BY id ASC LIMIT 1"); if ($this->checkStmt($stmt) && $stmt->bind_param('iii', $last, $aBlock['time'], $Block['time']) && $stmt->execute() && $result = $stmt->get_result()) { $this->oUpstream = $result->fetch_object(); + $this->share_type = 'upstream_share'; if (!empty($this->oUpstream->account) && is_int($this->oUpstream->id)) return true; } @@ -234,6 +237,7 @@ class Share { ORDER BY id ASC LIMIT 1"); if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $last, $aBlock['time']) && $stmt->execute() && $result = $stmt->get_result()) { $this->oUpstream = $result->fetch_object(); + $this->share_type = 'any_share'; if (!empty($this->oUpstream->account) && is_int($this->oUpstream->id)) return true; }