[ADDED] SSO across MPOS pools with single database host
This commit is contained in:
parent
4adc1134d9
commit
a7fc7146f1
@ -1,6 +1,13 @@
|
||||
1.0.2 (XXX XXth 2015)
|
||||
---------------------
|
||||
|
||||
* Allow SSO accross MPOS pools
|
||||
* Added a new config option `$config['db']['shared']['name']`, defaults to `$config['db']['name']`
|
||||
* Will access `accounts` and `pool_workers` on shared table
|
||||
* Does not allow splitting `accounts` and `pool_woker` across database hosts
|
||||
* Required `$config['cookie']['domain']` to be set
|
||||
* You need to use the top domain shared between hosts as the setting
|
||||
* e.g. `ltc.thepool.com` and `btc.thepool.com` it has to be `.thepool.com` (NOTE the leading .)
|
||||
* Increased information on `Admin -> Wallet Info`
|
||||
* Added block count to Wallet Status
|
||||
* Added number of accounts to Wallet Status
|
||||
|
||||
@ -3,7 +3,17 @@ $defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
|
||||
|
||||
class CoinAddress extends Base {
|
||||
protected $table = 'coin_addresses';
|
||||
private $cache = array();
|
||||
|
||||
/**
|
||||
* We allow changing the database for shared accounts across pools
|
||||
* Load the config on construct so we can assign the DB name
|
||||
* @param config array MPOS configuration
|
||||
* @return none
|
||||
**/
|
||||
public function __construct($config) {
|
||||
$this->setConfig($config);
|
||||
$this->table = $this->config['db']['shared']['name'] . '.' . $this->table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch users coin address for a currency
|
||||
@ -124,8 +134,7 @@ class CoinAddress extends Base {
|
||||
}
|
||||
}
|
||||
|
||||
$coin_address = new CoinAddress();
|
||||
$coin_address = new CoinAddress($config);
|
||||
$coin_address->setDebug($debug);
|
||||
$coin_address->setConfig($config);
|
||||
$coin_address->setMysql($mysqli);
|
||||
$coin_address->setErrorCodes($aErrorCodes);
|
||||
|
||||
@ -2,11 +2,6 @@
|
||||
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
|
||||
|
||||
class RoundStats extends Base {
|
||||
private $tableTrans = 'transactions';
|
||||
private $tableStats = 'statistics_shares';
|
||||
private $tableBlocks = 'blocks';
|
||||
private $tableUsers = 'accounts';
|
||||
|
||||
/**
|
||||
* Get next block for round stats
|
||||
**/
|
||||
@ -79,7 +74,7 @@ class RoundStats extends Base {
|
||||
b.id, height, blockhash, amount, confirmations, difficulty, FROM_UNIXTIME(time) as time, shares,
|
||||
IF(a.is_anonymous, 'anonymous', a.username) AS finder,
|
||||
ROUND(difficulty * POW(2, 32 - " . $this->coin->getTargetBits() . "), 0) AS estshares,
|
||||
(time - (SELECT time FROM $this->tableBlocks WHERE height < ? ORDER BY height DESC LIMIT 1)) AS round_time
|
||||
(time - (SELECT time FROM " . $this->block->getTableName() . " WHERE height < ? ORDER BY height DESC LIMIT 1)) AS round_time
|
||||
FROM " . $this->block->getTableName() . " as b
|
||||
LEFT JOIN " . $this->user->getTableName() . " AS a ON b.account_id = a.id
|
||||
WHERE b.height = ? LIMIT 1");
|
||||
|
||||
@ -6,6 +6,17 @@ class User extends Base {
|
||||
private $userID = false;
|
||||
private $user = array();
|
||||
|
||||
/**
|
||||
* We allow changing the database for shared accounts across pools
|
||||
* Load the config on construct so we can assign the DB name
|
||||
* @param config array MPOS configuration
|
||||
* @return none
|
||||
**/
|
||||
public function __construct($config) {
|
||||
$this->setConfig($config);
|
||||
$this->table = $this->config['db']['shared']['name'] . '.' . $this->table;
|
||||
}
|
||||
|
||||
// get and set methods
|
||||
private function getHash($string, $version=0, $pepper='') {
|
||||
switch($version) {
|
||||
@ -984,13 +995,12 @@ public function isAuthenticated($logout=true) {
|
||||
}
|
||||
|
||||
// Make our class available automatically
|
||||
$user = new User();
|
||||
$user = new User($config);
|
||||
$user->setDebug($debug);
|
||||
$user->setLog($log);
|
||||
$user->setMysql($mysqli);
|
||||
$user->setSalt($config['SALT']);
|
||||
$user->setSmarty($smarty);
|
||||
$user->setConfig($config);
|
||||
$user->setMail($mail);
|
||||
$user->setToken($oToken);
|
||||
$user->setBitcoin($bitcoin);
|
||||
|
||||
@ -4,6 +4,17 @@ $defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
|
||||
class Worker extends Base {
|
||||
protected $table = 'pool_worker';
|
||||
|
||||
/**
|
||||
* We allow changing the database for shared accounts across pools
|
||||
* Load the config on construct so we can assign the DB name
|
||||
* @param config array MPOS configuration
|
||||
* @return none
|
||||
**/
|
||||
public function __construct($config) {
|
||||
$this->setConfig($config);
|
||||
$this->table = $this->config['db']['shared']['name'] . '.' . $this->table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update worker list for a user
|
||||
* @param account_id int User ID
|
||||
@ -294,12 +305,11 @@ class Worker extends Base {
|
||||
}
|
||||
}
|
||||
|
||||
$worker = new Worker();
|
||||
$worker = new Worker($config);
|
||||
$worker->setDebug($debug);
|
||||
$worker->setMysql($mysqli);
|
||||
$worker->setMemcache($memcache);
|
||||
$worker->setShare($share);
|
||||
$worker->setConfig($config);
|
||||
$worker->setUser($user);
|
||||
$worker->setErrorCodes($aErrorCodes);
|
||||
$worker->setCoin($coin);
|
||||
|
||||
@ -54,6 +54,7 @@ $config['db']['user'] = 'someuser';
|
||||
$config['db']['pass'] = 'somepass';
|
||||
$config['db']['port'] = 3306;
|
||||
$config['db']['name'] = 'mpos';
|
||||
$config['db']['shared']['name'] = $config['db']['name'];
|
||||
|
||||
/**
|
||||
* Local wallet RPC
|
||||
|
||||
Loading…
Reference in New Issue
Block a user