starchyfort

Untitled

Jul 13th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.18 KB | None | 0 0
  1.  
  2. //... init precedes this ..
  3.  
  4.     cudaMemcpy(d_solution[theDevice], h_message[theDevice], 8, cudaMemcpyHostToDevice);   // sizeof(uint64_t), 8 bytes
  5.  
  6.     anyError = cudaDeviceSynchronize();
  7.     if (anyError != cudaSuccess)
  8.         printf("Kernel launch error (device %d): %s \n\n", theDevice, cudaGetErrorString(anyError));
  9.     //Sleep(0.35);
  10.  
  11.     cnt[theDevice] += numThreads;               // stride via theCounter a.k.a. `cnt`
  12.     printable_hashrate_cnt[theDevice] += numThreads;
  13.  
  14.     // consider moving this inside the if() statement below (FIXME/TODO)
  15.     cudaMemcpy(h_message[theDevice], d_solution[theDevice], 8, cudaMemcpyDeviceToHost);       // 8 bytes, was sizeof(uint64_t)
  16.     if (*h_message[theDevice] != UINT64_MAX)
  17.     {
  18.        
  19.         ...
  20.  
  21.         memcpy(&solution[theDevice][12], h_message[theDevice], 8);                              // 8 bytes, was sizeof(
  22.  
  23.     }
  24.  
  25.     //... confirmation bits:
  26.  
  27.     string const            str_solution = uint8t_array_toHexString (solution[solutionFoundOnDevice], 32); // was &solution[0]
  28.     string const            str_hash_prefix = uint8t_array_toHexString (hash_prefix, 52); // 52 bytes
  29.  
  30.     printf("Comm_VerifySolutionOnCPU():\n");
  31.     printf("-str_solution = %s \n", str_solution.c_str());
  32.     printf("-str_hash_prefix = %s \n\n", str_hash_prefix.c_str());
  33.  
  34.     // more declarations
  35.     BigUnsigned             digest_bignum = 0;                              // bignum for the digest we're about to compute
  36.     hash_t                  digest_hash = { 0 };                            // hash_t is an array of uint8_t 32 long
  37.     string                  digest_string = "";
  38.  
  39.     printf("performing keccak256 on hashprefix+solution ...\n");
  40.     cout << "message to keccak256() is " << str_hash_prefix + str_solution << endl;
  41.  
  42.     string scratchString_Digest = keccak256test(str_hash_prefix + str_solution);
  43.     cout << "sph-keccak result is  " << scratchString_Digest << endl << endl;
  44. //... there's some other debug prints here I omitted for space
  45.  
  46.     digest_bignum = BigUnsignedInABase(scratchString_Digest, 16);       // convert string to base-16 bignum (since it's a hex string)
  47.     if (digest_bignum <= gBig_MiningTarget)
  48.     {
  49.         printf("comms_pool.cpp: digest -passed- CPU verification!\n");
  50.         return scratchString_Digest;
  51.     }
  52.     else
  53.     {
  54.         printf("comms_pool.cpp: solution failed CPU verification. d'oh!\n\n");
  55.         return "veriferror";
  56.     }
Advertisement
Add Comment
Please, Sign In to add comment