Skip to content

Commit

Permalink
v0.2.1 fix stratum extranonce2
Browse files Browse the repository at this point in the history
  • Loading branch information
CoinFuMasterShifu committed Feb 11, 2024
1 parent e689ebc commit be2103a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project( 'Warthog Miner (Janushash)', ['c','cpp'],
version : '0.2.0',
version : '0.2.1',
default_options : ['warning_level=3', 'cpp_std=c++20'])


Expand Down
13 changes: 8 additions & 5 deletions src/miner/stratum/job.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
#include "crypto/hasher_sha256.hpp"
#include "general/byte_order.hpp"

std::vector<uint8_t> StratumJobGenerator::gen_extra2() const {
std::vector<uint8_t> StratumJobGenerator::gen_extra2() const
{
assert(data->_extranonce);
uint32_t e { hton32((*data->_extranonce)++) };
auto& e_ref(*data->_extranonce);
const uint32_t e { hton32(e_ref++) };
size_t s { data->subscription.extranonce2size };
std::vector<uint8_t> extra2(s);
memcpy(extra2.data(), &e + sizeof(e) - s, s);
std::vector<uint8_t> extra2(s, 0);
memcpy(extra2.data() + s - sizeof(e), &e, s);
return extra2;
};

Expand All @@ -19,7 +21,8 @@ Hash StratumJobGenerator::gen_merkle_root(std::vector<uint8_t> extra2) const
<< extra2;
}

StratumJob StratumJobGenerator::generate_job() const{
StratumJob StratumJobGenerator::generate_job() const
{
return StratumJob(*this);
}

Expand Down
18 changes: 9 additions & 9 deletions src/miner/verusopt/verus_clhash_opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1290,17 +1290,17 @@ inline bool JanusMinerOpt::mine_job(MineResult& res, const CandidateBatch& job,
if (janushash < job.targetV2) {
std::span<const uint8_t, 4> s((const uint8_t*)&nonce, 4);

spdlog::info("janushash(header): {}< {}", janushash.to_double(), 1 / job.targetV2.difficulty());
spdlog::info("header: {}", serialize_hex(header));
spdlog::info("sha256thash: {}", serialize_hex(dummySha256tHash));
// spdlog::info("janushash(header): {}< {}", janushash.to_double(), 1 / job.targetV2.difficulty());
// spdlog::info("header: {}", serialize_hex(header));
// spdlog::info("sha256thash: {}", serialize_hex(dummySha256tHash));
auto hs { hashSHA256(hashSHA256(hashSHA256(header))) };
spdlog::info("SHA256(header): {}", serialize_hex(hs));
spdlog::info("SHA256tFloat: {}", sha256tFloat.to_double());
// spdlog::info("SHA256(header): {}", serialize_hex(hs));
// spdlog::info("SHA256tFloat: {}", sha256tFloat.to_double());
CustomFloat hsf { hs };
spdlog::info("SHA256tFloat2: {}", hsf.to_double());
spdlog::info("verush(header): {}", serialize_hex(verus_hash(header)));
spdlog::info("verusFloat: {}", verusFloat.to_double());
spdlog::info("j {}, {}", j, span[j].nonce());
// spdlog::info("SHA256tFloat2: {}", hsf.to_double());
// spdlog::info("verush(header): {}", serialize_hex(verus_hash(header)));
// spdlog::info("verusFloat: {}", verusFloat.to_double());
// spdlog::info("j {}, {}", j, span[j].nonce());
assert(curHash == verus_hash(header));
res.success = Verus::Success { curHash, mined.submit(s) };
return true;
Expand Down

0 comments on commit be2103a

Please sign in to comment.