various small changes

This commit is contained in:
Tanguy Pruvot 2016-05-30 09:15:41 +02:00
parent f26060c15f
commit 738848b7e9
3 changed files with 31 additions and 11 deletions

View file

@ -8,6 +8,7 @@ class WalletRPC {
private $rpc; private $rpc;
// cache // cache
private $account;
private $accounts; private $accounts;
private $info; private $info;
private $height = 0; private $height = 0;
@ -26,6 +27,7 @@ class WalletRPC {
switch ($coin->rpcencoding) { switch ($coin->rpcencoding) {
case 'GETH': case 'GETH':
$this->type = 'Ethereum'; $this->type = 'Ethereum';
$this->account = empty($coin->account) ? $coin->master_wallet : $coin->account;
$this->rpc = new Ethereum($coin->rpchost, $coin->rpcport); $this->rpc = new Ethereum($coin->rpchost, $coin->rpcport);
break; break;
default: default:
@ -46,9 +48,9 @@ class WalletRPC {
// convert common methods used by yiimp // convert common methods used by yiimp
switch ($method) { switch ($method) {
case 'getaccountaddress': case 'getaccountaddress':
if (!isset($this->accounts)) if (!empty($params[0]))
$this->accounts = $this->rpc->eth_accounts(); return $params[0];
return arraySafeVal($this->accounts, 0, $params); return $this->account;
case 'getinfo': case 'getinfo':
if (!isset($this->info)) { if (!isset($this->info)) {
$info = array(); $info = array();
@ -88,14 +90,25 @@ class WalletRPC {
$info['generate'] = $this->rpc->eth_mining(); $info['generate'] = $this->rpc->eth_mining();
$info['errors'] = ''; $info['errors'] = '';
return $info; return $info;
case 'getblock':
$hash = (string) arraySafeVal($params,0);
$block = $this->rpc->eth_getBlockByHash($hash);
return $block;
case 'getblockhash':
$n = arraySafeVal($params,0);
$block = $this->rpc->eth_getBlockByNumber($n, true);
return $block->hash;
case 'gettransaction':
case 'getrawtransaction':
$txid = arraySafeVal($params,0,'');
$tx = $this->rpc->eth_getTransactionByHash($txid);
return $tx;
case 'getwork':
return false; //$this->rpc->eth_getWork(); auto enable miner!
// todo...
case 'getpeerinfo': case 'getpeerinfo':
$peers = array(); $peers = array();
return $peers; return $peers;
case 'getwork':
return $this->rpc->eth_getWork();
// todo...
case 'getblocktemplate':
return $this->rpc->eth_getWork();
case 'listtransactions': case 'listtransactions':
$txs = array(); $txs = array();
return $txs; return $txs;

View file

@ -7,6 +7,7 @@ echo <<<end
tr.ssrow.filtered { display: none; } tr.ssrow.filtered { display: none; }
th.status, td.status { min-width: 28px; max-width: 48px; text-align: center; } th.status, td.status { min-width: 28px; max-width: 48px; text-align: center; }
td.status { font-family: monospace; font-size: 9pt; letter-spacing: 3px; } td.status { font-family: monospace; font-size: 9pt; letter-spacing: 3px; }
td.status span.progress { font-size: .8em; letter-spacing: 0; }
td.status span.hidden { visibility: hidden; } td.status span.hidden { visibility: hidden; }
</style> </style>
end; end;
@ -87,8 +88,8 @@ foreach($coins as $coin)
else echo '&nbsp;'; else echo '&nbsp;';
if($coin->block_height < $coin->target_height) { if($coin->block_height < $coin->target_height) {
$percent = round($coin->block_height*100/$coin->target_height, 2); $percent = round($coin->block_height*100/$coin->target_height, 1);
echo '<br/><span style="font-size: .8em">'.$percent.'%</span>'; echo '<br/><span class="progress">'.$percent.'%</span>';
} }
echo "</td>"; echo "</td>";

View file

@ -128,7 +128,10 @@ if (!empty($query)) try {
if ($param === 'true' || $param === 'false') { if ($param === 'true' || $param === 'false') {
$param = $param === 'true' ? true : false; $param = $param === 'true' ? true : false;
} }
else $param = (is_numeric($param)) ? 0 + $param : trim($param,'"'); else if (strpos($param, '0x') === 0)
$param = "$param"; // eth hex crap
else
$param = (is_numeric($param)) ? 0 + $param : trim($param,'"');
$p[] = $param; $p[] = $param;
} }
@ -157,6 +160,9 @@ if (!empty($query)) try {
case 7: case 7:
$result = $remote->$command($p[0], $p[1], $p[2], $p[3], $p[4], $p[5], $p[6]); $result = $remote->$command($p[0], $p[1], $p[2], $p[3], $p[4], $p[5], $p[6]);
break; break;
case 8:
$result = $remote->$command($p[0], $p[1], $p[2], $p[3], $p[4], $p[5], $p[6], $p[7]);
break;
default: default:
$result = 'error: too much parameters'; $result = 'error: too much parameters';
} }