Skip to content

Commit

Permalink
Merge pull request #35 from luminousmining/feat/hiveos
Browse files Browse the repository at this point in the history
HiveOS, shell script
  • Loading branch information
luminousmining authored Mar 29, 2024
2 parents b224ab8 + 42865d4 commit f1eb38f
Show file tree
Hide file tree
Showing 17 changed files with 114 additions and 42 deletions.
19 changes: 19 additions & 0 deletions HIVEOS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# HiveOS

## How use luminousminer on HiveOS ?

You must add luminousminer uses `custom miner` mode.

Create new `Flight Sheet`.
![New flight sheet](https://github.com/luminousmining/miner/setup/hiveos/install/create_flight_sheet.PNG)

Click on `Setup Miner Config`.
Add link of release `lumininosminer-X.X_hiveos.tar.gz` in field `URL`.
Replace `YOUR_WALLET` by your wallet.
Replace `YOUR_WORKERNAME` by your workername.
![Setup miner config](https://github.com/luminousmining/miner/setup/hiveos/install/add_custom_miner.PNG)

Save and run your flight sheet.
Enjoy the miner is running!
![Running](https://github.com/luminousmining/miner/setup/hiveos/install/miner_running.PNG)

7 changes: 0 additions & 7 deletions hiveos/h-stats.sh

This file was deleted.

21 changes: 0 additions & 21 deletions hiveos/setup.sh

This file was deleted.

28 changes: 17 additions & 11 deletions miner/sources/api/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,29 @@ void api::ServerAPI::onMessage(
////////////////////////////////////////////////////////////////////////
boost_http::response<boost_http::string_body> response{};
response.version(request.version());
response.result(boost_http::status::ok);
response.set(boost_http::field::server, "LuminousMiner API");
response.set(boost_http::field::content_type, "application/json");

////////////////////////////////////////////////////////////////////////
if ("/hiveos/getStats" == target)
{
onHiveOSGetStats(socket, request, response);
onHiveOSGetStats(socket, response);
response.result(boost_http::status::ok);
}
else if ("/hiveos/getTotalHashrate" == target)
{
onHiveOSGetTotalHashrate(socket, request, response);
onHiveOSGetTotalHashrate(socket, response);
response.result(boost_http::status::ok);
}
else
{
response.result(boost_http::status::not_found);
}
}


void api::ServerAPI::onHiveOSGetStats(
boost_socket& socket,
boost_request const& request,
boost_response& response)
{
////////////////////////////////////////////////////////////////////////////
Expand All @@ -106,7 +110,7 @@ void api::ServerAPI::onHiveOSGetStats(
boost::json::object root
{
{ "hs", boost::json::array{} }, // array of hashes
{ "hs_units", "khs" }, // Optional: units that are uses for hashes array, "hs", "khs", "mhs", ... Default "khs".
{ "hs_units", "hs" }, // Optional: units that are uses for hashes array, "hs", "khs", "mhs", ... Default "khs".
{ "temp", boost::json::array{} }, // array of miner temps
{ "fan", boost::json::array{} }, // array of miner fans
{ "uptime", 0 }, // seconds elapsed from miner stats
Expand All @@ -128,15 +132,18 @@ void api::ServerAPI::onHiveOSGetStats(
if (nullptr == device)
{
hs.push_back(0);
ar.push_back(0);
}
else
{
hs.push_back(device->getHashrate());
hs.push_back(castU64(device->getHashrate()));
statistical::Statistical::ShareInfo shareInfo { device->getShare() };
ar.push_back(shareInfo.invalid);
root["algo"] = algo::toString(device->algorithm);
}
temp.push_back(0);
fan.push_back(0);
ar.push_back(0);
busNumbers.push_back(device->id);
busNumbers.push_back(device->pciBus);
}
root["hs"] = hs;
root["temp"] = temp;
Expand All @@ -155,10 +162,9 @@ void api::ServerAPI::onHiveOSGetStats(

void api::ServerAPI::onHiveOSGetTotalHashrate(
boost_socket& socket,
boost_request const& request,
boost_response& response)
{
double totalHashrate{ 0.0 };
uint64_t totalHashrate{ 0ull };
boost::json::object root{};
std::vector<device::Device*> devices{ deviceManager->getDevices() };

Expand All @@ -168,7 +174,7 @@ void api::ServerAPI::onHiveOSGetTotalHashrate(
{
continue;
}
totalHashrate += device->getHashrate();
totalHashrate += castU64(device->getHashrate());
}

root["total_hash_rate"] = totalHashrate;
Expand Down
4 changes: 1 addition & 3 deletions miner/sources/api/api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,10 @@ namespace api
private:
device::DeviceManager* deviceManager{ nullptr };
void onMessage(boost_socket& socket,
boost_request const& request);
boost_request const& request);
void onHiveOSGetStats(boost_socket& socket,
boost_request const& request,
boost_response& response);
void onHiveOSGetTotalHashrate(boost_socket& socket,
boost_request const& request,
boost_response& response);
};
}
1 change: 1 addition & 0 deletions miner/sources/device/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ namespace device
{
public:
uint32_t id{ 0u };
uint32_t pciBus { 0u };
device::DEVICE_TYPE deviceType { device::DEVICE_TYPE::UNKNOW };
algo::ALGORITHM algorithm { algo::ALGORITHM::UNKNOW };
uint32_t stratumUUID { 0u };
Expand Down
12 changes: 12 additions & 0 deletions miner/sources/device/device_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <common/date.hpp>
#include <common/formater_hashrate.hpp>
#include <common/error/cuda_error.hpp>
#include <common/error/opencl_error.hpp>
#include <device/device_manager.hpp>
#include <stratum/stratums.hpp>

Expand Down Expand Up @@ -226,6 +227,7 @@ bool device::DeviceManager::initializeNvidia()
}
device->cuIndex = castU32(i);
device->id = castU32(devices.size());
device->pciBus = device->properties.pciBusID;

logInfo() << "GPU[" << devices.size() << "] " << device->properties.name;
devices.push_back(device);
Expand Down Expand Up @@ -265,6 +267,16 @@ bool device::DeviceManager::initializeAmd()
}
device->id = castU32(devices.size());

cl_char topology[24]{ 0, };
OPENCL_ER(
clGetDeviceInfo(
device->clDevice.get(),
CL_DEVICE_TOPOLOGY_AMD,
sizeof(topology),
&topology,
nullptr));
device->pciBus = castU32(topology[21]);

logInfo() << "GPU[" << device->id << "] " << device->clDevice.getInfo<CL_DEVICE_BOARD_NAME_AMD>();
devices.push_back(device);
}
Expand Down
4 changes: 4 additions & 0 deletions setup/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Global variables
VERSION=0.2
PROJECT=luminousminer
EXE=miner
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions setup/hiveos/h-stats.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

# Documentation HiveOS
# https://github.com/minershive/hiveos-linux/blob/master/hive/miners/custom/README.md#h-statssh

stats=$(curl -s "http://127.0.0.1:8080/hiveos/getStats")
total_hash=$(curl -s "http://127.0.0.1:8080/hiveos/getTotalHashrate")
khs=`echo ${total_hash} | jq -r '.total_hash_rate'`


# Debug print
echo "stats => ${stats}"
echo "total_hash => ${total_hash}"
echo "khs => ${khs}"
Binary file added setup/install/add_custom_miner.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added setup/install/create_flight_sheet.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added setup/install/miner_running.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions setup/setup_hiveos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Global variables
. setup/config.sh


# Delete folder
rm -rf ${PROJECT}

# Create folder
mkdir ${PROJECT}

# Copy config hiveos
cp setup/hiveos/h-config.sh ${PROJECT}/
cp setup/hiveos/h-run.sh ${PROJECT}/
cp setup/hiveos/h-stats.sh ${PROJECT}/
cp setup/hiveos/h-manifest.conf ${PROJECT}/

# Add right executable
chmod +x ${PROJECT}/h-config.sh
chmod +x ${PROJECT}/h-run.sh
chmod +x ${PROJECT}/h-stats.sh

# Copy executable
cp bin/miner ${PROJECT}/

# Copy kernels
cp -r bin/Release/kernel ${PROJECT}/

# Zip folder
tar czvf ${PROJECT}-${VERSION}_hiveos.tar.gz ${PROJECT}
17 changes: 17 additions & 0 deletions setup/setup_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Global variables
. setup/config.sh

# Delete folder
rm -rf ${PROJECT}

# Create folder
mkdir ${PROJECT}

# Copy executable
cp bin/miner ${PROJECT}/

# Copy kernels
cp -r bin/Release/kernel ${PROJECT}/

# Zip folder
tar czvf ${PROJECT}-${VERSION}.tar.gz ${PROJECT}

0 comments on commit f1eb38f

Please sign in to comment.