Skip to content

Commit

Permalink
add keccakc support
Browse files Browse the repository at this point in the history
  • Loading branch information
cornz committed Sep 15, 2017
1 parent bce18b8 commit c320ebd
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 110 deletions.
220 changes: 111 additions & 109 deletions algos.h
Original file line number Diff line number Diff line change
@@ -1,109 +1,111 @@
#ifndef ALGOS_H
#define ALGOS_H

#include <string.h>
#include "compat.h"

enum sha_algos {
ALGO_BLAKE,
ALGO_DECRED,
ALGO_VCASH,
ALGO_BLAKECOIN,
ALGO_BLAKE2S,
// ALGO_WHIRLPOOLX,
ALGO_KECCAK,
ALGO_LYRA2,
ALGO_LYRA2v2,
ALGO_SKEIN,
ALGO_SKEIN2,
ALGO_NIST5,
ALGO_QUARK,
ALGO_QUBIT,
ALGO_WHIRLPOOL,
ALGO_X11,
ALGO_X11EVO,
ALGO_C11,
ALGO_SIB,
ALGO_X13,
ALGO_X14,
ALGO_X15,
ALGO_X17,
ALGO_LBRY,
ALGO_NEOSCRYPT,
ALGO_SIA,
ALGO_MYR_GR,
ALGO_VELTOR,
// ALGO_YESCRYPT,
ALGO_AUTO,
ALGO_COUNT
};

extern volatile enum sha_algos opt_algo;

static const char *algo_names[] = {
"blake",
"decred",
"vcash",
"blakecoin",
"blake2s",
// "whirlpoolx",
"keccak",
"lyra2",
"lyra2v2",
"skein",
"skein2",
"nist5",
"quark",
"qubit",
"whirlpool",
"x11",
"x11evo",
"c11",
"sib",
"x13",
"x14",
"x15",
"x17",
"lbry",
"neoscrypt",
"sia",
"myr-gr",
"veltor",
// "yescrypt",
"auto", /* reserved for multi algo */
""
};

// string to int/enum
static inline int algo_to_int(char* arg)
{
int i;

for (i = 0; i < ALGO_COUNT; i++) {
if (algo_names[i] && !strcasecmp(arg, algo_names[i])) {
return i;
}
}

if (i == ALGO_COUNT) {
// some aliases...
if (!strcasecmp("all", arg))
i = ALGO_AUTO;
else if (!strcasecmp("flax", arg))
i = ALGO_C11;
else if (!strcasecmp("lyra2re", arg))
i = ALGO_LYRA2;
else if (!strcasecmp("lyra2rev2", arg))
i = ALGO_LYRA2v2;
else if (!strcasecmp("thorsriddle", arg))
i = ALGO_VELTOR;
else if (!strcasecmp("whirl", arg))
i = ALGO_WHIRLPOOL;
else
i = -1;
}

return i;
}

#endif
#ifndef ALGOS_H
#define ALGOS_H

#include <string.h>
#include "compat.h"

enum sha_algos {
ALGO_BLAKE,
ALGO_DECRED,
ALGO_VCASH,
ALGO_BLAKECOIN,
ALGO_BLAKE2S,
// ALGO_WHIRLPOOLX,
ALGO_KECCAK,
ALGO_KECCAKC,
ALGO_LYRA2,
ALGO_LYRA2v2,
ALGO_SKEIN,
ALGO_SKEIN2,
ALGO_NIST5,
ALGO_QUARK,
ALGO_QUBIT,
ALGO_WHIRLPOOL,
ALGO_X11,
ALGO_X11EVO,
ALGO_C11,
ALGO_SIB,
ALGO_X13,
ALGO_X14,
ALGO_X15,
ALGO_X17,
ALGO_LBRY,
ALGO_NEOSCRYPT,
ALGO_SIA,
ALGO_MYR_GR,
ALGO_VELTOR,
// ALGO_YESCRYPT,
ALGO_AUTO,
ALGO_COUNT
};

extern volatile enum sha_algos opt_algo;

static const char *algo_names[] = {
"blake",
"decred",
"vcash",
"blakecoin",
"blake2s",
// "whirlpoolx",
"keccak",
"keccakc",
"lyra2",
"lyra2v2",
"skein",
"skein2",
"nist5",
"quark",
"qubit",
"whirlpool",
"x11",
"x11evo",
"c11",
"sib",
"x13",
"x14",
"x15",
"x17",
"lbry",
"neoscrypt",
"sia",
"myr-gr",
"veltor",
// "yescrypt",
"auto", /* reserved for multi algo */
""
};

// string to int/enum
static inline int algo_to_int(char* arg)
{
int i;

for (i = 0; i < ALGO_COUNT; i++) {
if (algo_names[i] && !strcasecmp(arg, algo_names[i])) {
return i;
}
}

if (i == ALGO_COUNT) {
// some aliases...
if (!strcasecmp("all", arg))
i = ALGO_AUTO;
else if (!strcasecmp("flax", arg))
i = ALGO_C11;
else if (!strcasecmp("lyra2re", arg))
i = ALGO_LYRA2;
else if (!strcasecmp("lyra2rev2", arg))
i = ALGO_LYRA2v2;
else if (!strcasecmp("thorsriddle", arg))
i = ALGO_VELTOR;
else if (!strcasecmp("whirl", arg))
i = ALGO_WHIRLPOOL;
else
i = -1;
}

return i;
}

#endif
10 changes: 9 additions & 1 deletion ccminer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ Options:\n\
vcash Blake256-8rounds (XVC)\n\
blake2s Blake2s (NEVA/XVG)\n\
keccak keccak256 (Maxcoin)\n\
keccakc Keccak-256 + sha256d merkle root (Creativecoin)\n\
lyra2 (LyraBar)\n\
lyra2v2 (VertCoin)\n\
skein Skein SHA2 (AUR/DGB/SKC)\n\
Expand Down Expand Up @@ -1471,6 +1472,9 @@ static bool stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
case ALGO_NEOSCRYPT:
work_set_target(work, sctx->job.diff / (65536.0 * opt_difficulty));
break;
case ALGO_KECCAKC:
work_set_target(work, sctx->job.diff / (256.0 * opt_difficulty));
break;
case ALGO_KECCAK:
case ALGO_LBRY:
case ALGO_LYRA2v2:
Expand Down Expand Up @@ -1976,6 +1980,9 @@ static void *miner_thread(void *userdata)
case ALGO_KECCAK:
rc = scanhash_keccak256(thr_id, &work, max_nonce, &hashes_done);
break;
case ALGO_KECCAKC:
rc = scanhash_keccak256(thr_id, &work, max_nonce, &hashes_done);
break;
case ALGO_BLAKE:
rc = scanhash_blake256_14round(thr_id, &work, max_nonce, &hashes_done);
break;
Expand Down Expand Up @@ -3375,7 +3382,8 @@ int main(int argc, char *argv[])
CUDART_VERSION/1000, (CUDART_VERSION % 1000)/10, comment_toolkit);
printf("*** Based on tpruvot@github ccminer\n");
printf("*** Originally based on Christian Buchner and Christian H. project\n");
printf("*** Include some of the work of djm34, sp, tsiv and klausT.\n\n");
printf("*** Include some of the work of djm34, sp, tsiv and klausT.\n");
printf("*** keccakc Algo added by cornz.\n\n");

rpc_user = strdup("");
rpc_pass = strdup("");
Expand Down

0 comments on commit c320ebd

Please sign in to comment.