From af70a194c9d618dbef80060f5c55ee43dadba7f5 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sun, 30 Jun 2013 10:26:24 +0200 Subject: [PATCH] Adding support for POS coin This will fix #275 and add proper support for a different implementation of network difficulty. --- cronjobs/pps_payout.php | 2 ++ public/include/pages/api/getdifficulty.inc.php | 4 +++- public/include/pages/statistics.inc.php | 2 ++ public/include/pages/statistics/pool.inc.php | 2 ++ public/include/smarty_globals.inc.php | 5 ++++- 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cronjobs/pps_payout.php b/cronjobs/pps_payout.php index 459384d2..bf8513fa 100755 --- a/cronjobs/pps_payout.php +++ b/cronjobs/pps_payout.php @@ -32,6 +32,8 @@ if ($config['payout_system'] != 'pps') { // Fetch all transactions since our last block if ( $bitcoin->can_connect() === true ){ $dDifficulty = $bitcoin->getdifficulty(); + if (strtolower($config['currency']) == 'pos') + $dDifficulty = $dDifficulty['proof-of-work']; } else { verbose("Aborted: " . $bitcoin->can_connect() . "\n"); exit(1); diff --git a/public/include/pages/api/getdifficulty.inc.php b/public/include/pages/api/getdifficulty.inc.php index 9d2aa7a2..4d721e93 100644 --- a/public/include/pages/api/getdifficulty.inc.php +++ b/public/include/pages/api/getdifficulty.inc.php @@ -10,8 +10,10 @@ $id = $user->checkApiKey($_REQUEST['api_key']); // Fetch data from litecoind if ($bitcoin->can_connect() === true){ if (!$dDifficulty = $memcache->get('dDifficulty')) { - $memcache->set('dDifficulty', $dDifficulty); $dDifficulty = $bitcoin->query('getdifficulty'); + if (strtolower($config['currency']) == 'pos') + $dDifficulty = $dDifficulty['proof-of-work']; + $memcache->set('dDifficulty', $dDifficulty); } } else { $iDifficulty = 1; diff --git a/public/include/pages/statistics.inc.php b/public/include/pages/statistics.inc.php index 195e3545..a09aa3cb 100644 --- a/public/include/pages/statistics.inc.php +++ b/public/include/pages/statistics.inc.php @@ -6,6 +6,8 @@ if (!defined('SECURITY')) if ($bitcoin->can_connect() === true){ $dDifficulty = $bitcoin->query('getdifficulty'); + if (strtolower($config['currency']) == 'pos') + $dDifficulty = $dDifficulty['proof-of-work']; $iBlock = $bitcoin->query('getblockcount'); } else { $dDifficulty = 1; diff --git a/public/include/pages/statistics/pool.inc.php b/public/include/pages/statistics/pool.inc.php index 9650681e..d8c996ad 100644 --- a/public/include/pages/statistics/pool.inc.php +++ b/public/include/pages/statistics/pool.inc.php @@ -7,6 +7,8 @@ if (!defined('SECURITY')) // Fetch data from litecoind if ($bitcoin->can_connect() === true){ $dDifficulty = $bitcoin->getdifficulty(); + if (strtolower($config['currency']) == 'pos') + $dDifficulty = $dDifficulty['proof-of-work']; $iBlock = $bitcoin->getblockcount(); } else { $dDifficulty = 1; diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index ed3d2ca8..9e77c923 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -14,8 +14,11 @@ $aRoundShares = 1; // Only run these if the user is logged in if (@$_SESSION['AUTHENTICATED']) { $aRoundShares = $statistics->getRoundShares(); - if ($bitcoin->can_connect() === true) + if ($bitcoin->can_connect() === true) { $dDifficulty = $bitcoin->query('getdifficulty'); + if (strtolower($config['currency']) == 'pos') + $dDifficulty = $dDifficulty['proof-of-work']; + } } // Fetch some data