-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdag.h
More file actions
51 lines (35 loc) · 1.14 KB
/
dag.h
File metadata and controls
51 lines (35 loc) · 1.14 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
/*
* dag.h - DAG generation
*
* Copyright (C) 2021 Linzhi Ltd.
*
* This work is licensed under the terms of the MIT License.
* A copy of the license can be found in the file COPYING.txt
*/
#ifndef LIBDAG_DAG_H
#define LIBDAG_DAG_H
/*
* Based on
* https://github.com/ethereum/wiki/wiki/Ethash
*/
#include <stdbool.h>
#include <stdint.h>
#include "dagalgo.h"
#define SEED_BYTES 32
#define HASH_BYTES 64
#define MIX_BYTES 128
#define CACHE_LINE_BYTES HASH_BYTES
#define DAG_LINE_BYTES MIX_BYTES
extern enum dag_algo dag_algo;
int get_epoch(unsigned block_number);
unsigned get_cache_size(int epoch);
unsigned get_full_lines(int epoch);
void get_seedhash(uint8_t *seed, unsigned epoch);
void mkcache_init(uint8_t *cache, unsigned cache_bytes, const uint8_t *seed);
void mkcache_round(uint8_t *cache, unsigned cache_bytes);
void mkcache(uint8_t *cache, unsigned cache_bytes, const uint8_t *seed);
void calc_dataset_range(uint8_t *dag, unsigned start, unsigned lines,
const uint8_t *cache, unsigned cache_bytes);
void calc_dataset(uint8_t *dag, unsigned full_lines,
const uint8_t *cache, unsigned cache_bytes);
#endif /* !LIBDAG_DAG_H */