diff --git a/.gitignore b/.gitignore index 46e1de7..eac5cdc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,7 @@ /vendor /cache/template +/cache/info.txt +/config.php +/run.sh +/dood.sh +/todo.txt diff --git a/README.md b/README.md index 97ab790..4068128 100644 --- a/README.md +++ b/README.md @@ -1,44 +1,89 @@ -# pool +# Modifications -A proof of concept pool for Arionum +This repository is based on angelexevior's fork. +System requirements are indentical to the official pool code. -Live version: http://aropool.com +Warning: because of additions to the config file, do not simply replace the php-files without making sure all variables are added to the config. -The pool requires a full node running on the same server (on a different subdomain) as it uses it's libraries and db connection. +## Mining +- Share count based on accepted share and pool min DL and networm maximum min DL rate +- Multiple pool can work together, (eg. different min DL for Cpu, GPU or other mining settings, but same reward policy) +- Database updated with orphan info +- Poolsanity.php: improved peering to other pools (send and get infos) +- Workers unique ID based on miner's session ID, or the address first 15 char -## Install +## Utils +- Update.php: calculate orphan blocks, and overwriter (stealer)'s alias or address +- Poolsanity.php: modified, to update PID every minute +- Poolsanity.service: Made a system service for poolsanity, copy to /etc/systemd/sytem +- getserverinfo.sh: update server resources +- services: system services for automated jobs (sanity, poolsanity, serverinfo) +- Added pool info service: Watching another pool's block height (Aropool.com, Aro.cool, Arionumpool.com, Arionum.info) + -> if our height lower, then force sanity -The requirements are the same as for the arionum node: +## Display +- Show another pool's block heights +- Show Server resources (CPU, Memory, Server load) +- Show Orphans % (basen on last 100 block) +- Show Orphan block overwriter ("stealer") +- Expanded informations on main page (need to run /utils/getinfo.sh) + -> passed blocks from last found + -> luck % (based on passed blocks and actual hashrate, need to finetune) + -> Arionum actual price (from arionum.info) + -> network hashrates (from arionum.info) +- Added some icons, and header +- Added links page (webpages, miners, wallets, pools...) +- Added Cuby's web wallet link +- Added News info -- php 7.2 (with argon2) -- php-openssl -- php-gmp -- php-bcmath +With the current setup payments are split from updates. -## Usage +Run payments to crontab every x hours, min payment can remain low, but it will prevent big miners from massive small payments. -1. Create a new database for the pool (separate from the node one). -2. Edit the `config.php` and follow the instructions inside. -3. Import the `contrib/pool.sql` to your NEW mysql database. -4. Chmod the cache directory using `chmod 777 cache -R`. -5. Create a cron entry using the following format: - ```bash - */10 * * * * user php /path/to/pool/payments.php - ``` +Run update in seperate crontab every 1 minute. -Start the poolsanity by running: +Optional: Run poolsanity as systemd-service -```bash -php /path/to/pool/poolsanity.php &>/dev/null & -``` -## Notes +### hendrik's changes ### + +## Bigger changes: +- Change: Hashreporting has been removed from payments/poolsanity to a seperate updater. Updating hashrates on the website can be done independently of payment-cycle, and db is no longer only updated when moving to next block. Be aware that the 10minute update interval from the clients is fixed. As is the 'first appearance' in the db after submitting first nonce +- Added: Api.php has been expanded and restructured with more options +- Added: Last payment, payment date, payments in 24h, time of last submitted nonce included on individual miner page and api +- Bugfix: False rejects stale blocks submitted through Dan's Javaminer after PHP upgrade. +- Bugfix: Workaround for misreporting Dan's Java miner/Android miner +- TODO: either update miner hr more often or insert sum workerHR into dashboard/individual pages/api -For the template system, we use [raintpl3]. +## Smaller changes: +- Change: The 'last-update' values of workers has been reduced from 1hr to 720s to keep the calculation of total hashrate more precise, this means workers not having reported in during the last 12 minutes are not added to the miner total hr and pool hr. +- Change: The 'time-out' value of miners has been enlarged to have miners remain in history when they are away for a while (max 24h). For individual workers it's set to 30minutes. +- Change: Discard of last remaining historical shares has been added to prevent ghost miners remaining in the list indefinely (hist.shares would never reach zero) +- Change: A miner will be deleted from history if the historical share rate drops below 50 AND he has not submitted a nonce in the last 24h +- Change: Only 'active miners' are counted to calculate total HR: those with miner HR > 0 +- Added/Change: Next average CPU Blocks HR we now also calculate average GPU blocks HR. Both are now only based on active miners. +- Change: How far back last payments are displayed on payments page is moved to config +- Change: During payment cycle, how far back is searched for small pending payments is moved to config. +- Change: Manual payment request of all outstanding payments now looks through entire pool history. +- Change: If no payment message is set in config it takes the pool hostname from config +- Change: Degradation, poolname etc. have been moved to config +- Bugfix: to make poolsanity being able to be started as service through systemd +- Bugfix: fixed erros in hashrate extension determination +- TODO: Bugfix of Ario's total hr calc in indiv.miner page. -Please use a new name instead of [aropool] to avoid user confusion! +## Display changes: -This project is early alpha, bugs may be found, functions might not work properly etc. - -[aropool]: https://aropool.com -[raintpl3]: https://github.com/feulf/raintpl3 +- Change: Small updates to dashboard layout based on reoccuring questions in discord +- Change: On payments page: Removal of long TX addresses in payout page, replaced with links to block explorer +- Change: To remove the constant confusion we are going to be consequent and call it GPU-*blocks* HR and NOT "GPU HR" (and CPU-*blocks* HR instead of "CPU HR") everywhere on the site. +- Bugfix: template/index.html responsive html code of the purple box showing hashrates caused errors on android. Fixed. Also: C-HR is now displayed left, G-HR right, just as in all other tables. +- Bugfix: Rounding error hashrates +- Change: Template/Header page: pool name set in config +- Added: On dashboard: average h/s displayed on page +- Added: On blocks won page - Blocks are veryfiable through link to Block Explorer, for transparency +- Change: On individual miner page - best DL is 1000000 replaced with No Nonce submitted yet +- Change: On individual miner page - added time of last submitted nonce +- Bugfix: On individual miner page - when last payment is still in mempool it's shown as Payment In Process +- Bugfix: On individual miner page - when no payment ever last payment date is shown as No Payment Yet +- Change: On info page - old mining info removed, pool details (rewards/degradation/payout/DL) are read from the config file +- Change: On info page - discord handle can be set in config diff --git a/api.php b/api.php new file mode 100644 index 0000000..5378074 --- /dev/null +++ b/api.php @@ -0,0 +1,202 @@ + returns total hashrate and shares of miner +/api?q=payments&id= returns payments of miner +/api.php without flags also returns pool status at the moment for compatibility reasons + +*/ + +header('Content-Type: application/json'); +require_once __DIR__.'/db.php'; + +$q = san($_GET['q']); + + +if ($q == "minerstatus") { + + $id = san($_GET['id']); + + if ($id == null) { + + api_err("Invalid request"); + + } else { + + $cpu_hashrate = $db->single("SELECT hashrate FROM miners WHERE id=:id",[":id"=>$id]); + + if ($cpu_hashrate != 0) { // If there is result, we can load rest of values + + $gpu_hashrate = $db->single("SELECT gpuhr FROM miners WHERE id=:id",[":id"=>$id]); + $historic = $db->single("SELECT historic FROM miners WHERE id=:id",[":id"=>$id]); + $shares = $db->single("SELECT shares FROM miners WHERE id=:id",[":id"=>$id]); + $update = $db->single("SELECT updated FROM miners WHERE id=:id",[":id"=>$id]); + + $yesterday = time()-86400; + $yesterday_block = $aro->single("SELECT height+1 FROM blocks WHERE date<=$yesterday ORDER by height DESC LIMIT 1"); + $last_payment_txn = $db->single("SELECT txn FROM payments WHERE address=:id AND done=1 ORDER by height DESC LIMIT 1",[":id"=>$id]); + $last_payment_time = $aro->single("SELECT date FROM transactions WHERE id=$last_payment_txn"); + $total_paid = (int)$db->single("SELECT total_paid FROM miners WHERE id=:id",[":id"=>$id]); + $pending = $db->single("SELECT pending FROM miners WHERE id=:id",[":id"=>$id]); + $last_payment = $db->single("SELECT SUM(val) FROM payments WHERE txn=:lasttxn AND done=1",[":lasttxn"=>$last_payment_txn]); + $past_24h = $db->single("SELECT SUM(val) FROM payments WHERE address=:id AND height>=$yesterday_block AND done=1",[":id"=>$id]); + + $workers = $db->single("SELECT COUNT(1) FROM workers WHERE miner=:id",[":id"=>$id]); + + if ($update == null) { + $update = "No nonce submitted"; + } + + if ($shares == null) { + $shares = 0; + } + + if ($historic == null) { + $historic = 0; + } + + if ($cpu_hashrate == null) { + $cpu_hashrate = 0; + } + + if ($gpu_hashrate == null) { + $gpu_hashrate = 0; + } + + if ($last_payment_time == null) { + $last_payment_time = "Payment in process"; + } + + if ($last_payment == 0 ) { + $last_payment_time = "No payment yet"; + } + + if ($pending == null) { + $pending = 0; + } + + if ($last_payment == null) { + $last_payment = 0; + } + + if ($past_24h == null) { + $past_24h = 0; + } + + if ($workers == null) { + $workers = 0; + } + echo json_encode(array( + "miner" => $id, + "cpu_hr" => $cpu_hashrate, + "gpu_hr" => $gpu_hashrate, + "workers" => $workers, + "historic_shares" => $historic, + "current_shares" => $shares, + "last_nonce_submited" => $update, + "total_paid" => $total_paid, + "pending" => $pending, + "past_24h" => $past_24h, + "last_payment" => $last_payment, + "last_payment_date" => $last_payment_time + )); + + } else { // No result - we don't have record for this id in our miners table + + api_err("Account not found"); + + } + } + +} elseif ($q == "poolstatus") { + + $total_hr = (int)$db->single("SELECT val FROM info WHERE id='total_hash_rate'"); + $total_gpu = (int)$db->single("SELECT val FROM info WHERE id='total_gpu_hr'"); + $current = $aro->single("SELECT height FROM blocks ORDER by height DESC LIMIT 1"); + $miners = $db->single("SELECT COUNT(1) FROM miners WHERE hashrate>0 OR gpuhr>0"); + $last_won = (int)$db->single("SELECT height FROM blocks ORDER by height DESC LIMIT 1"); + $last_won_time = $aro->single("SELECT date FROM blocks WHERE height=:h",[":h"=>$last_won]); + + if ($last_won_time == null) { + $last_won_time = "Never"; + } + + if ($miners == 0) { + $avg_gpuhr = 0; + $avg_hr = 0; + } + + echo json_encode( + array( + "cpu_hr" => $total_hr, + "gpu_hr" => $total_gpu, + "current_block_height" => $current, + "last_won_block" => $last_won, + "last_won_block_time" => $last_won_time, + "active miners" => $miners, + "fee" => $pool_config['fee'], + "historic_reward" => $pool_config['historic_reward'], + "current_reward" => $pool_config['current_reward'], + "miner_reward" => $pool_config['miner_reward'], + "min_payout" => $pool_config['min_payout'] + )); + +} elseif ($q == "payments") { + + $id = san($_GET['id']); + + if ($id == null) { + + api_err("Invalid request"); + + } else { + + $yesterday = time()-86400; + $yesterday_block = $aro->single("SELECT height+1 FROM blocks WHERE date<=$yesterday ORDER by height DESC LIMIT 1"); + $last_payment_txn = $db->single("SELECT txn FROM payments WHERE address=:id AND done=1 ORDER by height DESC LIMIT 1",[":id"=>$id]); + $last_payment_time = $aro->single("SELECT date FROM transactions WHERE id=$last_payment_txn"); + $total_paid = (int)$db->single("SELECT total_paid FROM miners WHERE id=:id",[":id"=>$id]); + $pending = $db->single("SELECT pending FROM miners WHERE id=:id",[":id"=>$id]); + $last_payment = $db->single("SELECT SUM(val) FROM payments WHERE txn=:lasttxn AND done=1",[":lasttxn"=>$last_payment_txn]); + $past_24h = $db->single("SELECT SUM(val) FROM payments WHERE address=:id AND height>=$yesterday_block AND done=1",[":id"=>$id]); + + if ($pending == null) { + $pending = 0; + } + + if ($last_payment == null) { + $last_payment = 0; + } + + if ($past_24h == null) { + $past_24h = 0; + } + + if ($last_payment_time == null) { + $last_payment_time = "Payment in process"; + } + + if ($last_payment == 0 ) { + $last_payment_time = "No payment yet"; + } + + echo json_encode(array("miner"=>$id, "total paid"=>$total_paid, "pending"=>$pending, "past_24h"=>$past_24h, "last_payment"=>$last_payment, "last_payment_date"=>$last_payment_time)); + + } + +} else { + + // we keep this here as this is the old aropool.com api, for compatibility + $total_hr = $db->single("SELECT val FROM info WHERE id='total_hash_rate'"); + $total_gpu = $db->single("SELECT val FROM info WHERE id='total_gpu_hr'"); + $current = $aro->single("SELECT height FROM blocks ORDER by height DESC LIMIT 1"); + $miners = $db->single("SELECT COUNT(1) FROM miners"); + $last_won = $db->single("SELECT height FROM blocks ORDER by height DESC LIMIT 1"); + $last_won_time = $aro->single("SELECT date FROM blocks WHERE height=:h",[":h"=>$last_won]); + + echo json_encode(array("cpu_hr"=>$total_hr, "gpu_hr"=>$total_gpu, "current_block_height"=>$current, "last_won_block"=>$last_won, "last_won_block_time"=>$last_won_time, "miners"=>$miners, "fee"=>$pool_config['fee'])); + +} + diff --git a/arionum.ico b/arionum.ico deleted file mode 100755 index ecd5cec..0000000 Binary files a/arionum.ico and /dev/null differ diff --git a/cache/info.txt b/cache/info.txt deleted file mode 100644 index dd78695..0000000 --- a/cache/info.txt +++ /dev/null @@ -1 +0,0 @@ -{"status":"ok","data":{"difficulty":"45669041","block":"ReoyrSmEHtkHkSTowE4opskgow9hWx9nwbjcTqWtac68MNnaQYygW417sa7nrXZtvKc66McLfQfH8BEginMvNJC","height":19515,"public_key":"your public key","limit":1000000},"coin":"arionum"} \ No newline at end of file diff --git a/composer.json b/composer.json index df233e2..0792226 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,7 @@ "php": "^7.2", "ext-bcmath": "*", "ext-gmp": "*", + "ext-json": "*", "ext-openssl": "*", "rain/raintpl": "^3.1" }, diff --git a/composer.lock b/composer.lock index 125f3bf..dd59138 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "4d41c56a619c079b1370689ed4a5980f", + "content-hash": "48490d1ee52afda34388c89bc7556b5a", "packages": [ { "name": "rain/raintpl", @@ -51,16 +51,16 @@ "packages-dev": [ { "name": "squizlabs/php_codesniffer", - "version": "3.2.3", + "version": "3.3.2", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "4842476c434e375f9d3182ff7b89059583aa8b27" + "reference": "6ad28354c04b364c3c71a34e4a18b629cc3b231e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/4842476c434e375f9d3182ff7b89059583aa8b27", - "reference": "4842476c434e375f9d3182ff7b89059583aa8b27", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/6ad28354c04b364c3c71a34e4a18b629cc3b231e", + "reference": "6ad28354c04b364c3c71a34e4a18b629cc3b231e", "shasum": "" }, "require": { @@ -98,7 +98,7 @@ "phpcs", "standards" ], - "time": "2018-02-20T21:35:23+00:00" + "time": "2018-09-23T23:08:17+00:00" } ], "aliases": [], @@ -106,6 +106,11 @@ "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, - "platform": [], + "platform": { + "php": "^7.2", + "ext-bcmath": "*", + "ext-gmp": "*", + "ext-openssl": "*" + }, "platform-dev": [] } diff --git a/config.php b/config-sample.php similarity index 50% rename from config.php rename to config-sample.php index b1a1c6d..b647852 100644 --- a/config.php +++ b/config-sample.php @@ -12,9 +12,15 @@ // The access URL for node $pool_config['node_url'] = 'http://127.0.0.1:30000'; -// The maximum deadline that is allowed for pool miners +// The maximum deadline that is allowed for pool miners // cpu block type $pool_config['max_deadline'] = 1000000; +// The maximum deadline that is allowed for pool miners // gpu block type +$pool_config['max_deadline_gpu'] = 1000000; + +// Degradation rate of historical shares +$pool_config['pool_degradation'] = 0.02; + /* |-------------------------------------------------------------------------- | Database Configuration @@ -51,6 +57,10 @@ // The fee that the pool takes from the funds (default is 2%) $pool_config['fee'] = 0.02; +// If value exists, pool will use it for external hash validation - https://github.com/bogdanadnan/ArgonValidationService +// pool_config['validator_url'] = 'http://localhost:2000'; + + /* |-------------------------------------------------------------------------- | Payments Configuration @@ -68,3 +78,43 @@ // The minimum payout that is required $pool_config['min_payout'] = 3; + +// The message included in payments +// If no message is set the poolname will be used +$pool_config['payout_message'] = ''; + +/* +|-------------------------------------------------------------------------- +| Addiontal Pool Information / Settings +|-------------------------------------------------------------------------- +*/ + +$pool_config['pool_url'] = 'http://pooladdress.here'; +$pool_config['pool_name'] = 'Your Poolname here'; +$pool_config['handle'] = 'your Discord name here'; + +// percentage of historical share degradation per block. 0.05 is best for pool with big miners, 0.02 for pool with small miners +$pool_config['pool_degradation'] = 0.05; + +// how many blocks to look back for pending payments. large pool: set at 500, small pool >2000 +// do not forget to occasionally run a manual payment to clear old payments +$pool_config['blocks_paid'] = 5000; + +// how long are old payments shown on the website. Delete after x blocks, default 1000. Small pool set much higher +$pool_config['payout_history'] = 1000; + +$pool_config['payout_shedule'] = '1 hour'; + +// Defines if we should keep orphans or delete it instead // bit greedy for render as it will ask node for block details later +$pool_config['keep_orphans'] = false; + +/* +|-------------------------------------------------------------------------- +| Design Settings +|-------------------------------------------------------------------------- +*/ + + +$pool_config['template_directory'] = 'template/'; + + diff --git a/contrib/pool.sql b/contrib/pool.sql index 639d531..182b645 100644 --- a/contrib/pool.sql +++ b/contrib/pool.sql @@ -52,6 +52,7 @@ CREATE TABLE `rejects` ( CREATE TABLE `workers` ( `id` varchar(32) NOT NULL, + `workername` varchar(32) NOT NULL, `hashrate` int(11) NOT NULL, `updated` int(11) NOT NULL, `miner` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '', diff --git a/contrib/upgrade-gpu-hr.sql b/contrib/upgrade-gpu-hr.sql index 7ca97e8..ed3b9e7 100644 --- a/contrib/upgrade-gpu-hr.sql +++ b/contrib/upgrade-gpu-hr.sql @@ -1,3 +1,6 @@ ALTER TABLE `miners` ADD `gpuhr` INT NULL DEFAULT '0' AFTER `hashrate`; ALTER TABLE `workers` ADD `gpuhr` INT NULL DEFAULT '0' AFTER `hashrate`; INSERT INTO `info` (`id`, `val`) VALUES ('total_gpu_hr', ''); + +ALTER TABLE `workers` ADD `workername` varchar(32) NULL AFTER `id`; + diff --git a/db.php b/db.php index 8422090..f0eb0e9 100644 --- a/db.php +++ b/db.php @@ -1,20 +1,20 @@ \ No newline at end of file diff --git a/images/gpu_icon.png b/images/gpu_icon.png new file mode 100644 index 0000000..14f0752 Binary files /dev/null and b/images/gpu_icon.png differ diff --git a/images/gpu_icon.svg b/images/gpu_icon.svg new file mode 100644 index 0000000..e09bd43 --- /dev/null +++ b/images/gpu_icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/link_icon.svg b/images/link_icon.svg new file mode 100644 index 0000000..ca81e46 --- /dev/null +++ b/images/link_icon.svg @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/images/node_icon.svg b/images/node_icon.svg new file mode 100644 index 0000000..73f5ddd --- /dev/null +++ b/images/node_icon.svg @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/images/rig_icon.png b/images/rig_icon.png new file mode 100644 index 0000000..0418850 Binary files /dev/null and b/images/rig_icon.png differ diff --git a/images/rig_icon.svg b/images/rig_icon.svg new file mode 100644 index 0000000..3873a42 --- /dev/null +++ b/images/rig_icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/images/solo_icon.svg b/images/solo_icon.svg new file mode 100644 index 0000000..70735cf --- /dev/null +++ b/images/solo_icon.svg @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/index.php b/index.php index 08f6be6..971238a 100755 --- a/index.php +++ b/index.php @@ -1,11 +1,12 @@ assign("q", $q); +$tpl->assign("id", $id); +$tpl->assign("pool_name", $pool_config['pool_name']); +$tpl->assign("pool_url", $pool_config['pool_url']); +$tpl->assign("template_directory", $pool_config['template_directory']); $tpl->draw('header'); if ($q == "") { $current = $aro->row("SELECT * FROM blocks ORDER by height DESC LIMIT 1"); $last_won = $db->single("SELECT height FROM blocks ORDER by height DESC LIMIT 1"); + $orphancount = $db->single("select sum(orphan) from (SELECT orphan FROM blocks ORDER by height DESC LIMIT 100) ol where orphan>0"); + $oblockcount = 100; + //$oblockcount = $db->single("SELECT count(*) FROM blocks ORDER by height DESC LIMIT 100"); //comment out on new pool + //$oblockcount = min($oblockcount, 100); + $orphanpercent = round( ($orphancount / $oblockcount) * 100, 1) ; + $tpl->assign("orphanpercent", $orphanpercent); + $total_shares = 0; $shares = []; - $r = $db->run("SELECT * FROM miners "); - $miners = count($r); + $p = $db->run("SELECT * FROM miners WHERE hashrate>0 OR gpuhr>0"); + $miners = count($p); + + $r = $db->run("SELECT * FROM miners"); $total_historic = 0; $historic = []; @@ -43,57 +57,136 @@ $historic[] = $x; } - $total_hr = $db->single("SELECT val FROM info WHERE id='total_hash_rate'"); - $avg_hr = floor($total_hr / $miners); + $total_hr=$db->single("SELECT val FROM info WHERE id='total_hash_rate'"); + $avg_hr = number_format(($total_hr / $miners), 0); if ($miners == 0) { $avg_hr = 0; } + if ($total_hr >= 1000000) { $total_hr_text = number_format($total_hr / 1000000, 2); $total_hr_ext = "MH/s"; } elseif ($total_hr > 1000 && $total_hr < 1000000) { $total_hr_text = number_format($total_hr / 1000, 2); - $total_hr_ext = "KH/s"; + $total_hr_ext = "kH/s"; } else { - $total_hr_text = number_format($total_hr)." H/s"; + $total_hr_text = number_format($total_hr); $total_hr_ext = "H/s"; } - $total_hr=$db->single("SELECT val FROM info WHERE id='total_gpu_hr'"); + $tpl->assign("hr_ext", $total_hr_ext); + $tpl->assign("total_hr", $total_hr_text); + - if($total_hr>=1000000){ - $total_gpu_text=number_format($total_hr/1000000,2); + $total_gpuhr = $db->single("SELECT val FROM info WHERE id='total_gpu_hr'"); + $avg_gpuhr = number_format($total_gpuhr / $miners, 0); + if ($miners == 0) { + $avg_gpuhr = 0; + } + + if($total_gpuhr>=1000000){ + $total_gpu_text=number_format($total_gpuhr/1000000,2); $total_gpu_ext="MH/s"; } - elseif($total_hr>1000&&$total_hr<1000000) { - $total_gpu_text=number_format($total_hr/1000,2); - $total_gpu_ext="KH/s"; + elseif($total_gpuhr>1000&&$total_gpuhr<1000000) { + $total_gpu_text=number_format($total_gpuhr/1000,2); + $total_gpu_ext="kH/s"; } else { - $total_gpu_text=number_format($total_hr)." H/s"; + $total_gpu_text=number_format($total_gpuhr); $total_gpu_ext="H/s"; } - $tpl->assign("gpu_ext",$total_gpu_ext); - $tpl->assign("total_gpu",$total_gpu_text); + $tpl->assign("gpu_ext",$total_gpu_ext); + $tpl->assign("total_gpu",$total_gpu_text); - + $agem = time(); + $agem = $current['date']; + + $agem = ( time() - $current['date']); $tpl->assign("avg_hr", $avg_hr); - $tpl->assign("hr_ext", $total_hr_ext); - $tpl->assign("total_hr", $total_hr_text); + $tpl->assign("avg_gpuhr", $avg_gpuhr); $tpl->assign("miners", $miners); $tpl->assign("total_shares", $total_shares); $tpl->assign("total_historic", $total_historic); $tpl->assign("height", $current['height']); $tpl->assign("lastwon", $last_won); - $tpl->assign("total_paid", number_format($db->single("SELECT val FROM info WHERE id='total_paid'") / 1000000, 2)); + $tpl->assign("total_paid", number_format($db->single("SELECT val FROM info WHERE id='total_paid'") / 1000, 3)); $tpl->assign("shares", $shares); $tpl->assign("historic", $historic); $tpl->assign("difficulty", 200000000 - $current['difficulty']); + if ($current['height'] % 2) $blocktype = "GPU"; else $blocktype = "CPU"; + $tpl->assign("blocktype", $blocktype); + $tpl->assign("agem", $agem); + $tpl->draw("index"); +} elseif ($q == 'acc') { + + $r = $db->run("SELECT concat(id) AS id, workername, sum(hashrate) AS hashrate, sum(gpuhr) as gpuhr, updated FROM workers WHERE miner=:miner GROUP BY id", [":miner" => $id] ); + $b = []; + foreach ($r as $x) { + $x['hashrate'] = number_format($x['hashrate'], 0); + $x['gpuhr'] = number_format($x['gpuhr'], 0); + $x['updated'] = date('Y/m/d H:i:s', $x['updated']); + + $b[] = $x; + } + $tpl->assign("workers", $b); + + $yesterday=time()-86400; + $yesterday_block=$aro->single("SELECT height+1 FROM blocks WHERE date<=$yesterday ORDER by height DESC LIMIT 1"); + $last_payment_txn=$db->single("SELECT txn FROM payments WHERE address=:miner AND done=1 ORDER by height DESC LIMIT 1", [":miner" => $id]); + $last_payment_time=$aro->single("SELECT date FROM transactions WHERE id=$last_payment_txn"); + $last_payment=$db->single("SELECT SUM(val) FROM payments WHERE txn=:lasttxn AND done=1", [":lasttxn" => $last_payment_txn]); + $past_24h=$db->single("SELECT SUM(val) FROM payments WHERE address=:miner AND height>=$yesterday_block AND done=1", [":miner" => $id]); + + $r = $db->run("SELECT * FROM miners WHERE id=:miner", [":miner" => $id] ); + $b = []; + foreach ($r as $x) { + $x['hashrate'] = number_format($x['hashrate'], 0); + $x['gpuhr'] = number_format($x['gpuhr'], 0); + if ($x['bestdl'] == 1000000) { + $x['bestdl'] = "No nonce submitted"; + } + + $x['pending'] = number_format($x['pending'], 2); + $x['total_paid'] = number_format($x['total_paid'], 2); + $x['last_payment'] = number_format($last_payment, 2); + $x['last_paid'] = date('Y/m/d H:i:s', $last_payment_time); + if ($last_payment_time == false) { + $x['last_paid'] = "Payment in process"; + } + if ($last_payment == 0 ) { + $x['last_paid'] = "No payment yet"; + } + $x['last_txn'] = $last_payment_txn; + $x['24h_paid'] = number_format($past_24h,2); + $x['updated'] = date('Y/m/d H:i:s', $x['updated']); + $b[] = $x; + } + $tpl->assign("account", $b); + + + $r = $db->run("SELECT sum(hashrate) / count(id) AS cpuhr, sum(gpuhr) / count(id) as gpuhr FROM workers WHERE miner=:miner GROUP BY id", [":miner" => $id]); + $c['cpuhr'] = 0; + $c['gpuhr'] = 0; + foreach ($r as $x) { + $c['cpuhr'] = $c['cpuhr'] + $x['cpuhr']; + $c['gpuhr'] = $c['gpuhr'] + $x['gpuhr']; + } + + $tpl->assign("hashrate", $c); + + + $tpl->draw("account"); + } elseif ($q == "blocks") { - $r = $db->run("SELECT * FROM blocks ORDER by height DESC LIMIT 100"); + $limit = 1000; + + if ($pool_config['keep_orphans'] == true) $limit = 100; + + $r = $db->run("SELECT * FROM blocks ORDER by height DESC LIMIT $limit"); $b = []; foreach ($r as $x) { $x['reward'] = number_format($x['reward'], 2); @@ -101,25 +194,48 @@ } $tpl->assign("blocks", $b); + $tpl->assign("limit", $limit); $tpl->draw("blocks"); } elseif ($q == "payments") { - $r = $db->run("SELECT id,address,val,done,txn FROM payments ORDER by id DESC LIMIT 5000"); + $r = $db->run("SELECT id,address,val,done,height,txn FROM payments ORDER by id DESC LIMIT 5000"); $b = []; foreach ($r as $x) { if ($x['done'] == 0) { - $x['txn'] = "Pending"; + $x['height'] = "Pending"; } $b[] = $x; } $tpl->assign("payments", $b); $tpl->draw("payments"); -} elseif ($q == "benchmarks") { - $tpl->draw("benchmarks"); +//} elseif ($q == "benchmarks") { +// $tpl->draw("benchmarks"); } elseif ($q == "info") { + + $tpl->assign("minpayout", number_format($pool_config['min_payout'],2)); + $tpl->assign("fee", number_format($pool_config['fee']*100,1)); + $tpl->assign("cpu_deadline", number_format($pool_config['max_deadline'])); + $tpl->assign("gpu_deadline", number_format($pool_config['max_deadline_gpu'])); + $tpl->assign("poolwallet", $pool_config['address']); + $tpl->assign("payout_shedule", $pool_config['payout_shedule']); + $tpl->assign("current_reward", $pool_config['current_reward']*100,0); + $tpl->assign("miner_reward", $pool_config['miner_reward']*100,0); + $tpl->assign("historic_reward", $pool_config['historic_reward']*100,0); + $tpl->assign("server", gethostname()); + $tpl->assign("pool_url", $pool_config['pool_url']); + $tpl->assign("pool_degradation", number_format($pool_config['pool_degradation']*100,1)); + $tpl->assign("handle", $pool_config['handle']); + $tpl->draw("info"); +} elseif ($q == "benchmarks") { + $tpl->draw("benchmarks"); +} elseif ($q == "links") { + $tpl->draw("links"); +} elseif ($q == "news") { + $tpl->draw("news"); } $tpl = new Tpl(); $tpl->assign("q", $q); $tpl->draw("footer"); + diff --git a/manualpayment-sendall.php b/manualpayment-sendall.php new file mode 100755 index 0000000..9104c6e --- /dev/null +++ b/manualpayment-sendall.php @@ -0,0 +1,160 @@ + 3600) { + system("rm -rf $pid112"); + } + die("\n\n### RUNNING ### -- PID: $pid112\n\n"); +} +system("touch $pid112"); +function shut_down() +{ + global $pid112; + system("rm -rf $pid112"); + echo "\n# ShutDown #\n"; + +} + +register_shutdown_function('shut_down'); +############################################### + +set_time_limit(0); +if (PHP_SAPI !== 'cli') { + die('This should only be run as cli'); +} + +require_once __DIR__.'/db.php'; + +if ($pool_config['payout_history'] == null) { + die('Payout History variable not set in config'); +} + + +function pay_post($url, $data = []) +{ + global $pool_config; + $peer = $pool_config['node_url']; + $postdata = http_build_query( + [ + 'data' => json_encode($data), + 'coin' => ' arionum', + ] + ); + + $opts = [ + 'http' => + [ + 'timeout' => '300', + 'method' => 'POST', + 'header' => 'Content-type: application/x-www-form-urlencoded', + 'content' => $postdata, + ], + ]; + + $context = stream_context_create($opts); + + $result = file_get_contents($peer.$url, false, $context); + return json_decode($result, true); +} + + +echo "\n----------------------------------------------------------------------------------\n"; +$current = $aro->single('SELECT height FROM blocks ORDER by height DESC LIMIT 1'); +echo "Current block $current\n"; + +$r = $db->run( + 'SELECT DISTINCT block FROM payments WHERE height<:h AND done=0', + [':h' => $current - 10] +); +if (count($r) === 0) { + die("No payments pending\n"); +} + +// check for orphan blocks +foreach ($r as $x) { + echo "Checking $x[block]\n"; + $s = $aro->single('SELECT COUNT(1) FROM blocks WHERE id=:id', [':id' => $x['block']]); + if ($s === 0) { +// dit kunnen we dus aanpassen naar orphaned. block wordt niet nog een keer meegenomen want verdwijnt uit payments + if ($pool_config['keep_orphans'] !== true) { + $db->run('DELETE FROM blocks WHERE id=:id', [':id' => $x['block']]); + } +// nu halen we de payments weg en wordt het block niet opnieuw geselecteerd bij de volgende payment cycle + $db->run('DELETE FROM payments WHERE block=:id', [':id' => $x['block']]); + echo "Deleted block: $x[block]\n"; + } +} + +$total_paid = 0; +$r = $db->run( + 'SELECT SUM(val) as v, address FROM payments WHERE height<:h AND done=0 GROUP by address', + [':h' => $current - 10] +); +foreach ($r as $x) { + if ($x['v'] < $pool_config['min_payout']) { + continue; + } + $fee = $x['v'] * 0.0025; + if ($fee < 0.00000001) { + $fee = 0.00000001; + } + if ($fee > 10) { + $fee = 10; + } + $val = number_format($x['v'] - $fee, 8, '.', ''); + #$val=intval($val); + $public_key = $pool_config['public_key']; + $private_key = $pool_config['private_key']; + $message = $pool_config['payout_message']; + if ($message == null) { + $message = $pool_config['pool_name']; + } + $res = pay_post('/api.php?q=send', [ + 'dst' => $x['address'], + 'val' => $val, + 'private_key' => $private_key, + 'public_key' => $public_key, + 'version' => 1, + 'message' => $message, + ]); + echo "$val\n"; + echo "$x[address]\n"; + if ($res['status'] !== 'ok') { + print("ERROR: $res[data]\n"); + } else { + $total_paid += $x['v']; + + echo "Transaction sent - $x[address] - $val! Transaction id: $res[data]\n"; + $db->run( + 'UPDATE payments SET txn=:txn, done=1 WHERE address=:address AND height<:h AND done=0', + [ + ':h' => $current - 10, + ':txn' => $res['data'], + ':address' => $x['address'], + ] + ); + $db->run('UPDATE miners SET total_paid=total_paid + :h WHERE id=:p', [':h' => $x['v'], ':p' => $x['address']]); + echo "DB updated\n"; + } +} + +$old = $db->single("SELECT val FROM info WHERE id='total_paid'"); +$new = $old + $total_paid; +echo "Total paid: $new\n"; + +$db->run("UPDATE info SET val=:s WHERE id='total_paid'", [':s' => $new]); +$not = $db->single('SELECT SUM(val) FROM payments WHERE done=0'); +echo "Pending balance: $not\n"; + +$db->run('DELETE FROM payments WHERE done=1 AND height<:h', [':h' => $current - $pool_config['payout_history']]); + diff --git a/mine.php b/mine.php index 5f2002d..b9163af 100644 --- a/mine.php +++ b/mine.php @@ -1,5 +1,6 @@ 1, CURLOPT_CONNECTTIMEOUT => 5, - CURLOPT_TIMEOUT => 20, - CURLOPT_URL => $url, - CURLOPT_POST => 1, - CURLOPT_POSTFIELDS => $post, + CURLOPT_TIMEOUT => 20, + CURLOPT_URL => $url, + CURLOPT_POST => 1, + CURLOPT_POSTFIELDS => $post, ]); $resp = curl_exec($curl); @@ -23,53 +24,111 @@ function curl_post($url, $post) $q = san($_GET['q']); $max_dl = $pool_config['max_deadline']; +$max_dl_network = $pool_config['max_deadline_network']; -if ($q == "info") { +if ($q === 'info') { $time = time(); if ($_GET['hashrate'] > 0) { $miner = san($_GET['address']); - if ($miner == '3uj7kyCcy5q6A1s1DQkgb58zXz6mLsjHpaoEkYxL6TjzkRP7muGZaXeGNcqk1bTgpQTVDuwPoKh49dGQn8bMwdBZ' || $miner == '4EtWPLwbUAs2JNnqb8yprvAKYCfA4dU3bJTRm2KjnM6f811MAh9qr7wrHABCHrnWPTdgmEF8iXqRBu2XSPHMuHnR') { - die("invalid wallet address. This address comes from a broken wallet file!"); + if ($miner === '3uj7kyCcy5q6A1s1DQkgb58zXz6mLsjHpaoEkYxL6TjzkRP7muGZaXeGNcqk1bTgpQTVDuwPoKh49dGQn8bMwdBZ' || + $miner === '4EtWPLwbUAs2JNnqb8yprvAKYCfA4dU3bJTRm2KjnM6f811MAh9qr7wrHABCHrnWPTdgmEF8iXqRBu2XSPHMuHnR') { + die('invalid wallet address. This address comes from a broken wallet file!'); + } + + $worker = $_GET['worker']; + $minerid = $_GET['id']; + + $hr = (int)round($_GET['hashrate'],0); + $gpuhr = (int)round($_GET['gpuhr'],0) + (int)round($_GET['hrgpu'],0); + + if (trim($minerid) === '') { + $workerid = substr(substr($miner,0,15) . '.' . substr($worker,0,15),0,31); + } else { + $workerid = substr($minerid . '.' . substr($worker,0,15),0,31); } - $worker = md5($miner.$_GET['worker'].$ip); - $hr = intval($_GET['hashrate']); - $gpuhr=intval($_GET['gpuhr']+$_GET['hrgpu']); - $bind = [":id" => $worker, ":hr" => $hr, ":hr2" => $hr, ":miner" => $miner, ":ip" => $ip, ":ip2" => $ip, ":gpuhr"=>$gpuhr, ":gpuhr2"=>$gpuhr]; + $bind = [ + ':id' => $workerid, + ':workername' => $worker, + ':workername2' => $worker, + ':hr' => $hr, + ':hr2' => $hr, + ':miner' => $miner, + ':ip' => $ip, + ':ip2' => $ip, + ':gpuhr' => $gpuhr, + ':gpuhr2' => $gpuhr, + ]; + + //fix not unique rows + $db->run( + 'UPDATE workers SET + id = :id, workername = :workername where id = :workername2', + $bind + ); + + // fix Dan's misreporting + if ($gpuhr == 0){ + $f = file_get_contents('cache/info.txt'); + $g = json_decode($f, true); + if ($g['data']['height'] % 2 == 1) { + $db->run( + 'INSERT INTO workers + SET id = :id, updated = UNIX_TIMESTAMP(), miner = :miner, ip = :ip, gpuhr = :hr + ON DUPLICATE KEY UPDATE updated = UNIX_TIMESTAMP(), ip = :ip2, gpuhr = :hr2', + $bind + ); + } + if ($g['data']['height'] % 2 == 0) { + $db->run( + 'INSERT INTO workers + SET id = :id, hashrate = :hr, updated = UNIX_TIMESTAMP(), miner = :miner, ip = :ip + ON DUPLICATE KEY UPDATE updated = UNIX_TIMESTAMP(), ip = :ip2, hashrate = :hr2', + $bind + ); + } + } + if ($gpuhr !== 0){ + $db->run( - "INSERT into workers SET id=:id, hashrate=:hr,updated=UNIX_TIMESTAMP(), miner=:miner, ip=:ip, gpuhr=:gpuhr ON DUPLICATE KEY UPDATE updated=UNIX_TIMESTAMP(), hashrate=:hr2, ip=:ip2, gpuhr=:gpuhr2", + 'INSERT INTO workers + SET id = :id, workername = :workername, hashrate = :hr, updated = UNIX_TIMESTAMP(), miner = :miner, ip = :ip, gpuhr = :gpuhr + ON DUPLICATE KEY UPDATE updated = UNIX_TIMESTAMP(), workername = :workername2, hashrate = :hr2, ip = :ip2, gpuhr = :gpuhr2', $bind ); + } } - readfile("cache/info.txt"); + readfile('cache/info.txt'); exit; -} elseif ($q == "submitNonce") { - $reject = $db->single("SELECT COUNT(1) FROM rejects WHERE ip=:ip AND data>UNIX_TIMESTAMP()-20", [":ip" => $ip]); - if ($reject == 1) { - api_err("rejected"); +} + +if ($q === 'submitNonce') { + $reject = $db->single('SELECT COUNT(1) FROM rejects WHERE ip=:ip AND data>UNIX_TIMESTAMP()-20', [':ip' => $ip]); + if ($reject === 1) { + api_err('rejected'); } $nonce = san(substr($_POST['nonce'], 0, 120)); $argon = $_POST['argon']; $address = san($_POST['address']); - $chk = $db->single("SELECT count(1) FROM nonces WHERE nonce=:nonce", [":nonce" => $nonce]); - if ($chk != 0) { - $db->run("INSERT into abusers SET miner=:miner, nonce=:nonce", [":miner" => $address, ":nonce" => $nonce]); - api_err("duplicate"); + $chk = $db->single('SELECT count(1) FROM nonces WHERE nonce=:nonce', [':nonce' => $argon]); + if ($chk !== 0) { + $db->run('INSERT into abusers SET miner=:miner, nonce=:nonce', [':miner' => $address, ':nonce' => $argon]); + api_err('duplicate'); exit; } - $db->run("INSERT IGNORE into nonces SET nonce=:nonce", [":nonce" => $nonce]); + $db->run('INSERT IGNORE into nonces SET nonce=:nonce', [':nonce' => $argon]); - $f = file_get_contents($pool_config['node_url']."/mine.php?q=info"); + $f = file_get_contents($pool_config['node_url'].'/mine.php?q=info'); $g = json_decode($f, true); - - if ($g['data']['height'] != $_POST['height'] && $_POST['height'] > 1) { + + if ((int)$_POST['height'] > 1 && $g['data']['height'] !== (int)$_POST['height']) { api_err('stale block'); } @@ -77,45 +136,52 @@ function curl_post($url, $post) $argon2 = '$argon2i$v=19$m=524288,t=1,p=1'.$argon; - if($g['data']['height']>=80000&&$g['data']['height']%2!=0) $argon2='$argon2i$v=19$m=16384,t=4,p=4'.$argon; + if ($g['data']['height'] >= 80000 && $g['data']['height'] % 2 !== 0) { + $argon2 = '$argon2i$v=19$m=16384,t=4,p=4'.$argon; + } - $base = "$public_key-$nonce-".$g['data']['block']."-".$g['data']['difficulty']; + $base = "$public_key-$nonce-".$g['data']['block'].'-'.$g['data']['difficulty']; - if (!password_verify($base, $argon2)) { - api_err("Invalid argon - $base - $argon2"); + + if (isset($pool_config['validator_url'])) { // If validator url exists, use it for hash validation + $res = file_get_contents($pool_config['validator_url'].'/validate?argon='. $argon2 . '&base=' . $base); + if ($res !== 'VALID') { + api_err("Invalid argon - $base - $argon2"); + } + } else { // Validate hash old fashion way + if (!password_verify($base, $argon2)) { + api_err("Invalid argon - $base - $argon2"); + } } + $hash = $base.$argon2; for ($i = 0; $i < 5; $i++) { - $hash = hash("sha512", $hash, true); + $hash = hash('sha512', $hash, true); } - $hash = hash("sha512", $hash); + $hash = hash('sha512', $hash); $m = str_split($hash, 2); - $duration = hexdec($m[10]).hexdec($m[15]).hexdec($m[20]).hexdec($m[23]).hexdec($m[31]).hexdec($m[40]).hexdec($m[45]).hexdec($m[55]); + $duration = hexdec($m[10]).hexdec($m[15]).hexdec($m[20]).hexdec($m[23]). + hexdec($m[31]).hexdec($m[40]).hexdec($m[45]).hexdec($m[55]); $duration = ltrim($duration, '0'); $result = gmp_div($duration, $g['data']['difficulty']); if ($result > 0 && $result <= 240) { $private_key = $pool_config['private_key']; $postdata = http_build_query( - [ - 'argon' => $argon, - 'nonce' => $nonce, - 'private_key' => $private_key, - 'public_key' => $public_key, - ] + compact('argon', 'nonce', 'private_key', 'public_key') ); $opts = [ 'http' => [ - 'method' => 'POST', - 'header' => 'Content-type: application/x-www-form-urlencoded', + 'method' => 'POST', + 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata, 'timeout' => 120, ], @@ -123,27 +189,27 @@ function curl_post($url, $post) $context = stream_context_create($opts); - $res = file_get_contents($pool_config['node_url']."/mine.php?q=submitNonce", false, $context); + $res = file_get_contents($pool_config['node_url'].'/mine.php?q=submitNonce', false, $context); $data = json_decode($res, true); - if ($data['status'] == "ok") { - $bl = $aro->row("SELECT * FROM blocks ORDER by height DESC LIMIT 1"); - $added = $db->single("SELECT COUNT(1) FROM blocks WHERE id=:id", [":id" => $bl['id']]); + if ($data['status'] === 'ok') { + $bl = $aro->row('SELECT * FROM blocks ORDER by height DESC LIMIT 1'); + $added = $db->single('SELECT COUNT(1) FROM blocks WHERE id=:id', [':id' => $bl['id']]); - if ($bl['generator'] == $pool_config['address'] && $added == 0) { + if ($added === 0 && $bl['generator'] === $pool_config['address']) { $reward = $aro->single( - "SELECT val FROM transactions WHERE block=:bl AND version=0", - [":bl" => $bl['id']] + "SELECT val FROM transactions WHERE block=:bl AND message='' AND version=0", + [':bl' => $bl['id']] ); - if ($reward == 0) { - api_err("something went wrong"); + if ($reward === 0) { + api_err('something went wrong'); } $original_reward = $reward; - $r = $db->run("SELECT * FROM miners WHERE shares>0 OR historic>0"); + $r = $db->run('SELECT * FROM miners WHERE shares>0 OR historic>0'); foreach ($r as $x) { $total_shares += $x['shares']; $total_historic += $x['historic']; } - $reward = $reward * (1 - $pool_config['fee']); + $reward *= (1 - $pool_config['fee']); $miner_reward = $pool_config['miner_reward'] * $reward; $historic_reward = $pool_config['historic_reward'] * $reward; $current_reward = $pool_config['current_reward'] * $reward; @@ -156,56 +222,59 @@ function curl_post($url, $post) if ($x['historic'] > 0) { $crw += ($x['historic'] / $total_historic) * $historic_reward; } - if ($x['id'] == $address) { + if ($x['id'] === $address) { $crw += $miner_reward; } $db->run( "INSERT into payments SET address=:to, block=:bl, height=:height, val=:val, txn='',done=0", - [":val" => $crw, ":height" => $bl['height'], ":bl" => $bl['id'], ":to" => $x['id']] + [':val' => $crw, ':height' => $bl['height'], ':bl' => $bl['id'], ':to' => $x['id']] ); } $db->run("INSERT into payments SET address=:to, block=:bl, height=:height, val=:val, txn='',done=0", [ - ":val" => $original_reward * $pool_config['fee'], - ":height" => $bl['height'], - ":bl" => $bl['id'], - ":to" => $pool_config['fee_address'], + ':val' => $original_reward * $pool_config['fee'], + ':height' => $bl['height'], + ':bl' => $bl['id'], + ':to' => $pool_config['fee_address'], ]); - $db->run("INSERT IGNORE into blocks SET reward=:reward, id=:id, height=:height, miner=:miner", [ - ":id" => $bl['id'], - ":miner" => $address, - ":height" => $bl['height'], - ":reward" => $original_reward, + $db->run('INSERT IGNORE into blocks SET reward=:reward, id=:id, height=:height, miner=:miner', [ + ':id' => $bl['id'], + ':miner' => $address, + ':height' => $bl['height'], + ':reward' => $original_reward, ]); - api_echo("accepted"); + api_echo('accepted'); } - api_err("rejected - block changed - 2"); + api_err('rejected - block changed - 2'); } - api_err("rejected - block changed - 1"); + api_err('rejected - block changed - 1'); } elseif ($result > 0 && $result <= $max_dl) { - $share = ceil(($max_dl - $result) / 100); + //$share = ceil(($max_dl_network - $result) / 1000); + $share = ceil(($max_dl_network / $max_dl) * 100); $db->run( - "INSERT INTO miners SET id=:id, shares=shares+:sh, updated=UNIX_TIMESTAMP(),bestdl=:bdl ON DUPLICATE KEY UPDATE shares=shares+:sh2, updated=UNIX_TIMESTAMP()", - [":id" => $address, ":sh" => $share, ":sh2" => $share, ":bdl" => intval($result)] + 'INSERT INTO miners + SET id = :id, shares = shares + :sh, updated = UNIX_TIMESTAMP(), bestdl = :bdl + ON DUPLICATE KEY UPDATE shares = shares + :sh2, updated = UNIX_TIMESTAMP()', + [':id' => $address, ':sh' => $share, ':sh2' => $share, ':bdl' => (int)$result] ); $db->run( - "UPDATE miners SET bestdl=:bdl WHERE id=:id AND bestdl>:bdl2", - [":id" => $address, ":bdl" => intval($result), ":bdl2" => intval($result)] + 'UPDATE miners SET bestdl=:bdl WHERE id=:id AND bestdl>:bdl2', + [':id' => $address, ':bdl' => (int)$result, ':bdl2' => (int)$result] ); - api_echo("accepted"); + api_echo('accepted'); } else { - $db->run("DELETE FROM nonces WHERE nonce=:nonce", ["nonce" => $nonce]); + $db->run('DELETE FROM nonces WHERE nonce=:nonce', ['nonce' => $argon]); $db->run( - "INSERT into rejects SET ip=:ip, data=UNIX_TIMESTAMP() ON DUPLICATE KEY update data=UNIX_TIMESTAMP()", - [":ip" => $ip] + 'INSERT into rejects SET ip=:ip, data=UNIX_TIMESTAMP() ON DUPLICATE KEY update data=UNIX_TIMESTAMP()', + [':ip' => $ip] ); api_err("rejected - $result"); } - api_err("rejected - block changed"); -} else { - api_err("invalid command"); + api_err('rejected - block changed'); } + +api_err('invalid command'); diff --git a/payments.php b/payments.php old mode 100644 new mode 100755 index 66832b7..9655ecc --- a/payments.php +++ b/payments.php @@ -22,17 +22,26 @@ function shut_down() global $pid112; system("rm -rf $pid112"); echo "\n# ShutDown #\n"; + } -register_shutdown_function("shut_down"); +register_shutdown_function('shut_down'); ############################################### set_time_limit(0); -if (php_sapi_name() !== 'cli') { - die("This should only be run as cli"); +if (PHP_SAPI !== 'cli') { + die('This should only be run as cli'); +} + +require_once __DIR__.'/db.php'; + +if ($pool_config['payout_history'] == null) { + die('Payout History variable not set in config'); +} +if ($pool_config['blocks_paid'] == null) { + die('Blocks Paid variable not set in config'); } -require_once("db.php"); function pay_post($url, $data = []) { @@ -41,16 +50,16 @@ function pay_post($url, $data = []) $postdata = http_build_query( [ 'data' => json_encode($data), - "coin" => " arionum", + 'coin' => ' arionum', ] ); $opts = [ 'http' => [ - 'timeout' => "300", - 'method' => 'POST', - 'header' => 'Content-type: application/x-www-form-urlencoded', + 'timeout' => '300', + 'method' => 'POST', + 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata, ], ]; @@ -58,60 +67,44 @@ function pay_post($url, $data = []) $context = stream_context_create($opts); $result = file_get_contents($peer.$url, false, $context); - $res = json_decode($result, true); - return $res; + return json_decode($result, true); } -$hour = date("H"); -$min = date("i"); - -$blocks_paid = 500; -if ($hour == 10 && $min < 20) { - $blocks_paid = 5000; -} - echo "\n----------------------------------------------------------------------------------\n"; -$current = $aro->single("SELECT height FROM blocks ORDER by height DESC LIMIT 1"); +$current = $aro->single('SELECT height FROM blocks ORDER by height DESC LIMIT 1'); echo "Current block $current\n"; - -$db->run("DELETE FROM miners WHERE historic+shares<=20"); -$db->run("UPDATE miners SET gpuhr=(SELECT SUM(gpuhr) FROM workers WHERE miner=miners.id AND updated>UNIX_TIMESTAMP()-3600)"); -$db->run("UPDATE miners SET hashrate=(SELECT SUM(hashrate) FROM workers WHERE miner=miners.id AND updated>UNIX_TIMESTAMP()-3600)"); -$db->run( - "UPDATE miners SET pending=(SELECT SUM(val) FROM payments WHERE done=0 AND payments.address=miners.id AND height>=:h)", - [":h" => $current - $blocks_paid] -); - - $r = $db->run( - "SELECT DISTINCT block FROM payments WHERE height<:h AND done=0 AND height>=:h2", - [":h" => $current - 10, ":h2" => $current - $blocks_paid] + 'SELECT DISTINCT block FROM payments WHERE height<:h AND done=0 AND height>=:h2', + [':h' => $current - 10, ':h2' => $current - $pool_config['blocks_paid']] ); -if (count($r) == 0) { +if (count($r) === 0) { die("No payments pending\n"); } -$db->run("DELETE FROM miners WHERE shares=0 AND historic=0 AND updatedrun("DELETE FROM workers WHERE updatedsingle("SELECT COUNT(1) FROM blocks WHERE id=:id", [":id" => $x['block']]); - if ($s == 0) { - $db->run("DELETE FROM blocks WHERE id=:id", [":id" => $x['block']]); - $db->run("DELETE FROM payments WHERE block=:id", [":id" => $x['block']]); - echo "Deleted block: $x[block]\n"; + $s = $aro->single('SELECT COUNT(1) FROM blocks WHERE id=:id', [':id' => $x['block']]); + if ($s === 0) { + + // dit kunnen we dus aanpassen naar orphaned. block wordt niet nog een keer meegenomen want verdwijnt uit payments + + // if defined, keep our block so we can display it as orphaned + if ($pool_config['keep_orphans'] !== true) { + $db->run('DELETE FROM blocks WHERE id=:id', [':id' => $x['block']]); + } + // nu halen we de payments weg en wordt het block niet opnieuw geselecteerd bij de volgende payment cycle + $db->run('DELETE FROM payments WHERE block=:id', [':id' => $x['block']]); + echo "Deleted payments for block: $x[block]\n"; } } - $total_paid = 0; $r = $db->run( - "SELECT SUM(val) as v, address FROM payments WHERE height<:h AND height>=:h2 AND done=0 GROUP by address", - [":h" => $current - 10, ":h2" => $current - $blocks_paid] + 'SELECT SUM(val) as v, address FROM payments WHERE height<:h AND height>=:h2 AND done=0 GROUP by address', + [':h' => $current - 10, ':h2' => $current - $pool_config['blocks_paid']] ); foreach ($r as $x) { if ($x['v'] < $pool_config['min_payout']) { @@ -124,36 +117,40 @@ function pay_post($url, $data = []) if ($fee > 10) { $fee = 10; } - $val = number_format($x['v'] - $fee, 8, ".", ""); + $val = number_format($x['v'] - $fee, 8, '.', ''); #$val=intval($val); $public_key = $pool_config['public_key']; $private_key = $pool_config['private_key']; - - $res = pay_post("/api.php?q=send", [ - "dst" => $x['address'], - "val" => $val, - "private_key" => $private_key, - "public_key" => $public_key, - "version" => 1, + $message = $pool_config['payout_message']; + if ($message == null) { + $message = $pool_config['pool_name']; + } + $res = pay_post('/api.php?q=send', [ + 'dst' => $x['address'], + 'val' => $val, + 'private_key' => $private_key, + 'public_key' => $public_key, + 'version' => 1, + 'message' => $message, ]); echo "$val\n"; echo "$x[address]\n"; - if ($res['status'] != "ok") { + if ($res['status'] !== 'ok') { print("ERROR: $res[data]\n"); } else { $total_paid += $x['v']; echo "Transaction sent - $x[address] - $val! Transaction id: $res[data]\n"; $db->run( - "UPDATE payments SET txn=:txn, done=1 WHERE address=:address AND height<:h AND done=0 AND height>=:h2", + 'UPDATE payments SET txn=:txn, done=1 WHERE address=:address AND height<:h AND done=0 AND height>=:h2', [ - ":h" => $current - 10, - ":h2" => $current - $blocks_paid, - ":txn" => $res['data'], - ":address" => $x['address'], + ':h' => $current - 10, + ':h2' => $current - $pool_config['blocks_paid'], + ':txn' => $res['data'], + ':address' => $x['address'], ] ); - $db->run("UPDATE miners SET total_paid=total_paid + :h WHERE id=:p", [":h" => $x['v'], ":p" => $x['address']]); + $db->run('UPDATE miners SET total_paid=total_paid + :h WHERE id=:p', [':h' => $x['v'], ':p' => $x['address']]); echo "DB updated\n"; } } @@ -162,14 +159,9 @@ function pay_post($url, $data = []) $new = $old + $total_paid; echo "Total paid: $new\n"; -$db->run("UPDATE info SET val=:s WHERE id='total_paid'", [":s" => $new]); -$not = $db->single("SELECT SUM(val) FROM payments WHERE done=0"); +$db->run("UPDATE info SET val=:s WHERE id='total_paid'", [':s' => $new]); +$not = $db->single('SELECT SUM(val) FROM payments WHERE done=0'); echo "Pending balance: $not\n"; +$db->run('DELETE FROM payments WHERE done=1 AND height<:h', [':h' => $current - $pool_config['payout_history']]); -$db->run( - "UPDATE miners SET pending=(SELECT SUM(val) FROM payments WHERE done=0 AND payments.address=miners.id AND height>=:h)", - [":h" => $current - $blocks_paid] -); - -$db->run("DELETE FROM payments WHERE done=1 AND height<:h", [":h" => $current - 1000]); diff --git a/pool.css b/pool.css new file mode 100644 index 0000000..a8c608e --- /dev/null +++ b/pool.css @@ -0,0 +1,45 @@ +@media only screen and (max-width: 600px) { + .cbox {float:left;width:100%;padding:10px;margin:10px;border:5px solid snow;} + + .cbox-text {height:100%;width:50%;float:left;background-color:salmon;text-align:center;color:white;padding-top:10%;padding-bottom:10%;} + .cbox-text span {border:1px solid silver;border-radius:10px;padding:5px;background-color:#212F3C;} + .cbox-image {width:40%;max-width:40%;float:left;border-width:0px;right:1px;position:relative;padding-left:5px;} + + .welcome-info {display:none;} + .welcome-name {font-size:25px; color:brown;} +} +@media only screen and (max-width: 800px) { + .welcome-info {display:none;} + .welcome-name {font-size:25px; color:brown;} +} +@media only screen and (min-width: 600px) { + .cbox {float:left;width:45%;padding:10px;margin:10px;border:5px solid snow;} + + .cbox-text {height:100%;min-height:170px;width:50%;float:left;background-color:salmon;text-align:center;color:white;padding-top:10%;padding-bottom:10%;} + .cbox-text span {border:1px solid silver;border-radius:10px;padding:5px;background-color:#212F3C;} + .cbox-image {width:30%;float:left;border-width:0px;right:1px;position:relative;padding-left:5px;} + + .welcome-info {float:left;margin-left:20px;} + .welcome-name {float:left;font-size:25px; color:brown;} +} + +.odd{ + background-color:snow !important; +} +.even{ + --background-color:antiquewhite; + background-color:linen; +} +a { + color: #0199E2 !important; +} + + .navbar-logo-image {font-size:16px !important;} + .welcome {padding-left:50px;font-size:25px; color:brown;height:100%;font-weight:bold;} + .counter {padding-left:50px;top:0px;} + .link {cursor:pointer;} + +#update +.sidebar-left-content{ + background-color:#3d3f48 !important; +} diff --git a/poolsanity.php b/poolsanity.php old mode 100644 new mode 100755 index 5bcbd93..51c19e1 --- a/poolsanity.php +++ b/poolsanity.php @@ -1,4 +1,5 @@ single("SELECT height FROM blocks ORDER by height DESC LIMIT 1"); - if ($ck != $current && $ck) { + //$ck = $aro->single('SELECT height FROM blocks ORDER by height DESC LIMIT 1'); + $ck = $aro->single('SELECT MAX(height) FROM blocks'); + //if ($ck !== $current && $ck) { + if ($ck !== $current) { $current = $ck; - $db->run("UPDATE miners SET historic=historic*0.95+shares, shares=0,bestdl=1000000"); - $db->run("TRUNCATE table nonces"); + $db->run('UPDATE miners SET historic=historic+shares-historic*:dr, shares=0,bestdl=1000000', [':dr' => $pool_config['pool_degradation']]); + $db->run('TRUNCATE table nonces'); $r=$db->run("SELECT * FROM miners WHERE historic>0"); $total_hr=0; @@ -61,30 +68,42 @@ function shut_down() echo "Total hr: $total_hr\n"; $db->run("UPDATE info SET val=:thr WHERE id='total_hash_rate'",array(":thr"=>$total_hr)); $db->run("UPDATE info SET val=:thr WHERE id='total_gpu_hr'",array(":thr"=>$total_gpu)); - } + $max_dl = ($current % 2) ? $pool_config['max_deadline_gpu'] : $pool_config['max_deadline']; - $max_dl = $pool_config['max_deadline']; - $cache_file = "cache/info.txt"; + $cache_file = __DIR__."/cache/info.txt"; - $f = file_get_contents($pool_config['node_url']."/mine.php?q=info"); + $f = file_get_contents($pool_config['node_url'].'/mine.php?q=info'); $g = json_decode($f, true); $res = [ - "difficulty" => $g['data']['difficulty'], - "block" => $g['data']['block'], - "height" => $g['data']['height'], - "public_key" => $pool_config['public_key'], - "limit" => $max_dl, - "recommendation"=> $g['data']['recommendation'], - "argon_mem" => $g['data']['argon_mem'], - "argon_threads" => $g['data']['argon_threads'], - "argon_time" => $g['data']['argon_time'], + 'difficulty' => $g['data']['difficulty'], + 'block' => $g['data']['block'], + 'height' => $g['data']['height'], + 'public_key' => $pool_config['public_key'], + 'limit' => $max_dl, + 'recommendation' => $g['data']['recommendation'], + 'argon_mem' => $g['data']['argon_mem'], + 'argon_threads' => $g['data']['argon_threads'], + 'argon_time' => $g['data']['argon_time'], ]; - $fin = json_encode(["status" => "ok", "data" => $res, "coin" => "arionum"]); + + $datetime_akt = date('Y.m.d H:i:s', time()); + $fin = json_encode(['status' => 'ok', 'data' => $res, 'coin' => 'arionum', 'lastupdate' => $datetime_akt]); + echo "\n$fin\n"; file_put_contents($cache_file, $fin); - sleep(5); + sleep(2); + + //refresh PID + $pid_exists = file_exists($pid112); + $pid_time = 0; + if ($pid_exists) { + $pid_time = filemtime($pid112); + } + if (time() - $pid_time > 60) { + system("touch $pid112"); + } } diff --git a/poolsanity.service b/poolsanity.service new file mode 100644 index 0000000..2717819 --- /dev/null +++ b/poolsanity.service @@ -0,0 +1,27 @@ +[Unit] +Description=mine.arionum.tk poolsanity service +#May your script needs MySQL or other services to run, eg. MySQL Memcached +Requires=mysqld.service +After=mysqld.service + +[Service] +User=root +Type=simple +TimeoutSec=0 +PIDFile=/var/run/poolsanity.php.pid +ExecStart=/usr/bin/php -f /var/www/mine.arionum.tk/poolsanity.php > /dev/null 2>/dev/null +#ExecStop=/bin/kill -HUP $MAINPID #It's the default you can change whats happens on stop command +#ExecReload=/bin/kill -HUP $MAINPID +KillMode=process + +#Restart=on-failure +Restart=always +RestartSec=30s + +#If you don't want to make toms of logs you can set it null if you sent a file or some other options it will send all php output to this one. +StandardOutput=/var/log/poolsanity.log +StandardError=/var/log/poolsanity.err + +[Install] +WantedBy=default.target + diff --git a/serverinfo.html b/serverinfo.html new file mode 100644 index 0000000..405d784 --- /dev/null +++ b/serverinfo.html @@ -0,0 +1,10 @@ +
+ Server Processor: 1 %
+ Server Memory: 10 %
+ Server Load: 3.75 %
+
+
+ #
+ #
+ #
+
diff --git a/showorphans.php b/showorphans.php new file mode 100755 index 0000000..03d4bd3 --- /dev/null +++ b/showorphans.php @@ -0,0 +1,89 @@ + 3600) { + system("rm -rf $pid112"); + } + die("\n\n### RUNNING ### -- PID: $pid112\n\n"); +} +system("touch $pid112"); +function shut_down() +{ + global $pid112; + system("rm -rf $pid112"); + echo "\n# ShutDown #\n"; +} + +register_shutdown_function('shut_down'); +############################################### + +set_time_limit(0); +if (PHP_SAPI !== 'cli') { + die('This should only be run as cli'); +} + +require_once __DIR__.'/db.php'; + +if ($pool_config['blocks_paid'] == null) { + die('Blocks Paid variable not set in config'); +} + +//count orphans + $r = $db->run("SELECT * FROM blocks ORDER by height DESC LIMIT 100"); + $oc = 0; + foreach ($r as $x) { + echo("Processing block height:".$x['height'].", orphan:".$x['orphan']." \n"); + if (($pool_config['keep_orphans'] == true) && ($x['orphan'] < 2)) { + echo("Updating block height:".$x['height'].", orphan:".$x['orphan']." \n"); + + $f = file_get_contents($pool_config['node_url'].'/api.php?q=getBlock&height='.$x['height']); + $g = json_decode($f, true); + $oheight = $x['height']; + + if ($g['data']['generator']) { + $x['generator'] = $g['data']['generator']; + if ( $pool_config['address'] != $g['data']['generator'] ) { + + //stealer alias + $fa = file_get_contents($pool_config['node_url'].'/api.php?q=getAlias&account='.$g['data']['generator']); + $ga = json_decode($fa, true); + + if ( trim($ga['data']) !== '' ){ + $x['stealer'] = $ga['data']; + }else{ + $x['stealer'] = $g['data']['generator']; + } + + $bind = [ + ':height' => $x['height'], + ':miner' => $x['stealer'] + ]; + + //$db->run("UPDATE blocks SET orphan=1, miner = :miner where height = :height",$bind); + $oc = $oc + 1; + echo("ORPHAN:".$x['height']." \n"); + } else { + $bind = [ + ':height' => $x['height'] + ]; + + //$db->run("UPDATE blocks SET orphan=-1 where height = :height",$bind); + } + } + } + } +echo("ORPHAN COUNT: $oc \n"); + + + + diff --git a/template/account.html b/template/account.html new file mode 100755 index 0000000..3404590 --- /dev/null +++ b/template/account.html @@ -0,0 +1,125 @@ + +
+
+
+
+

Miner: {$id}

+
+
+
+ + + + + + + + + + + + + + + + {loop="$account"} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {/loop} +
 
CPU blocks hashrate:{$hashrate['cpuhr']} h/s
GPU blocks hashrate:{$hashrate['gpuhr']} h/s
 
Pending balance:{$value.pending} ARO
Total paid:{$value.total_paid} ARO
Paid in last 24 hours:{$value.24h_paid} ARO
Last payment:{$value.last_payment} ARO
Time of last payment:{$value.last_paid}
Check last transaction:Link
 
Shares for current block:{$value.shares}
Total historic shares:{$value.historic}
Best nonce for current block (best DL):{$value.bestdl}
Last nonce submitted:{$value.updated}
+
+
+
+
+
+ + +
+
+
+
+ Workers +
+
+
+ + + + + + + + + + + + + + + + + + + + + {loop="$workers"} + + + + + + + {/loop} + +
NameCPU blocks hashrateGPU blocks hashrateLast Update
NameCPU blocks hashrateGPU blocks hashrateLast Update
{$value.workername}{$value.hashrate}{$value.gpuhr}{$value.updated}
+
+
+
+
+
+ + diff --git a/template/blocks.html b/template/blocks.html index 7269519..40194b6 100755 --- a/template/blocks.html +++ b/template/blocks.html @@ -4,26 +4,24 @@
- Last 100 won blocks + Last {$limit} found blocks
- - - + + - - - + + @@ -31,10 +29,21 @@ {loop="$blocks"} - - - + + {/loop} diff --git a/template/favicon.ico b/template/favicon.ico new file mode 100644 index 0000000..604ec12 Binary files /dev/null and b/template/favicon.ico differ diff --git a/template/footer.html b/template/footer.html index 6a90813..c81d770 100755 --- a/template/footer.html +++ b/template/footer.html @@ -8,7 +8,7 @@
- Copyright © AroPool 2018. All rights reserved. + Based upon AroPool. Service provided as is and without warranty.
diff --git a/template/header.html b/template/header.html index f85e68b..aa01024 100755 --- a/template/header.html +++ b/template/header.html @@ -2,14 +2,18 @@ - - - Arionum Pool - - + + {$pool_name} + + + + + + + @@ -23,16 +27,19 @@ - + - + + + + - + + - +
-
+
Pool: {$pool_name}
diff --git a/template/index.html b/template/index.html index 33893f6..0090a15 100755 --- a/template/index.html +++ b/template/index.html @@ -4,19 +4,19 @@
-
- +
+
-
+

{$height}

-
Current Block
- +
{if="$height % 2 == 0"}CPU / CBlock{else}GPU / GBlock{/if}
-
- Last won block - {$lastwon} +
+ Last won block: {$lastwon} + Passed: block
+
@@ -27,16 +27,17 @@
Current Block
- +

{$miners}

-
Miners
+
Active Miners
-
- Difficulty - {$difficulty} +
+ Difficulty: {$difficulty} + + Orphans: {$orphanpercent} %
@@ -47,17 +48,18 @@
Miners
-
+
+
-
-

{$total_paid}M

+
+

{$total_paid}T

ARO
-
- Total paid - +
+ Total paid (Thousand) + Price: USD
@@ -68,34 +70,36 @@
ARO
-
-

{$total_gpu}

-
GPU Hash Rate ({$gpu_ext})
- +
+ +
+
+

{$total_hr}

+
{$hr_ext}
-
-

{$total_hr}

-
CPU Hash Rate ({$hr_ext})
+
+

{$total_gpu}

+
{$gpu_ext}
+
+
+ CPU & GPU hashrate + kH/s +
+
- - - -
- -
- Current Shares - Total Current Shares: {$total_shares} + Total Current Shares: {$total_shares} + Earned by nonces submitted during current block
@@ -105,7 +109,7 @@
CPU Hash Rate ({$hr_ext})
- + @@ -114,34 +118,30 @@
CPU Hash Rate ({$hr_ext})
- + - -{loop="$shares"} + {loop="$shares"} - + -{/loop} + {/loop}
IDHeight RewardMinerHeight
Miner
IDHeight RewardMinerHeight
Miner
{$value.id}{$value.height} {$value.reward}{$value.miner} + {if="$value.orphan <= 0"} + {$value.height} + {else} +

{$value.height}

+ {/if} +
+ {if="$value.orphan <= 0"} +
{$value.miner}
+ {else} +

Stealer: {$value.miner}

+ {/if} +
Shares % Best DLMinerMiner
Shares % Best DLMinerMiner
{$value.shares} {$value.percent} % {$value.bestdl}{$value.id}{$value.id}
-
- - -
+
- Historic Shares - Total Historic Shares: {$total_historic} + Total Historic Shares: {$total_historic} + Average hashrate: {$avg_hr} H/s - {$avg_gpuhr} H/s
@@ -151,46 +151,43 @@
CPU Hash Rate ({$hr_ext})
Shares % - CPU HR - GPU HR - Pending + CPU bl. HR + GPU bl. HR + Pending Total paid - Miner - + Miner + Shares - % - CPU HR - GPU HR - Pending + % + CPU bl. HR + GPU bl. HR + Pending Total paid - Miner + Miner -{loop="$historic"} + {loop="$historic"} {$value.historic} {$value.percent} % - {$value.hashrate} - {$value.gpuhr} - {$value.pending} + {$value.hashrate} + {$value.gpuhr} + {$value.pending} {$value.total_paid} - {$value.id} + {$value.id} -{/loop} + {/loop}
-
- -
diff --git a/template/info.html b/template/info.html index 730f485..1f4ec81 100755 --- a/template/info.html +++ b/template/info.html @@ -1,57 +1,271 @@ -
-
- +
+
+
+
- Mining Info -
+ + Information: + +
+ +
-

Pool Address: http://aropool.com

-

Pool Fee: 2%

-

Min Payment: 3 ARO

-

Block confirmation: 10 blocks

-

Reward split: 40% miner, 30% current shares, 30% historic shares

- -

- - -

How to mine:

-
Windows
-

In order to mine on our pool, you will need to download the Arionum Wallet from arionum.com

-

Install the LightArionum app, search for the integrated "Miner" tab and click "Start Mining". This is all, you are now mining on our pool!

-

If you are a power user and you would like to get maximum mining performance, you should use Dan's java miner which is available here. -
- -
-
-

Linux/Mac
-

Under linux and mac, we recommend using Dan's java Miner, which is available here.

-

A full guide can be found on the above url.

- - -




-

How to mine: (old version)

-

In order to mine on our pool you will need to first create a wallet. You can download our bundled miner + cli wallet from here.

-

Extract the archive exactly in c:\, it is absolutely necessary that the files are located in this directory as php has absolute paths.

-

Download and install the windows openssl binaries located here (x64 light version). After the installation it's necessary to reboot the computer! -

The Windows version on your computer must be installed using the x64 architecture

-

Run the file Start-Wallet.bat, enter "balance" as the first command and follow the on-screen instructions. Copy your wallet address when printed.

-

Edit Auto-Miner.bat and replace CHANGE-ADDRESS with the address generated above.

-

Execute Auto-Miner.bat and it should start mining on our pool.

-

The miner uses by default 4 cores. If you'd like to mine with more cores, simply start the Auto-Miner.bat again.

-
-

In case you get an error regarding a missing DLL, you will need the Microsoft Visual C++ Runtime package. This can be done downloaded here: https://www.microsoft.com/en-us/download/details.aspx?id=48145> -

-For linux: -

Install php 7.2 and php-gmp

-

Download the latest miner from https://github.com/arionum/miner

-

Change permissions to 755: chmod 755 miner

-

Run it in the format: ./miner pool http://aropool.com (replace YOUR-ADDRESS with your actual address)

- - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
Pool mining address / url
+ +
+ +
{$pool_url}
+
+ +
+ +
+

{if="$handle"}For information and support:
{$handle}@ARO discord{/if}

+
+ +
DeadLine CPU / CBlocks
+ +
+ +
{$cpu_deadline}
+ +
+ +
+ +
+ +
+ +
+ +
DeadLine GPU / GBlocks
+ +
+ +
{$gpu_deadline}
+ +
+ + + + + +
+ +
Degradation of historic shares
+ +
+ +
{$pool_degradation}%
+ +
+ + + + + +
+ +
Pool fee
+ +
+ +
{$fee}%
+ +
+ + + +
+ +
Minimum payout
+ +
+ +
{$minpayout} ARO
+ +
+ + + +
+ +
Block confirmation
+ +
+ +
10 blocks
+ +
+ + + +
+ +
Reward structure
+ +
+ +
{$historic_reward}% historic shares
+ +
+
{$current_reward}% current shares
+ +
+
{$miner_reward}% block finder
+ +
+ +
Payout schedule
+ +
+ +
{$payout_shedule}
+ +
+ + + +
+ +
Pool balance
+ +
+ +
{$poolwallet}
+ +
+ +
This is an independent pool, which means you will only receive a payment when the pool finds a block.
+
+ + + +

+ + {if="$server"}{$server}{/if} + +

+ +
-
- -
-
+
+ + + + \ No newline at end of file diff --git a/template/links.html b/template/links.html new file mode 100755 index 0000000..d258f4d --- /dev/null +++ b/template/links.html @@ -0,0 +1,126 @@ +
+
+
+
+ Arionum links: +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
Arionum official
+
+
www.arionum.com
+
+
arionum.info
+
+

ARO discord

+
+
Arionum exchange
+
+
Mercatox.com
+
+
Vinex network
+
+
+
Wallet
+
+
Cubedpixels Web wallet
+ updated, crossplatform web wallet +
+
+
Electron wallet
+
+
Light wallet
+
+
Arionum.tk pools
You can use http:// or https://
+
+
Pool for CPU miners
https://smallminers.arionum.tk +
+
+
Multiple CPU, or GPU
https://mine.arionum.tk +
+
+
Pool for big mining farms
https://bigminers.arionum.tk +
+
+
Arionum.tk SOLO pool
+
+
Pool for SOLO miners
https://solo.arionum.tk +
+ +
+ +
+
Miner programs
+
+
Java CPU miner
+
+
Bogdanadnan CPU/GPU miner
+
+
Cryptogone CPU/GPU miner
+
+
+
+

+ {if="$server"}{$server}{/if} +

+
+
+
+
+ + + diff --git a/template/news.html b/template/news.html new file mode 100755 index 0000000..73cf35e --- /dev/null +++ b/template/news.html @@ -0,0 +1,47 @@ +
+
+
+
+ News: +
+ +
+ ⭐2019-06-24: Another informations +
+
+
    +
  • Added Aropool.com, Aro.cool, Arionumpool.com, Arionum.info acual block height (refresh: 10 sec)
  • +
  • If our pool block height smaller, then force sanity
  • +
  • Automated jobs, and watchers for better performance
  • +
+ Come and join Arionum.TK pool! 👍 +
+ +
+ ⭐2019-06-23: Advanced server informations +
+
+
    +
  • Added server informations to pools header
  • +
  • Processor, Memory and server load percentage, and progress bar
  • +
+ Wish many blocks! 😊 +
+ +
+ ⭐2019-06-22: Reconfigured server, node and pools. +
+
+
    +
  • Now sync with other pools and to network is working fast. That cause minimal wrong (orphan) blocks, spread new block fastly.
  • +
  • Lowered min DLs, reduced server load (don't influence block founds, and shres)
  • +
  • Share validation moved to an another validation server (share works between each other)
  • +
  • Improved some node functions. Now work faster.
  • +
+ Wish happy mining! 😃 +
+ +
+
+
+ diff --git a/template/payments.html b/template/payments.html index 7a408de..27b8a12 100755 --- a/template/payments.html +++ b/template/payments.html @@ -1,10 +1,11 @@ +
- Last 1000 sent payments + Payments
@@ -13,18 +14,20 @@ ID - Address + Block Height Value - Transaction ID + Address + TX ID - Address + Block Height Value - Transaction ID + Address + TX @@ -33,10 +36,10 @@ {loop="$payments"} {$value.id} + {$value.height} +
{$value.val}
{$value.address} - - {$value.val} - {$value.txn} + {if="$value.txn"}Link{else}Pending{/if} {/loop} diff --git a/update-manual.php b/update-manual.php new file mode 100755 index 0000000..78d997a --- /dev/null +++ b/update-manual.php @@ -0,0 +1,144 @@ + 3600) { + system("rm -rf $pid112"); + } + die("\n\n### RUNNING ### -- PID: $pid112\n\n"); +} +system("touch $pid112"); +function shut_down() +{ + global $pid112; + system("rm -rf $pid112"); + echo "\n# ShutDown #\n"; +} + +register_shutdown_function('shut_down'); +############################################### + +set_time_limit(0); +if (PHP_SAPI !== 'cli') { + die('This should only be run as cli'); +} + +require_once __DIR__.'/db.php'; + +if ($pool_config['blocks_paid'] == null) { + die('Blocks Paid variable not set in config'); +} + +echo "\n----------------------------------------------------------------------------------\n"; +$current = $aro->single('SELECT height FROM blocks ORDER by height DESC LIMIT 1'); +echo "Current block $current\n"; + +$db->run('DELETE FROM miners WHERE historic + shares <= 50'); +$db->run('UPDATE miners + SET gpuhr = ( + SELECT SUM(gpuhr) + FROM workers + WHERE miner = miners.id AND updated > UNIX_TIMESTAMP() - 1000 + )'); +$db->run('UPDATE miners + SET hashrate = ( + SELECT SUM(hashrate) + FROM workers + WHERE miner = miners.id AND updated > UNIX_TIMESTAMP() - 1000 + )'); +//uit sanity + + $r = $db->run('SELECT * FROM miners WHERE historic + shares >0'); + $total_hr = 0; + $total_gpu = 0; + foreach ($r as $x) { + $thr = $db->row( + 'SELECT SUM(hashrate) AS cpu, SUM(gpuhr) AS gpu + FROM workers + WHERE miner = :m AND updated > UNIX_TIMESTAMP() - 1000', + [':m' => $x['id']] + ); + if ($x['historic'] / $thr['cpu'] < 2 || $x['historic'] / $thr['gpu'] < 2) { + $thr['cpu'] = 0; + $thr['gpu'] = 0; + } + $total_hr += $thr['cpu']; + $total_gpu += $thr['gpu']; + } + echo "Total hr: $total_hr, total gpuhr: $total_gpu\n"; + $db->run("UPDATE info SET val=:thr WHERE id='total_hash_rate'", [':thr' => $total_hr]); + $db->run("UPDATE info SET val=:thr WHERE id='total_gpu_hr'", [':thr' => $total_gpu]); + +//cleanup + +//$db->run('DELETE FROM miners WHERE shares=0 AND historic=0 AND updatedrun('DELETE FROM miners WHERE shares + historic <=50 AND updatedrun('DELETE FROM workers WHERE updatedrun( + 'UPDATE miners + SET pending = ( + SELECT SUM(val) + FROM payments + WHERE done = 0 AND payments.address = miners.id AND height >= :h + )', + [':h' => $current - $pool_config['blocks_paid']] +); + + +//count orphans + $r = $db->run("SELECT * FROM blocks ORDER by height DESC LIMIT 20"); + foreach ($r as $x) { + echo("Processing block height:".$x['height'].", orphan:".$x['orphan']." \n"); + if (($pool_config['keep_orphans'] == true) && ($x['orphan'] < 2)) { + echo("Updating block height:".$x['height'].", orphan:".$x['orphan']." \n"); + + $f = file_get_contents($pool_config['node_url'].'/api.php?q=getBlock&height='.$x['height']); + $g = json_decode($f, true); + $oheight = $x['height']; + + if ($g['data']['generator']) { + $x['generator'] = $g['data']['generator']; + if ( $pool_config['address'] != $g['data']['generator'] ) { + + //stealer alias + $fa = file_get_contents($pool_config['node_url'].'/api.php?q=getAlias&account='.$g['data']['generator']); + $ga = json_decode($fa, true); + + if ( trim($ga['data']) !== '' ){ + $x['stealer'] = $ga['data']; + }else{ + $x['stealer'] = $g['data']['generator']; + } + + $bind = [ + ':height' => $x['height'], + ':miner' => $x['stealer'] + ]; + + $db->run("UPDATE blocks SET orphan=1, miner = :miner where height = :height",$bind); + echo("Set ORPHAN:".$x['height']." \n"); + } else { + $bind = [ + ':height' => $x['height'] + ]; + + $db->run("UPDATE blocks SET orphan=-1 where height = :height",$bind); + } + } + } + } + + + + diff --git a/update.php b/update.php new file mode 100755 index 0000000..3d4415c --- /dev/null +++ b/update.php @@ -0,0 +1,143 @@ + 3600) { + system("rm -rf $pid112"); + } + die("\n\n### RUNNING ### -- PID: $pid112\n\n"); +} +system("touch $pid112"); +function shut_down() +{ + global $pid112; + system("rm -rf $pid112"); + echo "\n# ShutDown #\n"; +} + +register_shutdown_function('shut_down'); +############################################### + +set_time_limit(0); +if (PHP_SAPI !== 'cli') { + die('This should only be run as cli'); +} + +require_once __DIR__.'/db.php'; + +if ($pool_config['blocks_paid'] == null) { + die('Blocks Paid variable not set in config'); +} + +echo "\n----------------------------------------------------------------------------------\n"; +$current = $aro->single('SELECT height FROM blocks ORDER by height DESC LIMIT 1'); +echo "Current block $current\n"; + +$db->run('DELETE FROM miners WHERE historic + shares <= 30'); +$db->run('UPDATE miners + SET gpuhr = ( + SELECT SUM(gpuhr) + FROM workers + WHERE miner = miners.id AND updated > UNIX_TIMESTAMP() - 1000 + )'); +$db->run('UPDATE miners + SET hashrate = ( + SELECT SUM(hashrate) + FROM workers + WHERE miner = miners.id AND updated > UNIX_TIMESTAMP() - 1000 + )'); +//uit sanity + + $r = $db->run('SELECT * FROM miners WHERE historic + shares >0'); + $total_hr = 0; + $total_gpu = 0; + foreach ($r as $x) { + $thr = $db->row( + 'SELECT SUM(hashrate) AS cpu, SUM(gpuhr) AS gpu + FROM workers + WHERE miner = :m AND updated > UNIX_TIMESTAMP() - 1000', + [':m' => $x['id']] + ); + if ($x['historic'] / $thr['cpu'] < 2 || $x['historic'] / $thr['gpu'] < 2) { + $thr['cpu'] = 0; + $thr['gpu'] = 0; + } + $total_hr += $thr['cpu']; + $total_gpu += $thr['gpu']; + } + echo "Total hr: $total_hr, total gpuhr: $total_gpu\n"; + $db->run("UPDATE info SET val=:thr WHERE id='total_hash_rate'", [':thr' => $total_hr]); + $db->run("UPDATE info SET val=:thr WHERE id='total_gpu_hr'", [':thr' => $total_gpu]); + +//cleanup + +//$db->run('DELETE FROM miners WHERE shares=0 AND historic=0 AND updatedrun('DELETE FROM miners WHERE shares + historic <=50 AND updatedrun('DELETE FROM workers WHERE updatedrun( + 'UPDATE miners + SET pending = ( + SELECT SUM(val) + FROM payments + WHERE done = 0 AND payments.address = miners.id AND height >= :h + )', + [':h' => $current - $pool_config['blocks_paid']] +); + + +//count orphans + $r = $db->run("SELECT * FROM blocks where orphan=0 ORDER by height DESC LIMIT 100"); + foreach ($r as $x) { + echo("Processing block height:".$x['height'].", orphan:".$x['orphan']." \n"); + if (($pool_config['keep_orphans'] == true) && ($x['orphan'] == 0)) { + echo("Updating block height:".$x['height'].", orphan:".$x['orphan']." \n"); + + $f = file_get_contents($pool_config['node_url'].'/api.php?q=getBlock&height='.$x['height']); + $g = json_decode($f, true); + $oheight = $x['height']; + + if ($g['data']['generator']) { + $x['generator'] = $g['data']['generator']; + if ( $pool_config['address'] != $g['data']['generator'] ) { + + //stealer alias + $fa = file_get_contents($pool_config['node_url'].'/api.php?q=getAlias&account='.$g['data']['generator']); + $ga = json_decode($fa, true); + + if ( trim($ga['data']) !== '' ){ + $x['stealer'] = $ga['data']; + }else{ + $x['stealer'] = $g['data']['generator']; + } + + $bind = [ + ':height' => $x['height'], + ':miner' => $x['stealer'] + ]; + + $db->run("UPDATE blocks SET orphan=1, miner = :miner where height = :height",$bind); + } else { + $bind = [ + ':height' => $x['height'] + ]; + + $db->run("UPDATE blocks SET orphan=-1 where height = :height",$bind); + } + } + } + } + + + + diff --git a/utils/PoolinfoUpdate.service b/utils/PoolinfoUpdate.service new file mode 100644 index 0000000..4268424 --- /dev/null +++ b/utils/PoolinfoUpdate.service @@ -0,0 +1,29 @@ +#PoolinfoUpdate.service + +[Unit] +Description=Poolinfo Update +#Requires=mysqld.service +After=network.target + +[Service] +User=root +Type=simple +TimeoutSec=0 +PIDFile=/var/run/PoolinfoUpdate.pid +ExecStart=/bin/bash /var/www/arionum.tk/utils/getpoolinfo.sh > /dev/null 2>/dev/null +#ExecStop=/bin/kill -HUP $MAINPID #It's the default you can change whats happens on stop command +#ExecReload=/bin/kill -HUP $MAINPID +KillMode=process + +#Restart=on-failure +Restart=always +RestartSec=30s + +#If you don't want to make toms of logs you can set it null if you sent a file or some other options it will send all php output to this one. +StandardOutput=/var/log/PoolinfoUpdate.log +StandardError=/var/log/PoolinfoUpdate.err + +[Install] +WantedBy=default.target + + diff --git a/utils/ServerinfoUpdate.service b/utils/ServerinfoUpdate.service new file mode 100644 index 0000000..40af07b --- /dev/null +++ b/utils/ServerinfoUpdate.service @@ -0,0 +1,29 @@ +#serverinfoUpdate.service + +[Unit] +Description=Serverinfo Update +#Requires=mysqld.service +After=network.target + +[Service] +User=root +Type=simple +TimeoutSec=0 +PIDFile=/var/run/ServerinfoUpdate.pid +ExecStart=/bin/bash /var/www/arionum.tk/utils/getserverinfo.sh > /dev/null 2>/dev/null +#ExecStop=/bin/kill -HUP $MAINPID #It's the default you can change whats happens on stop command +#ExecReload=/bin/kill -HUP $MAINPID +KillMode=process + +#Restart=on-failure +Restart=always +RestartSec=30s + +#If you don't want to make toms of logs you can set it null if you sent a file or some other options it will send all php output to this one. +StandardOutput=/var/log/ServerinfoUpdate.log +StandardError=/var/log/ServerinfoUpdate.err + +[Install] +WantedBy=default.target + + diff --git a/utils/getpoolinfo.sh b/utils/getpoolinfo.sh new file mode 100755 index 0000000..4a8bbd3 --- /dev/null +++ b/utils/getpoolinfo.sh @@ -0,0 +1,77 @@ +#extract infos from POOLs +while true; do + +dir=/var/www/arionum.tk/utils/ +cd $dir + +echo "//Generated: getpoolinfo.sh" > poolinfo.js + +######### POOLS ########## +AropoolBlock=$( curl -H 'user-agent: Mozilla/5.0' -s 'http://aropool.com:80/api.php?q=currentBlock' | jq -r '.current_block_height') +ArocoolBlock=$( curl -H 'user-agent: Mozilla/5.0' -s 'http://aro.cool:80/api.php?q=currentBlock' | jq -r '.current_block_height') +ArionumpoolBlock=$( curl -H 'user-agent: Mozilla/5.0' -s 'https://arionumpool.com/api.php?q=currentBlock' | jq -r '.current_block_height') +#ArionumtkBlock=$( curl -H 'user-agent: Mozilla/5.0' -s 'http://arionum.tk/api.php?q=currentBlock' | jq -r '.current_block_height') +ArionumtkBlock=$( curl -H 'user-agent: Mozilla/5.0' -s 'http://127.0.0.1:80/api.php?q=currentBlock' | jq -r '.current_block_height') + +#Write to file +echo "var aropool_block=$AropoolBlock;" >> poolinfo.js +echo "var arocool_block=$ArocoolBlock;" >> poolinfo.js +echo "var arionumpool_block=$ArionumpoolBlock;" >> poolinfo.js +echo "var arionumtk_block=$ArionumtkBlock;" >> poolinfo.js + +########## ARIONUM INFO ########### +rm index.html* +wget -O index.html --header 'user-agent: Mozilla/5.0' 'http://arionum.info/' + +#line numbers +blockline=$(grep -n '>Current block<' index.html | cut -f1 -d:) +blockline=$((blockline+1)) +ArionumInfo=$(sed -n $blockline'p' index.html | sed 's/

//' | sed 's/<[/]h3>//' | sed 's/^[[:blank:]]*//') +#Write to file +echo "var arionuminfo_block=$ArionumInfo;" >> poolinfo.js + +############## spread file ################ +cp poolinfo.js /var/www/mine-arionum.tk/utils +cp poolinfo.js /var/www/smallminers-arionum.tk/utils +cp poolinfo.js /var/www/bigminers-arionum.tk/utils +cp poolinfo.js /var/www/solo-arionum.tk/utils +cp poolinfo.js /var/www/pool-arionum.tk/utils + +#check Max block height - Force SANITY +needSanity="false" +if [ $ArionumtkBlock -lt $AropoolBlock ] +then + needSanity="true" + #echo "$AropoolBlock" > maxBlockHeight.txt +elif [ $ArionumtkBlock -lt $ArocoolBlock ] +then + needSanity="true" + #echo "$ArocoolBlock" > maxBlockHeight.txt +elif [ $ArionumtkBlock -lt $ArionumpoolBlock ] +then + needSanity="true" + #echo "$ArionumpoolBlock" > maxBlockHeight.txt +elif [ $ArionumtkBlock -lt $ArionumInfo ] +then + needSanity="true" + #echo "$ArionumInfo" > maxBlockHeight.txt +else + needSanity="false" + #rm maxBlockHeight.txt + #rm /var/www/node-arionum.tk/maxBlockHeight.txt + #echo "$ArionumtkBlock" > maxBlockHeight.txt +fi +#cp maxBlockHeight.txt /var/www/node-arionum.tk/ #indirect + +#Call Sanity direct +if [ $needSanity = "true" ] +then + #echo "$ArionumtkBlock" > callSanity.txt + php /var/www/node-arionum.tk/sanity.php +fi + +#WAIT FOR NEXT RUN +sleep 10 + +done + diff --git a/utils/getprice.sh b/utils/getprice.sh new file mode 100755 index 0000000..4e55953 --- /dev/null +++ b/utils/getprice.sh @@ -0,0 +1,40 @@ +#extract infos from arionum.info + +dir=/var/www/arionum.tk/utils/ +cd $dir +rm index.html* +wget arionum.info # index.html + +#line numbers +priceline=$(grep -n 'Last Price' index.html | cut -f1 -d:) +priceline=$((priceline+1)) + +gpuline=$(grep -n 'GPU hashrate' index.html | cut -f1 -d:) +gpuline=$((gpuline+1)) + +cpuline=$(grep -n 'CPU hashrate' index.html | cut -f1 -d:) +cpuline=$((cpuline+2)) + + +#extract price value +price=$(sed -n $priceline'p' index.html | sed 's/

//' | sed 's/<[/]h3>//' | sed 's/^[[:blank:]]*//') + +#extract GPU value +gpuhashrate=$(sed -n $gpuline'p' index.html | sed 's/

//' | sed 's/<[/]h3>//' | sed 's/^[[:blank:]]*//' | sed 's/[[:blank:]]*$//' | sed 's/,/./' ) + +#extract CPU value +cpuhashrate=$(sed -n $cpuline'p' index.html | sed 's/

//' | sed 's/<[/]h3>//' | sed 's/^[[:blank:]]*//' | sed 's/

KH[/]s<[/]h5>//' | sed 's/[[:blank:]]*$//' | sed 's/,/./' ) + + +#Write to file +echo "var aro_price=$price;" > price.js +echo "var aro_gpu_hashrate=$gpuhashrate;" >> price.js +echo "var aro_cpu_hashrate=$cpuhashrate;" >> price.js + +#spread file +cp price.js /var/www/mine-arionum.tk/utils +cp price.js /var/www/smallminers-arionum.tk/utils +cp price.js /var/www/bigminers-arionum.tk/utils +cp price.js /var/www/solo-arionum.tk/utils +cp price.js /var/www/pool-arionum.tk/utils + diff --git a/utils/getserverinfo.sh b/utils/getserverinfo.sh new file mode 100755 index 0000000..d7b3108 --- /dev/null +++ b/utils/getserverinfo.sh @@ -0,0 +1,99 @@ +#Gather Server info + +dir=/var/www/arionum.tk/utils/ +cd $dir + +PREV_TOTAL=0 +PREV_IDLE=0 + +while true; do + + ############## CPU INFO ############# + CPU=(`cat /proc/stat | grep '^cpu '`) # Get the total CPU statistics. + unset CPU[0] # Discard the "cpu" prefix. + IDLE=${CPU[4]} # Get the idle CPU time. + + # Calculate the total CPU time. + TOTAL=0 + + for VALUE in "${CPU[@]:0:4}"; do + let "TOTAL=$TOTAL+$VALUE" + done + + # Calculate the CPU usage since we last checked. + let "DIFF_IDLE=$IDLE-$PREV_IDLE" + let "DIFF_TOTAL=$TOTAL-$PREV_TOTAL" + let "DIFF_USAGE=(1000*($DIFF_TOTAL-$DIFF_IDLE)/$DIFF_TOTAL+5)/10" + CPUUSAGE=$(( DIFF_USAGE )); + #echo -en "\rCPU: $DIFF_USAGE% \b\b" + + # Remember the total and idle CPU times for the next check. + PREV_TOTAL="$TOTAL" + PREV_IDLE="$IDLE" + + ############## MEMORY INFO ############# + MEM=(`cat /proc/meminfo | grep Mem`) # Get the total MEM. + unset MEM[0] # Discard the "mem" prefix. + TotalMEM=${MEM[1]} # Get the MEM. + FreeMEM=${MEM[4]} + AvailMEM=${MEM[7]} + UsedMEM=$(( (100 * ($TotalMEM - $FreeMEM) / $TotalMEM) )); + + LOAD=(`uptime`) # Get the serverLOAD. + L1M=${LOAD[10]/,/} # Get the Loads. + L5M=${LOAD[11]/,/} + L15M=${LOAD[12]/,/} + L1P=$(echo "scale=2; (($L1M * 100)/4)" | bc -l); + L5P=$(echo "scale=2; (($L5M * 100)/4)" | bc -l); + L15P=$(echo "scale=2; (($L15M * 100)/4)" | bc -l); + #echo -en "\r Load 1m: $L1M, Load 5m: $L5M, Load 15m: $L15M, Load 1 percent: $L1PERCENT \b\b" + + #Write to file + echo "var srv_cpu=$CPUUSAGE;" > serverinfo.js + echo "var srv_mem=$UsedMEM;" >> serverinfo.js + echo "var srv_load=$L1P;" >> serverinfo.js + echo "var srv_load1p=$L1P;" >> serverinfo.js + echo "var srv_load5p=$L5P;" >> serverinfo.js + echo "var srv_load15p=$L15P;" >> serverinfo.js + echo "var srv_load1m=$L1M;" >> serverinfo.js + echo "var srv_load5m=$L5M;" >> serverinfo.js + echo "var srv_load15m=$L15M;" >> serverinfo.js + + #spread file + cp serverinfo.js /var/www/mine-arionum.tk/utils + cp serverinfo.js /var/www/smallminers-arionum.tk/utils + cp serverinfo.js /var/www/bigminers-arionum.tk/utils + cp serverinfo.js /var/www/solo-arionum.tk/utils + cp serverinfo.js /var/www/pool-arionum.tk/utils + + #serverinfo.html + echo "
" > serverinfo.html +# echo "" >> serverinfo.html + echo " Server Processor: $CPUUSAGE %
" >> serverinfo.html + echo " Server Memory: $UsedMEM %
" >> serverinfo.html + echo " Server Load: $L1P %
" >> serverinfo.html + echo "
" >> serverinfo.html + echo "
" >> serverinfo.html +# echo " " >> serverinfo.html +# echo " " >> serverinfo.html +# echo " " >> serverinfo.html + echo " #
" >> serverinfo.html + echo " #
" >> serverinfo.html + echo " #
" >> serverinfo.html + echo "
" >> serverinfo.html + + #spread file + cp serverinfo.html /var/www/arionum.tk/ + cp serverinfo.html /var/www/mine-arionum.tk/ + cp serverinfo.html /var/www/smallminers-arionum.tk/ + cp serverinfo.html /var/www/bigminers-arionum.tk/ + cp serverinfo.html /var/www/solo-arionum.tk/ + cp serverinfo.html /var/www/pool-arionum.tk/ + + # Wait before checking again. + sleep 5 +done diff --git a/utils/plusinfo.js b/utils/plusinfo.js new file mode 100644 index 0000000..565ea1a --- /dev/null +++ b/utils/plusinfo.js @@ -0,0 +1,52 @@ +//Extra functions + function automat(){ + setInterval(function(){ $("#srvinfo").load("serverinfo.html #serverinfo") }, 1000); + setInterval(function(){ scheduleProgress() }, 1000); + } + function scheduleProgress(){ + $("#srvprogress").load("serverinfo.html #serverprogress", function(){ + $("#progCPU").html( drawprogress ($("#progCPU").attr("value") ) ); + $("#progMEM").html( drawprogress( $("#progMEM").attr("value") ) ); + $("#progLOAD").html( drawprogress( $("#progLOAD").attr("value") ) ); + }); + } + function drawprogress(pval){ + var progress = "#"; + var pc = ""; + var p10 = ""; + var p20 = ""; + var p30 = ""; + var p40 = ""; + var p50 = ""; + var p60 = ""; + var p70 = ""; + var p80 = ""; + var p90 = ""; + var p100= ""; + + var ival = (parseInt(pval)); + switch (true){ + case (ival<5): progress = p10+"#"; break; + case (ival<10): progress = p10+"##"; break; + case (ival<15): progress = p10+"##"+p20+"#"; break; + case (ival<20): progress = p10+"##"+p20+"##"; break; + case (ival<25): progress = p10+"##"+p20+"##"+p30+"#"; break; + case (ival<30): progress = p10+"##"+p20+"##"+p30+"##"; break; + case (ival<35): progress = p10+"##"+p20+"##"+p30+"##"+p40+"#"; break; + case (ival<40): progress = p10+"##"+p20+"##"+p30+"##"+p40+"##"; break; + case (ival<45): progress = p10+"##"+p20+"##"+p30+"##"+p40+"##"+p50+"#"; break; + case (ival<50): progress = p10+"##"+p20+"##"+p30+"##"+p40+"##"+p50+"##"; break; + case (ival<55): progress = p10+"##"+p20+"##"+p30+"##"+p40+"##"+p50+"##"+p60+"#"; break; + case (ival<60): progress = p10+"##"+p20+"##"+p30+"##"+p40+"##"+p50+"##"+p60+"##"; break; + case (ival<65): progress = p10+"##"+p20+"##"+p30+"##"+p40+"##"+p50+"##"+p60+"##"+p70+"#"; break; + case (ival<70): progress = p10+"##"+p20+"##"+p30+"##"+p40+"##"+p50+"##"+p60+"##"+p70+"##"; break; + case (ival<75): progress = p10+"##"+p20+"##"+p30+"##"+p40+"##"+p50+"##"+p60+"##"+p70+"##"+p80+"#"; break; + case (ival<80): progress = p10+"##"+p20+"##"+p30+"##"+p40+"##"+p50+"##"+p60+"##"+p70+"##"+p80+"##"; break; + case (ival<85): progress = p10+"##"+p20+"##"+p30+"##"+p40+"##"+p50+"##"+p60+"##"+p70+"##"+p80+"##"+p90+"#"; break; + case (ival<90): progress = p10+"##"+p20+"##"+p30+"##"+p40+"##"+p50+"##"+p60+"##"+p70+"##"+p80+"##"+p90+"##"; break; + case (ival<95): progress = p10+"##"+p20+"##"+p30+"##"+p40+"##"+p50+"##"+p60+"##"+p70+"##"+p80+"##"+p90+"##"+p100+"#"; break; + case (ival<100):progress = p10+"##"+p20+"##"+p30+"##"+p40+"##"+p50+"##"+p60+"##"+p70+"##"+p80+"##"+p90+"##"+p100+"##"; break; + } + return progress+pc; + } + diff --git a/utils/poolinfo.js b/utils/poolinfo.js new file mode 100644 index 0000000..0bf33d2 --- /dev/null +++ b/utils/poolinfo.js @@ -0,0 +1,6 @@ +//Generated: getpoolinfo.sh +var aropool_block=187240; +var arocool_block=187241; +var arionumpool_block=187241; +var arionumtk_block=187241; +var arionuminfo_block=187241; diff --git a/utils/price.js b/utils/price.js new file mode 100644 index 0000000..e7464f2 --- /dev/null +++ b/utils/price.js @@ -0,0 +1,3 @@ +var aro_price=0.0029; +var aro_gpu_hashrate=937; +var aro_cpu_hashrate=125; diff --git a/utils/reuirements.txt b/utils/reuirements.txt new file mode 100644 index 0000000..a3fe469 --- /dev/null +++ b/utils/reuirements.txt @@ -0,0 +1,2 @@ +#Requirements +curl, bc, jq, cputool, cpulimit diff --git a/utils/serverinfo.html b/utils/serverinfo.html new file mode 100644 index 0000000..357c3d0 --- /dev/null +++ b/utils/serverinfo.html @@ -0,0 +1,10 @@ +
+ Server Processor: 2 %
+ Server Memory: 10 %
+ Server Load: 5.00 %
+
+
+ #
+ #
+ #
+
diff --git a/utils/serverinfo.js b/utils/serverinfo.js new file mode 100644 index 0000000..706928b --- /dev/null +++ b/utils/serverinfo.js @@ -0,0 +1,9 @@ +var srv_cpu=2; +var srv_mem=10; +var srv_load=5.00; +var srv_load1p=5.00; +var srv_load5p=5.75; +var srv_load15p=; +var srv_load1m=0.20; +var srv_load5m=0.23; +var srv_load15m=;