Browse Source

Callback will now be called only 100 times pes DAG creation

cl-refactor
Lefteris Karapetsas 10 years ago
parent
commit
377fe9cbd8
  1. 3
      ethash.h
  2. 7
      internal.c

3
ethash.h

@ -102,6 +102,9 @@ ethash_return_value_t ethash_light_compute(
* It accepts an unsigned with which a progress of DAG calculation
* can be displayed. If all goes well the callback should return 0.
* If a non-zero value is returned then DAG generation will stop.
* Be advised. A progress value of 100 means that DAG creation is
* almost complete and that this function will soon return succesfully.
* It does not mean that the function has already had a succesfull return.
* @return Newly allocated ethash_full handler or NULL in case of
* ERRNOMEM or invalid parameters used for @ref ethash_compute_full_data()
*/

7
internal.c

@ -153,13 +153,16 @@ bool ethash_compute_full_data(
(full_size % sizeof(node)) != 0) {
return false;
}
unsigned int const max_n = full_size / sizeof(node);
node* full_nodes = mem;
double const progress_change = 1.0f / (full_size / sizeof(node));
double const progress_change = 1.0f / max_n;
double progress = 0.0f;
// now compute full nodes
for (unsigned n = 0; n != (full_size / sizeof(node)); ++n) {
for (unsigned n = 0; n != max_n; ++n) {
if (callback &&
n % (max_n / 100) == 0 &&
callback((unsigned int)(ceil(progress * 100.0f))) != 0) {
return false;
}
progress += progress_change;

Loading…
Cancel
Save