diff --git a/HIVEOS.md b/HIVEOS.md new file mode 100644 index 0000000..301e018 --- /dev/null +++ b/HIVEOS.md @@ -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) + diff --git a/hiveos/h-stats.sh b/hiveos/h-stats.sh deleted file mode 100644 index 6c98ec1..0000000 --- a/hiveos/h-stats.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -# Documentation HiveOS -# https://github.com/minershive/hiveos-linux/blob/master/hive/miners/custom/README.md#h-statssh - -stats=`{}` -khs=`{}` diff --git a/hiveos/setup.sh b/hiveos/setup.sh deleted file mode 100644 index e6b7b23..0000000 --- a/hiveos/setup.sh +++ /dev/null @@ -1,21 +0,0 @@ -# Global variables -VERSION=0.1 -PROJECT=luminousminer -EXE=miner - -# Delete folder -rm -rf ${PROJECT} - -# Create folder -mkdir ${PROJECT} - -# Setup folder -cp hiveos/h-config.sh ${PROJECT}/ -cp hiveos/h-manifest.conf ${PROJECT}/ -cp hiveos/h-run.sh ${PROJECT}/ -cp hiveos/h-stats.sh ${PROJECT}/ -cp bin/miner ${PROJECT}/ -cp -r bin/Release/kernel ${PROJECT}/ - -# Zip folder -tar czvf ${PROJECT}-${VERSION}_hiveos.tar.gz ${PROJECT} diff --git a/miner/sources/api/api.cpp b/miner/sources/api/api.cpp index cd2a695..3f6a9e6 100644 --- a/miner/sources/api/api.cpp +++ b/miner/sources/api/api.cpp @@ -73,25 +73,29 @@ void api::ServerAPI::onMessage( //////////////////////////////////////////////////////////////////////// boost_http::response 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) { //////////////////////////////////////////////////////////////////////////// @@ -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 @@ -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; @@ -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 devices{ deviceManager->getDevices() }; @@ -168,7 +174,7 @@ void api::ServerAPI::onHiveOSGetTotalHashrate( { continue; } - totalHashrate += device->getHashrate(); + totalHashrate += castU64(device->getHashrate()); } root["total_hash_rate"] = totalHashrate; diff --git a/miner/sources/api/api.hpp b/miner/sources/api/api.hpp index 76e196a..b50ce0a 100644 --- a/miner/sources/api/api.hpp +++ b/miner/sources/api/api.hpp @@ -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); }; } diff --git a/miner/sources/device/device.hpp b/miner/sources/device/device.hpp index 79bbdd1..df708be 100644 --- a/miner/sources/device/device.hpp +++ b/miner/sources/device/device.hpp @@ -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 }; diff --git a/miner/sources/device/device_manager.cpp b/miner/sources/device/device_manager.cpp index 436de69..48ffc3f 100644 --- a/miner/sources/device/device_manager.cpp +++ b/miner/sources/device/device_manager.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -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); @@ -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(); devices.push_back(device); } diff --git a/setup/config.sh b/setup/config.sh new file mode 100644 index 0000000..ae8b4b4 --- /dev/null +++ b/setup/config.sh @@ -0,0 +1,4 @@ +# Global variables +VERSION=0.2 +PROJECT=luminousminer +EXE=miner diff --git a/hiveos/h-config.sh b/setup/hiveos/h-config.sh similarity index 100% rename from hiveos/h-config.sh rename to setup/hiveos/h-config.sh diff --git a/hiveos/h-manifest.conf b/setup/hiveos/h-manifest.conf similarity index 100% rename from hiveos/h-manifest.conf rename to setup/hiveos/h-manifest.conf diff --git a/hiveos/h-run.sh b/setup/hiveos/h-run.sh similarity index 100% rename from hiveos/h-run.sh rename to setup/hiveos/h-run.sh diff --git a/setup/hiveos/h-stats.sh b/setup/hiveos/h-stats.sh new file mode 100644 index 0000000..70eda55 --- /dev/null +++ b/setup/hiveos/h-stats.sh @@ -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}" diff --git a/setup/install/add_custom_miner.PNG b/setup/install/add_custom_miner.PNG new file mode 100644 index 0000000..12fb849 Binary files /dev/null and b/setup/install/add_custom_miner.PNG differ diff --git a/setup/install/create_flight_sheet.PNG b/setup/install/create_flight_sheet.PNG new file mode 100644 index 0000000..4b33732 Binary files /dev/null and b/setup/install/create_flight_sheet.PNG differ diff --git a/setup/install/miner_running.PNG b/setup/install/miner_running.PNG new file mode 100644 index 0000000..4360a0d Binary files /dev/null and b/setup/install/miner_running.PNG differ diff --git a/setup/setup_hiveos.sh b/setup/setup_hiveos.sh new file mode 100644 index 0000000..7ca328e --- /dev/null +++ b/setup/setup_hiveos.sh @@ -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} diff --git a/setup/setup_linux.sh b/setup/setup_linux.sh new file mode 100644 index 0000000..069db67 --- /dev/null +++ b/setup/setup_linux.sh @@ -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}