-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathplugin.c
More file actions
67 lines (53 loc) · 1.43 KB
/
plugin.c
File metadata and controls
67 lines (53 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <string.h>
#include "miner.h"
typedef struct {
int N;
double x;
} example_param_t;
static example_param_t default_param;
int init_EXAMPLE() {
default_param.N = 1023;
default_param.x = 12.1;
return 0; // 0 == success
}
void* thread_init_EXAMPLE(int* error, void *extra_param) {
example_param_t *p = (example_param_t*) extra_param;
void *buff = malloc((size_t)p->N * 1234);
*error = (buff == NULL);
return buff;
}
int scanhash_EXAMPLE(int thr_id, uint32_t *pdata,
unsigned char *scratchbuf, const uint32_t *ptarget,
uint32_t max_nonce, unsigned long *hashes_done, void *extra_param) {
example_param_t *p = (example_param_t*) extra_param;
// c.f. scrypt or sha256d code for usage of other parameters
return 0;
}
void *param_default_EXAMPLE() {
return (void*) &default_param;
}
void *param_parse_EXAMPLE(const char *str, int *error) {
static example_param_t p;
const char *delim = ",";
char *pch = strtok (str, delim);
int i = 0;
while( pch ) {
switch(i) {
case 0:
p.N = strtol(pch, NULL, 10);
applog(LOG_INFO, "example: Setting parameter N to %i", p.N);
break;
case 1:
p.x = strtod(pch, NULL);
applog(LOG_INFO, "example: Setting parameter x to %f", p.x);
break;
default:
applog(LOG_ERR, "Too many parameters specified to example algorithm: %s", str);
*error = 1;
return NULL;
}
i++;
pch = strtok (NULL, delim);
}
return (void*) &p;
}