pool/web/yaamp/models/db_coinsModel.php
Tanguy Pruvot cbe55a3a84 Squashed commit for segwit support:
commit c59abe5d203fabdabcca81ff5f9c6ff133cfae3b
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Tue Nov 28 11:13:52 2017 +0100

    segwit: show a segwit icon on blocks history

    + remove some inline styles...

commit b4a8639370e6837ebc5a2047e7c334e9f931abfc
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Tue Nov 28 09:55:40 2017 +0100

    segwit: cleanup + masternode case

    tested ok with BSD (block 400996), and with real BTX segwit txs (block 90958)

    also ok on VTC and GRS

commit 926dbd11757ebff7f7d4930266de9b9061c8ab16
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Sat Nov 25 18:41:01 2017 +0100

    sql: add segwit fields, and ui config

    and fill block segwit field if it contains segwit txs,
    an icon is added in the dashboard "last blocks" for these blocks

commit 0b13bf55e9dd1d2229d188f0f8382b27642b20da
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Sat Nov 25 13:47:20 2017 +0100

    segwit: include commitment in coinbase + .conf toggle

    tested ok on BTX, GRS and VTC with normal txs, but the commitment merkle hash maybe need some more love...

    so, to prevent useless bigger blocks, only generate segwit commitment if a segwit tx is present in mempool

    to check with real segwit txs... not seen any yet..

commit b508bc87943d9e426cda994c2f53c16c11e8d4c3
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Thu Mar 2 11:18:34 2017 +0100

    segwit: prepare the witness data, but disabled

    need more test, may affect the coinbase merkle and the miners...

commit 19bd3a83b9ddddd8b5ed4b7a1bdf8cf8c233e346
Author: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Date:   Thu Mar 2 10:30:29 2017 +0100

    stratum: handle and auto toggle segwit if supported
2017-11-28 11:55:20 +01:00

124 lines
3.2 KiB
PHP

<?php
class db_coins extends CActiveRecord
{
public static function model($className=__CLASS__)
{
return parent::model($className);
}
public function tableName()
{
return 'coins';
}
public function rules()
{
return array(
array('name', 'required'),
array('symbol', 'required'),
array('symbol', 'unique'),
);
}
public function relations()
{
return array(
);
}
public function attributeLabels()
{
return array(
'symbol2' => 'Official Symbol',
'auxpow' => 'AUX PoW',
'dontsell' => 'Don\'t sell',
'sellonbid' => 'Sell on Bid',
'txfee' => 'Tx Fee',
'program' => 'Process name',
'conf_folder' => 'Conf. folder',
'mature_blocks' => 'PoW Confirmations',
'powend_height' => 'End of PoW',
'rpchost' => 'RPC Host',
'rpcport' => 'RPC Port',
'rpcuser' => 'RPC User',
'rpcpasswd' => 'RPC Password',
'rpccurl' => 'RPC via curl',
'rpcssl' => 'RPC SSL',
'rpccert' => 'RPC Certificate',
'serveruser' => 'Server user',
'hassubmitblock'=> 'Has submitblock',
'hasmasternodes'=> 'Masternodes',
'usesegwit' => 'Use segwit',
'market' => 'Preferred market',
'rpcencoding' => 'RPC Type',
'specifications'=> 'Notes'
);
}
public function getOfficialSymbol()
{
if(!empty($this->symbol2))
return $this->symbol2;
else
return $this->symbol;
}
public function getSymbol_show()
{
// virtual property $coin->symbol_show
return $this->getOfficialSymbol();
}
public function deleteDeps()
{
$coin = $this;
$ids_query = "(SELECT id FROM accounts WHERE coinid=".$coin->id.")";
dborun("DELETE FROM balanceuser WHERE userid IN $ids_query");
dborun("DELETE FROM hashuser WHERE userid IN $ids_query");
dborun("DELETE FROM shares WHERE userid IN $ids_query");
dborun("DELETE FROM workers WHERE userid IN $ids_query");
dborun("DELETE FROM payouts WHERE account_id IN $ids_query");
dborun("DELETE FROM blocks WHERE coin_id=".$coin->id);
dborun("DELETE FROM shares WHERE coinid=".$coin->id);
dborun("DELETE FROM earnings WHERE coinid=".$coin->id);
dborun("DELETE FROM notifications WHERE idcoin=".$coin->id);
dborun("DELETE FROM market_history WHERE idcoin=".$coin->id);
dborun("DELETE FROM markets WHERE coinid=".$coin->id);
dborun("DELETE FROM accounts WHERE coinid=".$coin->id);
}
public function deleteWithDeps()
{
$this->deleteDeps();
return $this->delete();
}
/**
* Link for txs
* @param string $label link content
* @param array $params 'height'=>123 or 'hash'=>'xxx' or 'txid'=>'xxx'
* @param array $htmlOptions target/title ...
*/
public function createExplorerLink($label, $params=array(), $htmlOptions=array(), $force=false)
{
if($this->id == 6 && isset($params['txid'])) {
// BTC txid
$url = 'https://blockchain.info/tx/'.$params['txid'];
$htmlOpts = array_merge(array('target'=>'_blank'), $htmlOptions);
return CHtml::link($label, $url, $htmlOpts);
}
else if (YIIMP_PUBLIC_EXPLORER || $force || user()->getState('yaamp_admin')) {
$urlParams = array_merge(array('id'=>$this->id), $params);
Yii::import('application.modules.explorer.ExplorerController');
$url = ExplorerController::createUrl('/explorer', $urlParams);
return CHtml::link($label, trim($url,'?'), $htmlOptions);
}
return $label;
}
}