Update mine file to PSR-2
This commit is contained in:
23
mine.php
23
mine.php
@@ -33,19 +33,31 @@ $ip=san_ip($_SERVER['REMOTE_ADDR']);
|
||||
$ip = filter_var($ip, FILTER_VALIDATE_IP);
|
||||
|
||||
// in case of testnet, all IPs are accepted for mining
|
||||
if($_config['testnet']==false&&!in_array($ip,$_config['allowed_hosts'])&&!empty($ip)&&!in_array('*',$_config['allowed_hosts'])) api_err("unauthorized");
|
||||
if ($_config['testnet'] == false && !in_array($ip, $_config['allowed_hosts']) && !empty($ip) && !in_array(
|
||||
'*',
|
||||
$_config['allowed_hosts']
|
||||
)) {
|
||||
api_err("unauthorized");
|
||||
}
|
||||
|
||||
if ($q == "info") {
|
||||
// provides the mining info to the miner
|
||||
$diff = $block->difficulty();
|
||||
$current = $block->current();
|
||||
|
||||
$res=array("difficulty"=>$diff, "block"=>$current['id'], "height"=>$current['height'], "testnet"=>$_config['testnet']);
|
||||
$res = [
|
||||
"difficulty" => $diff,
|
||||
"block" => $current['id'],
|
||||
"height" => $current['height'],
|
||||
"testnet" => $_config['testnet'],
|
||||
];
|
||||
api_echo($res);
|
||||
exit;
|
||||
} elseif ($q == "submitNonce") {
|
||||
// in case the blocks are syncing, reject all
|
||||
if($_config['sanity_sync']==1) api_err("sanity-sync");
|
||||
if ($_config['sanity_sync'] == 1) {
|
||||
api_err("sanity-sync");
|
||||
}
|
||||
$nonce = san($_POST['nonce']);
|
||||
$argon = $_POST['argon'];
|
||||
$public_key = san($_POST['public_key']);
|
||||
@@ -58,9 +70,6 @@ if($q=="info"){
|
||||
$res = $block->forge($nonce, $argon, $public_key, $private_key);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if ($res) {
|
||||
//if the new block is generated, propagate it to all peers in background
|
||||
$current = $block->current();
|
||||
@@ -72,5 +81,3 @@ if($q=="info"){
|
||||
} else {
|
||||
api_err("invalid command");
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user