Skip to content
This repository has been archived by the owner on Jan 9, 2021. It is now read-only.

Commit

Permalink
resultCode is now uint8_t
Browse files Browse the repository at this point in the history
- applyed changes suggested by bitbandi (v2)
  • Loading branch information
pompobit committed Feb 1, 2018
1 parent 6b3f179 commit 55fe9b9
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 45 deletions.
46 changes: 18 additions & 28 deletions algorithm/evocoin.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,42 +121,37 @@ int nextPerm(uint8_t n[], uint32_t count) {
}


void getAlgoString(char *str, uint32_t count)
{
uint8_t algoList[HASH_FUNC_COUNT];
char s[100];
char *sptr;

void getAlgoString(uint8_t *algoList, uint32_t count)
{
initPerm(algoList, HASH_FUNC_COUNT);

int j;

int k;
for (k = 0; k < count; k++) {
nextPerm(algoList, HASH_FUNC_COUNT);
}

sptr = str;
for (j = 0; j < HASH_FUNC_COUNT; j++) {
if (algoList[j] >= 10)
sprintf(sptr, "%c", 'A' + (algoList[j] - 10));
else
sprintf(sptr, "%u", algoList[j]);
sptr++;
}
*sptr = 0;
}


void evocoin_twisted_code(char *result, const char *ntime, char *code)
void evocoin_twisted_code(char *result, const char *ntime, uint8_t *code)
{
unsigned char bin[4];
uint32_t h32, *be32 = (uint32_t *)bin;
hex2bin(bin, ntime, 4);
h32 = be32toh(*be32);
uint32_t count = getCurrentAlgoSeq(h32, INITIAL_DATE);
getAlgoString(code, count);
sprintf(result, "_%d_%s_", count, code);
char *sptr;
int j;
int n = sprintf(result, "_%d_", count);
sptr = result + n;
for (j = 0; j < HASH_FUNC_COUNT; j++) {
if (code[j] >= 10)
sprintf(sptr, "%c", 'A' + (code[j] - 10));
else
sprintf(sptr, "%u", code[j]);
sptr++;
}
strcat(sptr, "_"); sptr++;
*sptr = 0;

}

Expand All @@ -179,13 +174,8 @@ static inline void xhash(void *state, const void *input , const char* ntime)
void *out;


for (i = 0; i < strlen(resultCode); i++) {
char elem = resultCode[i];
uint8_t idx;
if (elem >= 'A')
idx = elem - 'A' + 10;
else
idx = elem - '0';
for (i = 0; i < HASH_FUNC_COUNT; i++) {
uint8_t idx = resultCode[i];

int size;

Expand Down
2 changes: 1 addition & 1 deletion algorithm/evocoin.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@

extern int evocoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t nonce);
extern void evocoin_regenhash(struct work *work);
extern void evocoin_twisted_code(char *result, const char *ntime, char *code);
extern void evocoin_twisted_code(char *result, const char *ntime, uint8_t *code);

#endif /* EVOCOIN_H */
2 changes: 1 addition & 1 deletion miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ struct thr_info {
int pool_no;
struct timeval last;
struct timeval sick;
char curSequence[12];
uint8_t curSequence[12];
struct work *work;

bool pause;
Expand Down
3 changes: 1 addition & 2 deletions ocl.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize, algorithm_t *alg
if (clState->goffset)
strcat(build_data->binary_filename, "g");

char x11EvoCode[12];
x11EvoCode[0] = 0;
uint8_t x11EvoCode[12] = { 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 };

if (cgpu->algorithm.type == ALGO_X11EVO) {
char algoSuffixCode[100];
Expand Down
12 changes: 3 additions & 9 deletions ocl/build_kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,7 @@ char *generateSource(const uint8_t *code)
for (i = 0; i < HASH_FUNC_COUNT; i++) {

// extract index
uint8_t elem = code[i];
uint8_t idx;
if (elem >= 'A')
idx = elem - 'A' + 10;
else
idx = elem - '0';

uint8_t idx = code[i];
// calc swap requirements
if (curState != algo[idx].req_inverted) {

Expand Down Expand Up @@ -194,11 +188,11 @@ char *generateSource(const uint8_t *code)
return result;
}

cl_program build_opencl_kernel(build_kernel_data *data, const char *filename, const char *x11EvoCode)
cl_program build_opencl_kernel(build_kernel_data *data, const char *filename, const uint8_t *x11EvoCode)
{
int pl;
char *source;
if (strlen(x11EvoCode) > 0) {
if (x11EvoCode[0] != 255) {
source = generateSource(x11EvoCode);
pl = strlen(source) + 1;
}
Expand Down
2 changes: 1 addition & 1 deletion ocl/build_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ typedef struct _build_kernel_data {
} build_kernel_data;

bool needs_bfi_patch(build_kernel_data *data);
cl_program build_opencl_kernel(build_kernel_data *data, const char *filename, const char *x11EvoCode);
cl_program build_opencl_kernel(build_kernel_data *data, const char *filename, const uint8_t *x11EvoCode);
bool save_opencl_kernel(build_kernel_data *data, cl_program program);
void set_base_compiler_options(build_kernel_data *data);

Expand Down
6 changes: 3 additions & 3 deletions sgminer.c
Original file line number Diff line number Diff line change
Expand Up @@ -6777,14 +6777,14 @@ static bool checkIfNeedSwitch(struct thr_info *mythr, struct work *work)
if (work && work->pool) {

char result[100];
char code[12];
uint8_t code[12];

evocoin_twisted_code(result, work->pool->swork.ntime, code);

if (strcmp(code, mythr->curSequence) == 0) {
if (memcmp(code, mythr->curSequence, 12) == 0) {
algoSwitch = false;
} else {
strcpy(mythr->curSequence, code);
memcpy(mythr->curSequence, code, 12);
}
}

Expand Down

0 comments on commit 55fe9b9

Please sign in to comment.