Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ... init precedes this ..
- cudaMemcpy(d_solution[theDevice], h_message[theDevice], 8, cudaMemcpyHostToDevice); // sizeof(uint64_t), 8 bytes
- anyError = cudaDeviceSynchronize();
- if (anyError != cudaSuccess)
- printf("Kernel launch error (device %d): %s \n\n", theDevice, cudaGetErrorString(anyError));
- //Sleep(0.35);
- cnt[theDevice] += numThreads; // stride via theCounter a.k.a. `cnt`
- printable_hashrate_cnt[theDevice] += numThreads;
- // consider moving this inside the if() statement below (FIXME/TODO)
- cudaMemcpy(h_message[theDevice], d_solution[theDevice], 8, cudaMemcpyDeviceToHost); // 8 bytes, was sizeof(uint64_t)
- if (*h_message[theDevice] != UINT64_MAX)
- {
- ...
- memcpy(&solution[theDevice][12], h_message[theDevice], 8); // 8 bytes, was sizeof(
- }
- string Comm_VerifySolutionOnCPU()
- {
- #define SPH_KECCAK_64 1
- #include "sph_keccak.h"
- typedef std::array<uint8_t, 32u> hash_t;
- typedef std::array<uint8_t, 84u> message_t;
- auto keccak256test(std::string const mesgParam) -> std::string const
- {
- message_t theMesg;
- preHexToBytes(mesgParam, theMesg); // checks for 0x, unneeded really, testing only
- sph_keccak256_context ctx;
- sph_keccak256_init(&ctx);
- sph_keccak256(&ctx, theMesg.data(), theMesg.size());
- hash_t out;
- sph_keccak256_close(&ctx, out.data());
- return Different_BytesToString(out);
- }
- void
- string const str_solution = uint8t_array_toHexString (solution[solutionFoundOnDevice], 32); // was &solution[0]
- string const str_hash_prefix = uint8t_array_toHexString (hash_prefix, 52); // 52 bytes
- printf("Comm_VerifySolutionOnCPU():\n");
- printf("-str_solution = %s \n", str_solution.c_str());
- printf("-str_hash_prefix = %s \n\n", str_hash_prefix.c_str());
- // more declarations
- BigUnsigned digest_bignum = 0; // bignum for the digest we're about to compute
- hash_t digest_hash = { 0 }; // hash_t is an array of uint8_t 32 long
- string digest_string = "";
- printf("performing keccak256 on hashprefix+solution ...\n");
- cout << "message to keccak256() is " << str_hash_prefix + str_solution << endl;
- string scratchString_Digest = keccak256test(str_hash_prefix + str_solution);
- cout << "sph-keccak result is " << scratchString_Digest << endl << endl;
- cout << "mining target is " << gBig_MiningTarget << endl;
- digest_bignum = BigUnsignedInABase(scratchString_Digest, 16); // convert string to base-16 bignum (since it's a hex string)
- if (digest_bignum <= gBig_MiningTarget)
- {
- printf("comms_pool.cpp: digest -passed- CPU verification!\n");
- return scratchString_Digest;
- }
- else
- {
- printf("comms_pool.cpp: solution failed CPU verification. d'oh!\n\n");
- return "veriferror";
- }
Advertisement
Add Comment
Please, Sign In to add comment