-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from 71ae/ZIL-1
1st Version
- Loading branch information
Showing
7 changed files
with
269 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,102 @@ | ||
# crypto-zil-miner-switch-ethos | ||
Zilliqa (ZIL) Mining Switch for ethOS | ||
|
||
## Background | ||
|
||
[Zilliqa](https://github.com/Zilliqa/Zilliqa) (ZIL) is a blockchain with a | ||
very specific mining process. Mining on the | ||
[Ethash](https://github.com/ethereum/wiki/wiki/Ethash) | ||
algorithm for only less than 5 minutes roughly each 2.5 hours allows the | ||
owner of the ethOS rig to mine their other preferred coins throughout | ||
the rest of the time. | ||
|
||
### Description | ||
|
||
This little set of scripts makes sure your rig monitors the proof-of-work | ||
(PoW) start time, and when required stops your main miner, fires up the | ||
ZIL miner, and switches back to your main miner afterwards. | ||
|
||
In the background a script checks the block height of the ZIL blockchain | ||
every this and then in a loop by calling the Zilliqa API in a decreasing | ||
interval. Once the block 99 is hit, the background sleep stops, the main | ||
miner is disallowed and the mining for ZIL starts for 5 minutes. After | ||
this period the ZIL miner terminates automatically, the main miner is | ||
launched again, and the loop starts from the beginning. | ||
|
||
## Getting Started | ||
|
||
In this version some manual tasks for the configuration is still required. | ||
If you follow the instructions carefully you shall have your ZIL mining up | ||
and running within just a few minutes. | ||
|
||
### Prerequisites | ||
|
||
You need to be running a mining rig with [ethOS](http://ethosdistro.com) 1.3.3 | ||
installed. | ||
|
||
You need to own a wallet address for ZIL. | ||
|
||
### Installation | ||
|
||
Run the following command in your ethOS shell: | ||
|
||
``` | ||
bash <(curl -s https://raw.githubusercontent.com/71ae/crypto-zil-miner-switch-ethos/ZIL-1/install-zil.sh) | ||
``` | ||
|
||
#### Utilization | ||
|
||
For running this script we're making use of the following components: | ||
|
||
* Bash, Perl, and curl | ||
* [Miner Manager for ethOS](https://github.com/cynixx3/third-party-miner-installer-for-ethos) | ||
* [PhoenixMiner](https://phoenix-miner.github.io) | ||
* libwww-perl (LWP) | ||
* JSON for perl | ||
|
||
The installation script makes sure that these tools are installed, if | ||
they aren't part of ethOS yet. | ||
|
||
### Configuration | ||
|
||
After the installation please edit the pool and wallet configuration! | ||
``` | ||
nano zil-miner-switch/minerpool.txt | ||
``` | ||
|
||
After you've done this, you can start this toolsuite with: | ||
``` | ||
sh zil-miner-switch/zil-init.sh | ||
``` | ||
|
||
To make sure the ZIL Mining Switcher also starts when you power on your rig, | ||
you also can add the following line into custom.sh (execute `nano custom.sh`) | ||
before the "exit" line: | ||
``` | ||
bash -c zil-miner-switch/zil-init.sh | ||
``` | ||
|
||
### Farms | ||
|
||
You are limited to installing 15 miners an hour as this script makes | ||
4 GitHub calls per install. Use authenticated requests if you require more. | ||
|
||
## Author | ||
|
||
* [@71ae](https://github.com/71ae) - Andreas E. | ||
|
||
If you find this helpful, a small donation always is welcome | ||
(every coin helps): | ||
|
||
- BTC 1Q1Hnm26TY3nf5NCxTcEJKMYq3C1ejTXCZ | ||
- ETH 0x18eb62e93adceb68c8b28c7e0f6e168ad76500bc (ETH only, no ERC20 tokens) | ||
- LTC LXNgnAodqT5HYBVqKpxdPKCdYFNRphMzg6 | ||
- ETC 0x502a5609fa5e0c1a991fbcc595a48385a764cd16 | ||
- ZEC t1XANY6JV8asAAUegv6v4S2bQE6SzAumkVQ | ||
- ZIL zil19pa7mefxhal7jeda0p6agft5cxc97gfcnl55e0 | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License - see the [LICENSE](LICENSE) | ||
file for details. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/bin/bash | ||
|
||
cat <<EOO | ||
################################################################# | ||
# Zilliqa (ZIL) Mining Switch for ethOS | ||
# Project: https://github.com/71ae/crypto-zil-miner-switch-ethos | ||
################################################################# | ||
We're making use of some additional system libraries and the | ||
PhoenixMiner, so we need to take care of some requirements. | ||
In case of any errors please submit an issue at: | ||
https://github.com/71ae/crypto-zil-miner-switch-ethos/issues/new | ||
################################################################# | ||
EOO | ||
|
||
sleep 5 | ||
|
||
# Install requirements | ||
|
||
sudo apt-get-ubuntu -qq -y update | ||
sudo apt-get-ubuntu -qq -y install libwww-perl liblwp-protocol-https-perl libjson-perl libjson-xs-perl | ||
|
||
bash <(curl -s https://raw.githubusercontent.com/cynixx3/third-party-miner-installer-for-ethos/master/miner-manager) phoenixminer install | ||
|
||
# Download ZIL Mining Switch for ethOS | ||
cd ~ | ||
git clone https://github.com/71ae/crypto-zil-miner-switch-ethos.git | ||
cd crypto-zil-miner-switch-ethos | ||
git checkout ZIL-1 | ||
|
||
cd ~ | ||
mkdir zil-miner-switch | ||
cp -p crypto-zil-miner-switch-ethos/* zil-miner-switch/ | ||
cp -p crypto-zil-miner-switch-ethos/src/* zil-miner-switch/ | ||
|
||
rm -rf crypto-zil-miner-switch-ethos | ||
|
||
cat <<EOO | ||
################################################################# | ||
Now please edit the pool and wallet configuration! | ||
Execute: | ||
nano zil-miner-switch/minerpool.txt | ||
After you've done this, you can start this toolsuite with: | ||
bash zil-miner-switch/zil-init.sh | ||
To make sure the ZIL Mining Switcher also starts when you power on your rig, | ||
you also can add the following line into custom.sh (execute nano custom.sh) | ||
before the "exit" line: | ||
bash -c zil-miner-switch/zil-init.sh | ||
We're ready to go... | ||
################################################################# | ||
EOO | ||
|
||
# to-do: download release instead | ||
# configure | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
OPTS="-cdmport 3334 -ftimeout 240 -worker zilminer -ftimeout 240 -retrydelay 5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
POOL="pool.zil.farm:3333" | ||
WALLET="zil19pa7mefxhal7jeda0p6agft5cxc97gfcnl55e0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
export LC_ALL=C | ||
|
||
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/ethos/bin:/opt/ethos/sbin" | ||
|
||
screen -wipe 2>&1 >/dev/null | ||
|
||
screen -dmS zil -t zil ${HOME}/zil-miner-switch/zil-loop.sh | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/ethos/bin:/opt/ethos/sbin" | ||
|
||
# Make sure EthOS Miner is allowed for now | ||
allow | ||
|
||
# Loop forever | ||
while : | ||
do | ||
|
||
# Wait for Zilliqa ZIL PoW Time | ||
perl ${HOME}/zil-miner-switch/zil-waitfor-pow.pl | ||
|
||
# Stopp EthOS Miner | ||
disallow | ||
minestop | ||
|
||
source ${HOME}/zil-miner-switch/mineropts.txt | ||
source ${HOME}/zil-miner-switch/minerpool.txt | ||
|
||
# Start PhoenixMiner for ZIL Mining for 5 Minutes | ||
/opt/miners/phoenixminer/PhoenixMiner -pool ${POOL} -wal ${WALLET} -proto 2 -gsi 15 -log 2 -logfile /run/miner.output -rmode 0 -timeout 5 ${OPTS} | ||
|
||
# Restart EthOS Miner | ||
allow | ||
|
||
# Repeat loop | ||
done | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/perl | ||
|
||
use LWP::Simple; | ||
use JSON; | ||
|
||
# Initialize basics | ||
|
||
my $url = 'https://api.zilliqa.com/'; | ||
my $json = '{"id": "1", "jsonrpc": "2.0", | ||
"method": "GetBlockchainInfo", | ||
"params": [""] | ||
}'; | ||
|
||
my $req = HTTP::Request->new('POST', $url); | ||
$req->content_type('application/json'); | ||
$req->content($json); | ||
|
||
my $currentBlock = "unknown yet"; | ||
my $powToGo = int(rand(100)); | ||
my $sleep = rand(60); | ||
my $loop = 1; | ||
|
||
while ($loop) { | ||
|
||
# Fetch blockchain info | ||
|
||
my $ua = LWP::UserAgent->new; | ||
$ua->agent("zilMinerSwitch/0." . 100-int($powToGo) . " (ethOS)"); | ||
$ua->timeout(10); | ||
my $res = $ua->request($req); | ||
|
||
if ($res->is_error) { | ||
print "ERROR $res->code: reading Zilliqa API ($res->message)\n"; | ||
$sleep = $sleep / 2 - 0.1; | ||
} | ||
else { # Decode result | ||
my $json = $res->decoded_content . "\n"; | ||
my $obj = from_json($json); | ||
$currentBlock = $obj->{'result'}->{'NumTxBlocks'}; | ||
$powToGo = int($currentBlock/100)*100+99 - $currentBlock; | ||
$sleep = $powToGo * (rand(20)+50)/100 - 0.1; | ||
} | ||
|
||
print localtime(time) . ": ZIL $currentBlock / PoW $powToGo / " . int($sleep) . " mins \n"; | ||
|
||
if ($powToGo <= 1) { | ||
$sleep = 0; | ||
$loop = 0; | ||
break; | ||
} | ||
|
||
if ($sleep <= 3) { | ||
$sleep = $sleep * (rand(20)+50)/100; | ||
} | ||
|
||
my $wait = $sleep * 60; | ||
sleep $wait; | ||
|
||
} | ||
|