Developer's Corner - MaynardMiner/SWARM GitHub Wiki
**Note: Some items in this article may be depreciated. I will update soon. Post Issue if you have a question on developing / adding SWARM to your project. **
SWARM is capable of working in any *nix OS. Here are the fine points to work in integration:
Free Space
Depending on how many miners/device groups users may specify, you may require up to 1GB of extra space to run SWARM.
Dependencies:
Swarm requires Powershell 6.1.0 to run. To get the version of powershell I use in HiveOS, I use the following:
wget https://github.com/PowerShell/PowerShell/releases/download/v6.1.0/powershell-6.1.0-linux-x64.tar.gz -O /tmp/powershell.tar.gz
sudo mkdir -p /opt/microsoft/powershell/6.1.0
sudo tar zxf /tmp/powershell.tar.gz -C /opt/microsoft/powershell/6.1.0
sudo chmod +x /opt/microsoft/powershell/6.1.0/pwsh
sudo ln -s /opt/microsoft/powershell/6.1.0/pwsh /usr/bin/pwsh
sudo rm -rf /tmp/powershell.tar.gz
SWARM will query GPU drivers for items like power, and what gpu's are available to mine (to build stat arrays based on user arguments). Doing this requires swarm to have access to:
rocm-smi
nvidia-smi
wolfamdctrl
(also known as ohgodatool)
lspci
lscpu
start-stop-daemon
There are miners that require the following libraries to work:
libc-ares2
libuv1
libcurl / OpenSSL
OPenSSL is a complicated beast in linux. SWARM works best in an Ubuntu 16.04 image. Using other OS's may cause issues with SWARM miners and libcurl library. To resolve this- You would add LD_PRELOAD=/path/to/libcurl
to each prestart in each miner.json file located in ".\config\miners\"
folder.
SWARM uses:
wget
to install miners and:
tar
command to extract them in unix environment
SWARM is meant to run in:
screen
This is done, so that OS's can run SWARM from terminal. You can detach and attach screens as necessary to switch between them. To view information.
An important thing to note is SWARM creates its only launch scripts on demand, in order to add/remove background miner prestarts. This requires SWARM having the ability to use chmod +x
to make the executable on demand, the same goes for miner executables. Some developers tend to forget permissions, and SWARM chmod +x
all exectuables before launches to ensure they have access to do so. This may require SWARM having special permissions to do this.
SWARM has small mini bash scripts, which are placed in the /usr/bin directory. This is what allows users to run commands like stats
and active
, no matter what directory they are in, and it will start the correct mini-script. To see the full list of commands that needs to be installed: One simply needs to view:
.\install.ps1
Which is the Ubuntu script which shows everything needed to set SWARM up, including making the required symlinks needed for .\build\export folder, so they can be exported in when SWARM starts a new miner. Swarm handles the problem of adding needed libraries to run miners. The libraries currently in swarm can be found in:
.\build\export
And can be changed as necessary.
background miner launch
.\build\bash\startup.sh
Is the background script that is made on demand, and launches background miners. The great thing about this, is that since it is made on demand, users can add further commands to the script for each miner. These commands can be changed for each miner within the "prestart" section of the miner.json files located in .\config\miners
folder. If your application of SWARM requires further addition to the launch of the background miners, you would simply add it to the 'prestart' section of the miner in question.
STATS
SWARM gather all the stats from the rig, based on what users specified in their arguments. This is done through the background screen process called:
background
Debug
.\build\txt
As SWARM runs, critical information is written to these small .txt files, each labeled according to what they are gathering. It is a useful addition to help you troubleshoot why SWARM may not be working on your OS.
logs
.\logs
SWARM creates its own transcript, as well a .log for each device group. It has its own log rollover system.
config
(NOTE: Next version this is going to change a lot, to incorporate a better update system, along with other features).
.\config
Most configuration details are changed/formatted into .json within the config folder. This allows you to pull said file remotely, and create commands to modify them remotely. -Update Yes
works by copying the previous .json files over to the new version, allowing users to update without having to modify their settings/user configurations.
API Stats
As of 1.8.7 http://localhost:4099/getstats
will produce the current stats of the miner's SWARM is using. This is easier than attempting to gather the miner stats yourself. See API section of Wiki for more details. This is assuming user has enabled HTML api.
Lite Mode
If you would prefer to manage/control miners, SWARM can still be used!
Swarm has a lite mode, which is specified when user inputs -Lite Yes
Lite mode launches an api server rather than miners. This server provides developers with the needed data required to profit switch in any OS.
The server can be reached at http://localhost:4099/summary
The server will display each possible internal combination SWARM can calculate, and sorts it in application/json in the following manner:
[ { "Power": 0.0, "Pool_Estimate": 2.21445E-11, "Type": "NVIDIA2", "Miner": "TRex-2", "Name": "x22i", "Arguments": "-a x22i -o stratum+tcp://blockmasters.co:3223 --api-bind-telnet 0.0.0.0:4069 --api-bind-http 0.0.0.0:4072 -u 1DRxiWx6yuZfN9hrEJa3BDXWVJ9yyJU36i -p c=BTC,ID=MKVITO2 ", "HashRates": null, "Profits": null, "Algo": "x22i", "Fullname": "x22i", "MinerPool": "blockmasters" }, { "Power": 0.0, "Pool_Estimate": 1.135035E-10, "Type": "NVIDIA2", "Miner": "CryptoDredge-2", "Name": "neoscrypt", "Arguments": "-a neoscrypt -o stratum+tcp://neoscrypt.mine.ahashpool.com:4233 -b 0.0.0.0:4069 -u 1DRxiWx6yuZfN9hrEJa3BDXWVJ9yyJU36i -p c=BTC,ID=MKVITO2 ", "HashRates": null, "Profits": null, "Algo": "neoscrypt", "Fullname": "neoscrypt", "MinerPool": "ahashpool" } ]
The manner in which it is sorted can be in two formats: 1.) If there are no hashrate benchmarks, then each combo is sorted in a descending order by Platform Type First, then Pool Estimates. 2.) If there is a hashrate benchmark, the each combo is sorted in a descending order by Platform Type First, then Profits (esimated).
SWARM will still open its background agent, which is query the api off the port specified in arguments on a 10 second basis. This means you are able to launch your own miners in your own environment, and still use all the functions and features of SWARM.
It is suggested that the api is called between 15-20 seconds, so that you are given time to make a switch.