diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dcaf9f25..28267ad4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,7 +3,7 @@ name: Build Tnn-miner on Ubuntu 22.04 on: push: branches: - - '*dev*' + - '*' tags: - "v*.*.*" @@ -19,7 +19,8 @@ jobs: sudo update-alternatives --list clang sudo update-alternatives --list clang++ sudo update-alternatives --get-selections - sudo apt update && sudo apt upgrade -y + sudo apt update + #sudo apt upgrade -y - name: 'Setup pre-reqs' run: | sudo apt install git wget build-essential cmake clang libssl-dev libudns-dev libfmt-dev libc++-dev @@ -49,30 +50,25 @@ jobs: sudo update-alternatives --display clang clang --version clang++ --version - - name: 'Compile boost' - run: | - wget -q https://github.com/boostorg/boost/releases/download/boost-1.82.0/boost-1.82.0.tar.gz - tar -xf boost-1.82.0.tar.gz - cd boost-1.82.0/ - ./bootstrap.sh --with-toolset=clang - ./b2 clean - ./b2 toolset=clang cxxflags=-std=c++20 -stdlib=libc++ linkflags=-stdlib=libc++ link=static - name: 'Compile Tnn-miner' run: | mkdir build cd build cmake .. make -j$(nproc) - tar -zcvf ../tnn-miner.tar.gz Tnn-miner + tar -cvf ../tnn-miner.tar Tnn-miner - name: 'Archive tnn-miner.tar.gz' uses: actions/upload-artifact@v4 with: - name: tnn-miner.tar.gz - path: ./tnn-miner.tar.gz + name: tnn-miner.tar + path: ./tnn-miner.tar retention-days: 5 - - name: 'Test Tnn-miner' + - name: 'Dero Test' + run: | + ./build/Tnn-miner --dero-test + - name: 'Xelis Test' run: | - ./build/Tnn-miner --test + ./build/Tnn-miner --xelis-test - name: 'Release' uses: softprops/action-gh-release@v2 if: startsWith(github.ref, 'refs/tags/') diff --git a/.gitignore b/.gitignore index c446202b..61c86f4c 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,7 @@ /build /tests /boost-1.82.0/** +/.cache # Xelis rust resources /src/xelis-hash/**.rs diff --git a/CMakeLists.txt b/CMakeLists.txt index b2be675e..5bb69493 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,10 +38,10 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fstack-protector") set (CMAKE_STANDARD_REQUIRED TRUE) set (CMAKE_CXX_STANDARD 23) - - enable_language(ASM) +include(CMakePrintHelpers) + if(WIN32) include_directories( "C:/mingw64/include" @@ -55,7 +55,19 @@ endif() include_directories(${CUDAToolkit_INCLUDE_DIRS}) -set(CPM_DOWNLOAD_VERSION 0.34.0) +# download CPM.cmake +file( + DOWNLOAD + https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.38.3/CPM.cmake + ${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake + EXPECTED_HASH SHA256=cc155ce02e7945e7b8967ddfaff0b050e958a723ef7aad3766d368940cb15494 +) +include(${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake) + +# This stores downloaded dependencies so we do not need to re-download them +set(CPM_SOURCE_CACHE "${PROJECT_SOURCE_DIR}/.cache/CPM") + +set(CPM_DOWNLOAD_VERSION 0.39.0) if(CPM_SOURCE_CACHE) set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") @@ -86,20 +98,13 @@ execute_process(COMMAND ${LSB_RELEASE_EXEC} -cs OUTPUT_STRIP_TRAILING_WHITESPACE ) -if("${LSB_RELEASE_CODENAME_SHORT}" STREQUAL "jammy") - set(Boost_NO_SYSTEM_PATHS TRUE) - if (Boost_NO_SYSTEM_PATHS) - set(Boost_NO_BOOST_CMAKE TRUE) - set(BOOST_ROOT "${PROJECT_SOURCE_DIR}/boost-1.82.0") - set(BOOST_INCLUDE_DIRS "${BOOST_ROOT}") - set(BOOST_LIBRARY_DIRS "${BOOST_ROOT}/libs") - endif (Boost_NO_SYSTEM_PATHS) -endif() +set(THREADS_PREFER_PTHREAD_FLAG ON) +find_package(Threads REQUIRED) set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_MULTITHREADED ON) set(Boost_NO_WARN_NEW_VERSIONS ON) -find_package(Boost 1.80 REQUIRED +find_package(Boost 1.80 COMPONENTS chrono context json @@ -107,11 +112,42 @@ find_package(Boost 1.80 REQUIRED atomic program_options ) +if(Boost_FOUND) + message("OS-provided Boost found") + set(TNN_BOOST_INCLUDES ${Boost_INCLUDE_DIRS}) +else() + message("Boost not found. Using CPM to add it") + CPMAddPackage( + NAME Boost + VERSION 1.85.0 + URL https://github.com/boostorg/boost/releases/download/boost-1.85.0/boost-1.85.0-cmake.tar.xz + URL_HASH SHA256=0a9cc56ceae46986f5f4d43fe0311d90cf6d2fa9028258a95cab49ffdacf92ad + OPTIONS "Boost_ENABLE_CMAKE ON" "BOOST_INCLUDE_LIBRARIES chrono\\\;context\\\;json\\\;thread\\\;atomic\\\;program_options" # Note the escapes! + # Maintain build compatibility between find_package and CMakeLists.txt variants + ) -set(THREADS_PREFER_PTHREAD_FLAG ON) -find_package(Threads REQUIRED) + if(Boost_ADDED) + file(GLOB files "${Boost_SOURCE_DIR}/libs/*/include") + foreach(filename ${files}) + include_directories(${filename}) + endforeach() + + file(GLOB files "${Boost_SOURCE_DIR}/libs/*/*/include") + foreach(filename ${files}) + include_directories(${filename}) + endforeach() + else() + message(FATAL_ERROR "Boost was neither found nor added.") + endif() + + set(TNN_BOOST_INCLUDES ${Boost_SOURCE_DIR}) +endif() -set(BOOST_INCLUDE_DIRS ${Boost_INCLUDE_DIRS}) +# This is universal regardless of how wheter we compiled or found Boost +set(TNN_BOOST_LIBS Boost::chrono Boost::context Boost::json Boost::thread Boost::atomic Boost::program_options) + +#cmake_print_variables(TNN_BOOST_INCLUDES) +#cmake_print_variables(TNN_BOOST_LIBS) include_directories( ${PROJECT_SOURCE_DIR}/include @@ -122,7 +158,8 @@ include_directories( "${PROJECT_SOURCE_DIR}/src/xelis-hash/" "${PROJECT_SOURCE_DIR}/src/xatum/" "${PROJECT_SOURCE_DIR}/src/miner/" - "${BOOST_INCLUDE_DIRS}" + "${TNN_BOOST_INCLUDES}" + "${PROJECT_SOURCE_DIR}/src/broadcast/" ) set(ASM_SOURCES @@ -139,6 +176,7 @@ file(GLOB all_SRCS "${PROJECT_SOURCE_DIR}/src/astrobwtv3/*.c" "${PROJECT_SOURCE_DIR}/src/xelis-hash/*.cpp" "${PROJECT_SOURCE_DIR}/src/xelis-hash/*.c" + "${PROJECT_SOURCE_DIR}/src/broadcast/*.cpp" "${ASM_SOURCES}" # "${PROJECT_SOURCE_DIR}/src/astrobwtv3/*.cu" # "${PROJECT_SOURCE_DIR}/src/astrobwtv3/*.cuh" @@ -146,7 +184,6 @@ file(GLOB all_SRCS "${PROJECT_SOURCE_DIR}/src/miner/*.c" ) -add_definitions(${GTK3_CFLAGS_OTHER}) add_executable(${PROJECT_NAME} ${all_SRCS}) if(WIN32) @@ -155,5 +192,4 @@ endif() if(UNIX) target_link_libraries(${PROJECT_NAME} udns pthread) endif() -target_link_libraries(${PROJECT_NAME} Threads::Threads nlohmann_json::nlohmann_json ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto) - +target_link_libraries(${PROJECT_NAME} Threads::Threads nlohmann_json::nlohmann_json ${TNN_BOOST_LIBS} OpenSSL::SSL OpenSSL::Crypto) diff --git a/README.md b/README.md index 8caf3d90..f5a851a9 100644 --- a/README.md +++ b/README.md @@ -7,27 +7,29 @@ - UDNS (UNIX only. sudo apt-get install libudns-dev) - FMT (header only) -**For Ubuntu 22.04:** -Install development dependencies +**Building the easy way** +Use the prereqs.sh scripts (one-time only) ``` -sudo apt install git wget build-essential cmake clang libssl-dev libudns-dev libfmt-dev libc++-dev -# Checkout tnn-miner got from github -git clone https://github.com/Tritonn204/tnn-miner.git -cd tnn-miner +./scripts/prereqs.sh +``` +Then build! +``` +./scripts/build.sh ``` -Download and compile Boost 1.82. This is a one-time thing. --- Newer versions of Boost exist, but there's some issue linking program_options +**For Ubuntu 24.04:** +Install development dependencies for Ubuntu 22.04 below, but also install the Boost dev libraries ``` -wget https://github.com/boostorg/boost/releases/download/boost-1.82.0/boost-1.82.0.tar.gz -tar -xf boost-1.82.0.tar.gz -cd boost-1.82.0/ -./bootstrap.sh --with-toolset=clang -./b2 clean -./b2 toolset=clang cxxflags=-std=c++20 -stdlib=libc++ linkflags=-stdlib=libc++ link=static +sudo apt install libboost1.83-all-dev ``` -Proceed with Tnn-miner build + +**For Ubuntu 22.04:** +Install development dependencies ``` +sudo apt install git wget build-essential cmake clang libssl-dev libudns-dev libfmt-dev libc++-dev lld +# Checkout tnn-miner got from github +git clone https://github.com/Tritonn204/tnn-miner.git +cd tnn-miner mkdir build cd build cmake .. diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake deleted file mode 100644 index c4ef2cd4..00000000 --- a/cmake/CPM.cmake +++ /dev/null @@ -1,33 +0,0 @@ -set(CPM_DOWNLOAD_VERSION 0.38.2) - -if(CPM_SOURCE_CACHE) - set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") -elseif(DEFINED ENV{CPM_SOURCE_CACHE}) - set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") -else() - set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") -endif() - -# Expand relative path. This is important if the provided path contains a tilde (~) -get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE) - -function(download_cpm) - message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}") - file(DOWNLOAD - https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake - ${CPM_DOWNLOAD_LOCATION} - ) -endfunction() - -if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION})) - download_cpm() -else() - # resume download if it previously failed - file(READ ${CPM_DOWNLOAD_LOCATION} check) - if("${check}" STREQUAL "") - download_cpm() - endif() - unset(check) -endif() - -include(${CPM_DOWNLOAD_LOCATION}) diff --git a/include/terminal.h b/include/terminal.h index 0071714f..b9247a10 100644 --- a/include/terminal.h +++ b/include/terminal.h @@ -3,13 +3,15 @@ #include #include #include +#include + #if defined(__linux__) #include #endif namespace po = boost::program_options; // from -const char *versionString = "v0.3.1"; +const char *versionString = "0.3.1"; const char *consoleLine = " TNN-MINER "; const char *TNN = R"( @@ -127,6 +129,7 @@ inline po::options_description get_prog_opts() ("help", "produce help message") ("dero", "Will mine Dero") ("xelis", "Will mine Xelis") + ("broadcast", "Creates an http server to query miner stats") ("testnet", "Adjusts in-house parameters to mine on testnets") ("daemon-address", po::value(), "Node/pool URL or IP address to mine to") // todo: parse out port and/or wss:// or ws:// ("port", po::value(), "The port used to connect to the node") diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 00000000..24560a88 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +ret=0 + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +ROOT_DIR=$( cd -- "$( dirname -- "${SCRIPT_DIR}" )" &> /dev/null && pwd ) + +mkdir build +pushd build + cmake .. + ret=$? + if [[ "$ret" != "0" ]]; then + rm -rf ./* + cmake .. + fi + make -j $(nproc) + ret=$? +popd + +exit $ret diff --git a/scripts/prereqs.sh b/scripts/prereqs.sh new file mode 100755 index 00000000..c0ef181f --- /dev/null +++ b/scripts/prereqs.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +ROOT_DIR=$( cd -- "$( dirname -- "${SCRIPT_DIR}" )" &> /dev/null && pwd ) + +if [[ -f /etc/lsb-release ]]; then + source /etc/lsb-release + sudo apt install git wget build-essential cmake clang libssl-dev libudns-dev libfmt-dev libc++-dev lld + if [[ "$DISTRIB_CODENAME" == "noble" ]]; then + sudo apt install libboost1.83-all-dev + fi +fi diff --git a/src/astrobwtv3/astrobwtv3.cpp b/src/astrobwtv3/astrobwtv3.cpp index 4642666a..6edafb94 100644 --- a/src/astrobwtv3/astrobwtv3.cpp +++ b/src/astrobwtv3/astrobwtv3.cpp @@ -176,7 +176,7 @@ __m256i _mm256_mul_epi8(__m256i x, __m256i y) { __m256i _mm256_sllv_epi8(__m256i a, __m256i count) { __m256i mask_hi = _mm256_set1_epi32(0xFF00FF00); - __m256i multiplier_lut = _mm256_set_epi8(0,0,0,0, 0,0,0,0, 128,64,32,16, 8,4,2,1, 0,0,0,0, 0,0,0,0, 128,64,32,16, 8,4,2,1); + __m256i multiplier_lut = _mm256_set_epi8(0,0,0,0, 0,0,0,0, 0x80,0x40,0x20,0x10, 0x08,0x04,0x02,0x01, 0,0,0,0, 0,0,0,0, 0x80,0x40,0x20,0x10, 0x08,0x04,0x02,0x01); __m256i count_sat = _mm256_min_epu8(count, _mm256_set1_epi8(8)); /* AVX shift counts are not masked. So a_i << n_i = 0 for n_i >= 8. count_sat is always less than 9.*/ __m256i multiplier = _mm256_shuffle_epi8(multiplier_lut, count_sat); /* Select the right multiplication factor in the lookup table. */ @@ -194,7 +194,7 @@ __m256i _mm256_sllv_epi8(__m256i a, __m256i count) { __m256i _mm256_srlv_epi8(__m256i a, __m256i count) { __m256i mask_hi = _mm256_set1_epi32(0xFF00FF00); - __m256i multiplier_lut = _mm256_set_epi8(0,0,0,0, 0,0,0,0, 1,2,4,8, 16,32,64,128, 0,0,0,0, 0,0,0,0, 1,2,4,8, 16,32,64,128); + __m256i multiplier_lut = _mm256_set_epi8(0,0,0,0, 0,0,0,0, 0x01,0x02,0x04,0x08, 0x10,0x20,0x40,0x80, 0,0,0,0, 0,0,0,0, 0x01,0x02,0x04,0x08, 0x10,0x20,0x40,0x80); __m256i count_sat = _mm256_min_epu8(count, _mm256_set1_epi8(8)); /* AVX shift counts are not masked. So a_i >> n_i = 0 for n_i >= 8. count_sat is always less than 9.*/ __m256i multiplier = _mm256_shuffle_epi8(multiplier_lut, count_sat); /* Select the right multiplication factor in the lookup table. */ diff --git a/src/broadcast/broadcastServer.cpp b/src/broadcast/broadcastServer.cpp new file mode 100644 index 00000000..0b9fceec --- /dev/null +++ b/src/broadcast/broadcastServer.cpp @@ -0,0 +1,107 @@ +#include "broadcastServer.hpp" +#include + +namespace BroadcastServer +{ + int broadcastPort = 8989; + std::vector *rate30sec_ptr; + uint64_t startTime = 0; + int *accepted_ptr; + int *rejected_ptr; + const char *version_b; + + void handleRequest(http::request &req, http::response &res) + { + if (req.method() == http::verb::get && req.target() == "/stats") + { + + // Create a JSON object with some sample data + json_b::object jsonData; + + jsonData["hashrate"] = std::accumulate((*rate30sec_ptr).begin(), (*rate30sec_ptr).end(), 0LL) / (*rate30sec_ptr).size(); + jsonData["accepted"] = *accepted_ptr; + jsonData["rejected"] = *rejected_ptr; + + // Calculate the uptime using std::chrono + auto currentTime = std::chrono::steady_clock::now(); + auto startTimePoint = std::chrono::steady_clock::time_point(std::chrono::seconds(startTime)); + auto uptime = std::chrono::duration_cast(currentTime - startTimePoint).count(); + jsonData["uptime"] = uptime; + + jsonData["version"] = version_b; + + // Set the response headers and body + res.version(11); + res.set(http::field::content_type, "application/json"); + res.body() = json_b::serialize(jsonData); + res.prepare_payload(); + } + else + { + // Handle other routes or return an error response + res.result(http::status::not_found); + res.set(http::field::content_type, "text/plain"); + res.body() = "Not Found"; + res.prepare_payload(); + } + } + + void handleConnection(tcp::socket socket) + { + try + { + while (true) + { + http::request req; + beast::flat_buffer buffer; + + try + { + http::read(socket, buffer, req); + } + catch (const boost::system::system_error &e) + { + if (e.code() == boost::asio::error::eof) + { + // Client closed the connection, break the loop + break; + } + throw; + } + + http::response res; + handleRequest(req, res); + + http::write(socket, res); + } + } + catch (const std::exception &e) + { + // Unnecessary bloat if the server still works + // std::cerr << "Error handling connection: " << e.what() << std::endl; + } + } + + void serverThread(std::vector *HR30, int *accepted, int *rejected, const char *version) + { + startTime = std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count(); + + boost::asio::io_context ioContext; + tcp::acceptor acceptor(ioContext, tcp::endpoint(tcp::v4(), broadcastPort)); + + rate30sec_ptr = HR30; + accepted_ptr = accepted; + rejected_ptr = rejected; + + version_b = version; + + while (true) + { + tcp::socket socket(ioContext); + acceptor.accept(socket); + + std::thread(handleConnection, std::move(socket)).detach(); + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + } +} \ No newline at end of file diff --git a/src/broadcast/broadcastServer.hpp b/src/broadcast/broadcastServer.hpp new file mode 100644 index 00000000..7280e483 --- /dev/null +++ b/src/broadcast/broadcastServer.hpp @@ -0,0 +1,25 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +namespace beast = boost::beast; +namespace http = beast::http; +namespace json_b = boost::json; +using tcp = boost::asio::ip::tcp; + +namespace BroadcastServer { + extern int broadcastPort; + extern std::vector *rate30sec_ptr; + extern uint64_t startTime; + extern int *accepted_ptr; + extern int *rejected_ptr; + extern const char* version_b; + + void serverThread(std::vector *HR30, int *accepted, int *rejected, const char *version); +}; \ No newline at end of file diff --git a/src/miner/DNSResolver.hpp b/src/miner/DNSResolver.hpp index 094d9cbc..c46f16fa 100644 --- a/src/miner/DNSResolver.hpp +++ b/src/miner/DNSResolver.hpp @@ -37,11 +37,12 @@ #include #include -#include +#include #define THROW_ERRNO throw std::system_error(errno, std::system_category(), strerror(errno)) namespace YukiWorkshop { + using namespace boost::placeholders; class DNSResolver { public: struct MXRecord { diff --git a/src/miner/miner.cpp b/src/miner/miner.cpp index d1bc36ce..af69da58 100644 --- a/src/miner/miner.cpp +++ b/src/miner/miner.cpp @@ -65,6 +65,7 @@ #include #include +#include #if defined(_WIN32) #include @@ -580,53 +581,24 @@ void xelis_session( bool subStart = false; - // boost::thread submission_thread([&] - // { - // bool *C = isDev ? &isConnected : &devConnected; - // bool *B = isDev ? &submittingDev : &submitting; - - // bool keepLoop = true; - - // while (true) { - // try { - // if (!(*C)) break; - // if (*B) { - // boost::json::object *S = isDev ? &devShare : &share; - // std::string msg = boost::json::serialize(*S); - - // // Acquire a lock before writing to the WebSocket - // ws.async_write(boost::asio::buffer(msg), [&](const boost::system::error_code& ec, std::size_t) { - // if (ec) { - // setcolor(RED); - // printf("\nasync_write: submission error\n"); - // setcolor(BRIGHT_WHITE); - // } - // }); - // if (keepLoop == false) break; - // (*B) = false; - // } - // } catch(...){} - - // boost::this_thread::sleep_for(boost::chrono::milliseconds(100)); - // } }); - while (true) { try { bool *B = isDev ? &submittingDev : &submitting; - if (*B) { + if (*B) + { boost::json::object *S = isDev ? &devShare : &share; std::string msg = boost::json::serialize(*S); // Acquire a lock before writing to the WebSocket - ws.async_write(boost::asio::buffer(msg), [&](const boost::system::error_code& ec, std::size_t) { + ws.async_write(boost::asio::buffer(msg), [&](const boost::system::error_code &ec, std::size_t) + { if (ec) { setcolor(RED); printf("\nasync_write: submission error\n"); setcolor(BRIGHT_WHITE); - } - }); + } }); (*B) = false; } @@ -660,7 +632,7 @@ void xelis_session( if ((*J).contains("lasterror") && (*J).at("lasterror") != "") { std::cerr << "received error: " << (*J).at("lasterror") << std::endl - << consoleLine << versionString << " "; + << consoleLine << "v" << versionString << " "; } if (!isDev) @@ -1021,7 +993,8 @@ int handleXatumPacket(Xatum::packet xPacket, bool isDev) *B = data.at("blob").get(); // std::cout << data << std::endl; - if (!isDev) { + if (!isDev) + { setcolor(CYAN); printf("\nNew Xatum job received\n"); setcolor(BRIGHT_WHITE); @@ -1281,6 +1254,11 @@ int main(int argc, char **argv) { gpuMine = true; } + + if (vm.count("broadcast")) + { + broadcastStats = true; + } // GPU-specific if (vm.count("batch-size")) { @@ -1638,6 +1616,9 @@ int main(int argc, char **argv) mutex.unlock(); auto start_time = std::chrono::steady_clock::now(); + if (broadcastStats) { + boost::thread BROADCAST(BroadcastServer::serverThread, &rate30sec, &accepted, &rejected, versionString); + } // update(start_time); while (!isConnected) @@ -2322,7 +2303,8 @@ void mineXelis(int tid) std::swap(nonceBytes[4], nonceBytes[3]); } - if (localJobCounter != jobCounter || localOurHeight != ourHeight) break; + if (localJobCounter != jobCounter || localOurHeight != ourHeight) + break; // std::copy(WORK, WORK + XELIS_TEMPLATE_SIZE, FINALWORK); memcpy(FINALWORK, WORK, XELIS_BYTES_ARRAY_INPUT); @@ -2336,7 +2318,8 @@ void mineXelis(int tid) counter.fetch_add(1); submit = (devMine && devConnected) ? !submittingDev : !submitting; - if (localJobCounter != jobCounter || localOurHeight != ourHeight) break; + if (localJobCounter != jobCounter || localOurHeight != ourHeight) + break; if (submit && CheckHash(powHash, cmpDiff, XELIS_HASH)) { @@ -2349,7 +2332,8 @@ void mineXelis(int tid) if (devMine) { mutex.lock(); - if (localJobCounter != jobCounter || localDevHeight != devHeight) { + if (localJobCounter != jobCounter || localDevHeight != devHeight) + { mutex.unlock(); break; } @@ -2374,7 +2358,8 @@ void mineXelis(int tid) else { mutex.lock(); - if (localJobCounter != jobCounter || localOurHeight != ourHeight) { + if (localJobCounter != jobCounter || localOurHeight != ourHeight) + { mutex.unlock(); break; } diff --git a/src/miner/miner.h b/src/miner/miner.h index 263a96c1..9de45632 100644 --- a/src/miner/miner.h +++ b/src/miner/miner.h @@ -46,6 +46,7 @@ int testOp = -1; int testLen = -1; bool gpuMine = false; bool useLookupMine = false; +bool broadcastStats = false; int cudaMemNumerator = 1000; int cudaMemDenominator = 750; //Kilobytes per worker in VRAM