Skip to content

Commit

Permalink
Add algorithm aliases x11, x13, x15, x15mod, nist5, keccak
Browse files Browse the repository at this point in the history
Also refactor aliasing
  • Loading branch information
mrbrdo committed Jul 3, 2014
1 parent 30d0a9b commit 2902429
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions algorithm.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include <inttypes.h>
#include <string.h>


const char *algorithm_type_str[] = {
"Unknown",
"Scrypt",
Expand Down Expand Up @@ -630,40 +629,43 @@ void copy_algorithm_settings(algorithm_t* dest, const char* algo)
}
}

static const char *lookup_algorithm_alias(const char *lookup_alias, uint8_t *nfactor)
{
#define ALGO_ALIAS_NF(alias, name, nf) \
if (strcasecmp(alias, lookup_alias) == 0) { *nfactor = nf; return name; }
#define ALGO_ALIAS(alias, name) \
if (strcasecmp(alias, lookup_alias) == 0) return name;

ALGO_ALIAS_NF("scrypt", "ckolivas", 10);
ALGO_ALIAS_NF("scrypt", "ckolivas", 10);
ALGO_ALIAS_NF("adaptive-n-factor", "ckolivas", 11);
ALGO_ALIAS_NF("adaptive-nfactor", "ckolivas", 11);
ALGO_ALIAS_NF("nscrypt", "ckolivas", 11);
ALGO_ALIAS_NF("adaptive-nscrypt", "ckolivas", 11);
ALGO_ALIAS_NF("adaptive-n-scrypt", "ckolivas", 11);
ALGO_ALIAS("x11mod", "darkcoin-mod");
ALGO_ALIAS("x11", "darkcoin-mod");
ALGO_ALIAS("x13mod", "marucoin-mod");
ALGO_ALIAS("x13", "marucoin-mod");
ALGO_ALIAS("x15mod", "bitblock");
ALGO_ALIAS("x15", "bitblock");
ALGO_ALIAS("nist5", "talkcoin-mod");
ALGO_ALIAS("keccak", "maxcoin");

#undef ALGO_ALIAS
#undef ALGO_ALIAS_NF

return NULL;
}

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 nfactor = ((algo->nfactor)?algo->nfactor:10);

// scrypt is default ckolivas kernel
if(!strcasecmp(newname_alias, "scrypt"))
{
newname = "ckolivas";
nfactor = 10;
}
// Adaptive N-factor Scrypt is default ckolivas kernel with nfactor 11
else if ((strcasecmp(newname_alias, "adaptive-n-factor") == 0) ||
(strcasecmp(newname_alias, "adaptive-nfactor") == 0) ||
(strcasecmp(newname_alias, "nscrypt") == 0) ||
(strcasecmp(newname_alias, "adaptive-nscrypt") == 0) ||
(strcasecmp(newname_alias, "adaptive-n-scrypt") == 0))
{
newname = "ckolivas";
nfactor = 11;
// Not an alias
}
//x11mod -> darkcoin-mod
else if(!strcasecmp(newname_alias, "x11mod"))
newname = "darkcoin-mod";
//x13mod -> marucoin-mod
else if(!strcasecmp(newname_alias, "x13mod"))
newname = "marucoin-mod";
//x13modold -> marucoin-modold
else if(!strcasecmp(newname_alias, "x13modold"))
newname = "marucoin-modold";
else
newname = newname_alias;
newname = lookup_algorithm_alias(newname_alias, &nfactor);
if (!newname) newname = newname_alias;

copy_algorithm_settings(algo, newname);

Expand Down

1 comment on commit 2902429

@jkister
Copy link

@jkister jkister commented on 2902429 Jul 4, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<whistles>

can you also allow modold aliases?

Please sign in to comment.