From 044bf709018d8509cad7bfb758670f087f924980 Mon Sep 17 00:00:00 2001 From: ystarnaud Date: Wed, 25 Jun 2014 01:01:03 -0400 Subject: [PATCH] Nfactor fix Sometimes the json parser, will read/apply nfactor before algorithm is set. When that is the case, set_algorithm() will reset nfactor to 10 preventing nscrypt from loading properly. Corrected the function to use previously set nfactor or default to 10. --- algorithm.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/algorithm.c b/algorithm.c index 97a723fc..3edbc233 100644 --- a/algorithm.c +++ b/algorithm.c @@ -415,25 +415,37 @@ void copy_algorithm_settings(algorithm_t* dest, const char* algo) void set_algorithm(algorithm_t* algo, const char* newname_alias) { const char* newname; - uint8_t nfactor = 10; + //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 (strcmp(newname_alias, "scrypt") == 0) { + if(!strcasecmp(newname_alias, "scrypt")) + { newname = "ckolivas"; + nfactor = 10; } // 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)) { + 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 - } - else { - newname = newname_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; copy_algorithm_settings(algo, newname);