KawPow WIP

This commit is contained in:
SChernykh 2020-05-24 23:57:41 +02:00
parent 07025dc41b
commit 22b937cc1c
88 changed files with 11004 additions and 8383 deletions

View file

@ -38,6 +38,12 @@
#endif
#ifdef XMRIG_ALGO_KAWPOW
# include "crypto/kawpow/KPCache.h"
# include "crypto/kawpow/KPHash.h"
#endif
#if defined(XMRIG_FEATURE_OPENCL) || defined(XMRIG_FEATURE_CUDA)
# include "base/tools/Baton.h"
# include "crypto/cn/CnCtx.h"
@ -132,6 +138,39 @@ static void getResults(JobBundle &bundle, std::vector<JobResult> &results, uint3
else if (algorithm.family() == Algorithm::ARGON2) {
errors += bundle.nonces.size(); // TODO ARGON2
}
else if (algorithm.family() == Algorithm::KAWPOW) {
# ifdef XMRIG_ALGO_KAWPOW
for (uint32_t nonce : bundle.nonces) {
*bundle.job.nonce() = nonce;
uint8_t header_hash[32];
uint64_t full_nonce;
memcpy(header_hash, bundle.job.blob(), sizeof(header_hash));
memcpy(&full_nonce, bundle.job.blob() + sizeof(header_hash), sizeof(full_nonce));
uint32_t output[8];
uint32_t mix_hash[8];
{
std::lock_guard<std::mutex> lock(KPCache::s_cacheMutex);
KPCache::s_cache.init(bundle.job.height() / KPHash::EPOCH_LENGTH);
KPHash::calculate(KPCache::s_cache, bundle.job.height(), header_hash, full_nonce, output, mix_hash);
}
for (size_t i = 0; i < sizeof(hash); ++i) {
hash[i] = ((uint8_t*)output)[sizeof(hash) - 1 - i];
}
if (*reinterpret_cast<uint64_t*>(hash + 24) < bundle.job.target()) {
results.emplace_back(bundle.job, full_nonce, (uint8_t*)output, bundle.job.blob(), (uint8_t*)mix_hash);
}
else {
LOG_ERR("COMPUTE ERROR"); // TODO Extend information.
++errors;
}
}
# endif
}
else {
cryptonight_ctx *ctx[1];
CnCtx::create(ctx, memory->scratchpad(), memory->size(), 1);