Rewrite readnonces
This commit is contained in:
28
solve_bs.c
28
solve_bs.c
@ -19,24 +19,28 @@ uint32_t **space;
|
|||||||
size_t thread_count = 1;
|
size_t thread_count = 1;
|
||||||
|
|
||||||
uint64_t *readnonces(char* fname) {
|
uint64_t *readnonces(char* fname) {
|
||||||
int i, j, r;
|
int i, j;
|
||||||
FILE *f = fopen(fname, "r");
|
FILE *f = fopen(fname, "r");
|
||||||
|
if (f == NULL) {
|
||||||
|
fprintf(stderr, "Cannot open file.\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
uint64_t *nonces = malloc(sizeof (uint64_t) << 24);
|
uint64_t *nonces = malloc(sizeof (uint64_t) << 24);
|
||||||
uint32_t byte;
|
uint32_t nt;
|
||||||
char parities;
|
char par;
|
||||||
|
|
||||||
for(i = 0; !feof(f); ++i) {
|
i = 0;
|
||||||
for(j = nonces[i] = 0; j < 4; ++j) {
|
while(!feof(f)){
|
||||||
r = fscanf(f, "%02x%c ", &byte, &parities);
|
nonces[i] = 0;
|
||||||
if(r != 2) {
|
for(j = 0; j < 32; j += 8) {
|
||||||
fprintf(stderr, "Input parse error pos:%ld\n", ftell(f));
|
if(2 != fscanf(f, "%02x%c ", &nt, &par)) {
|
||||||
|
fprintf(stderr, "Input format error at line:%d\n", i);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
abort();
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
parities = (parities == '!') ^ parity(byte);
|
nonces[i] |= nt << j | (uint64_t)((par == '!') ^ parity(nt)) << (32 + j);
|
||||||
nonces[i] |= byte << 8 * j;
|
|
||||||
nonces[i] |= ((uint64_t)parities) << (32 + j * 8);
|
|
||||||
}
|
}
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
nonces[i] = -1;
|
nonces[i] = -1;
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
Reference in New Issue
Block a user