void set_algorithm(algorithm_t* algo, const char* newname_alias)
{
  const char* newname;
  uint8_t nfactor = 10;

  // scrypt is default ckolivas kernel
  if (strcmp(newname_alias, "scrypt") == 0) {
    newname = "ckolivas";
  }
  // Adaptive N-factor Scrypt is default ckolivas kernel with nfactor 11
  else if ((strcmp(newname_alias, "adaptive-n-factor") == 0) ||
           (strcmp(newname_alias, "adaptive-nfactor") == 0) ||
           (strcmp(newname_alias, "nscrypt") == 0) ||
           (strcmp(newname_alias, "adaptive-nscrypt") == 0) ||
           (strcmp(newname_alias, "adaptive-n-scrypt") == 0)) {
    newname = "ckolivas";
    nfactor = 11;
    // Not an alias
  } 
  else {
    newname = newname_alias;
  }

  copy_algorithm_settings(algo, newname);

  // Doesn't matter for non-scrypt algorithms
  set_algorithm_nfactor(algo, nfactor);
}
Beispiel #2
0
void set_algorithm(algorithm_t* algo, const char* newname_alias)
{
  const char *newname;

  //load previous algorithm nfactor in case nfactor was applied before algorithm... or default to 10
  uint8_t old_nfactor = ((algo->nfactor) ? algo->nfactor : 0);
  //load previous kernel file name if was applied before algorithm...
  const char *kernelfile = algo->kernelfile;
  uint8_t nfactor = 10;

  if (!(newname = lookup_algorithm_alias(newname_alias, &nfactor)))
    newname = newname_alias;

  copy_algorithm_settings(algo, newname);

  // use old nfactor if it was previously set and is different than the one set by alias
  if ((old_nfactor > 0) && (old_nfactor != nfactor))
    nfactor = old_nfactor;

  set_algorithm_nfactor(algo, nfactor);

  //reapply kernelfile if was set
  if (!empty_string(kernelfile)) {
    algo->kernelfile = kernelfile;
  }
}
void copy_algorithm_settings(algorithm_t* dest, const char* algo)
{
  algorithm_settings_t* src;

  // Find algorithm settings and copy
  for (src = algos; src->name; src++) {
    if (strcmp(src->name, algo) == 0) {
      strcpy(dest->name, src->name);

      dest->diff_multiplier1 = src->diff_multiplier1;
      dest->diff_multiplier2 = src->diff_multiplier2;
      dest->share_diff_multiplier = src->share_diff_multiplier;
      dest->xintensity_shift = src->xintensity_shift;
      dest->intensity_shift = src->intensity_shift;
      dest->found_idx = src->found_idx;
      dest->diff_nonce = src->diff_nonce;
      dest->diff_numerator = src->diff_numerator;
      dest->diff1targ = src->diff1targ;
      dest->n_extra_kernels = src->n_extra_kernels;
      dest->rw_buffer_size = src->rw_buffer_size;
      dest->cq_properties = src->cq_properties;
      dest->regenhash = src->regenhash;
      dest->queue_kernel = src->queue_kernel;
      dest->gen_hash = src->gen_hash;
      dest->set_compile_options = src->set_compile_options;
      break;
    }
  }

  // if not found
  if (src->name == NULL) {
    applog(LOG_WARNING, "Algorithm %s not found, using %s.", algo, algos->name);
    copy_algorithm_settings(dest, algos->name);
  }
}