Browse Source

algorithm: initial set_algorithm() and set_algorithm_nfactor().

build-mingw
Noel Maersk 11 years ago
parent
commit
50a792f2cd
  1. 18
      algorithm.c
  2. 7
      algorithm.h

18
algorithm.c

@ -10,8 +10,24 @@
#include "algorithm.h" #include "algorithm.h"
#include <inttypes.h> #include <inttypes.h>
#include <string.h>
typedef struct algorithm_t { typedef struct algorithm_t {
char name[32]; /* Human-readable identifier */ char name[20]; /* Human-readable identifier */
uint8_t nfactor; /* N factor (CPU/Memory tradeoff parameter) */ uint8_t nfactor; /* N factor (CPU/Memory tradeoff parameter) */
} algorithm_t; } algorithm_t;
void set_algorithm(algorithm_t* algo, char* newname) {
strncpy(algo->name, newname, sizeof(algo->name));
algo->name[sizeof(algo->name) - 1] = '\0';
if (strcmp(algo->name, "adaptive-nfactor") == 0) {
algo->nfactor = 11;
} else {
algo->nfactor = 10;
}
}
void set_algorithm_nfactor(algorithm_t* algo, uint8_t nfactor) {
algo->nfactor = nfactor;
}

7
algorithm.h

@ -1,10 +1,17 @@
#ifndef ALGORITHM_H #ifndef ALGORITHM_H
#define ALGORITHM_H #define ALGORITHM_H
#include <inttypes.h>
/* Describes the Scrypt parameters and hashing functions used to mine /* Describes the Scrypt parameters and hashing functions used to mine
* a specific coin. * a specific coin.
*/ */
typedef struct algorithm_t algorithm_t; typedef struct algorithm_t algorithm_t;
/* Set default parameters based on name. */
void set_algorithm(algorithm_t* algo, char* name);
/* Set to specific N factor. */
void set_algorithm_nfactor(algorithm_t* algo, uint8_t nfactor);
#endif /* ALGORITHM_H */ #endif /* ALGORITHM_H */

Loading…
Cancel
Save