forked from tromp/cuckoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcuckoo_miner.cpp
49 lines (47 loc) · 1.34 KB
/
cuckoo_miner.cpp
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
// Cuckoo Cycle, a memory-hard proof-of-work
// Copyright (c) 2013-2014 John Tromp
#include "cuckoo_miner.h"
#include <unistd.h>
int main(int argc, char **argv) {
int nthreads = 1;
int maxsols = 8;
int ntrims = 8;
const char *header = "";
int c;
while ((c = getopt (argc, argv, "h:m:n:t:")) != -1) {
switch (c) {
case 'h':
header = optarg;
break;
case 'm':
maxsols = atoi(optarg);
break;
case 'n':
ntrims = atoi(optarg);
break;
case 't':
nthreads = atoi(optarg);
break;
}
}
printf("Looking for %d-cycle on cuckoo%d(\"%s\") with 50%% edges, %d trims, and %d threads\n",
PROOFSIZE, SIZESHIFT, header, ntrims, nthreads);
cuckoo_ctx ctx(header, nthreads, ntrims, maxsols);
thread_ctx *threads = (thread_ctx *)calloc(nthreads, sizeof(thread_ctx));
assert(threads);
for (int t = 0; t < nthreads; t++) {
threads[t].id = t;
threads[t].ctx = &ctx;
assert(pthread_create(&threads[t].thread, NULL, worker, (void *)&threads[t]) == 0);
}
for (int t = 0; t < nthreads; t++)
assert(pthread_join(threads[t].thread, NULL) == 0);
free(threads);
for (unsigned s = 0; s < ctx.nsols; s++) {
printf("Solution");
for (int i = 0; i < PROOFSIZE; i++)
printf(" %lx", ctx.sols[s][i]);
printf("\n");
}
return 0;
}