You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.6 KiB
92 lines
2.6 KiB
10 years ago
|
/*
|
||
10 years ago
|
This file is part of ethash.
|
||
10 years ago
|
|
||
10 years ago
|
ethash is free software: you can redistribute it and/or modify
|
||
10 years ago
|
it under the terms of the GNU General Public License as published by
|
||
|
the Free Software Foundation, either version 3 of the License, or
|
||
|
(at your option) any later version.
|
||
|
|
||
10 years ago
|
ethash is distributed in the hope that it will be useful,
|
||
10 years ago
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
GNU General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU General Public License
|
||
10 years ago
|
along with ethash. If not, see <http://www.gnu.org/licenses/>.
|
||
10 years ago
|
*/
|
||
10 years ago
|
|
||
10 years ago
|
/** @file ethash.h
|
||
|
* @date 2015
|
||
|
*/
|
||
|
#pragma once
|
||
|
|
||
|
#include <stdint.h>
|
||
|
#include <stdbool.h>
|
||
|
#include <string.h>
|
||
|
#include <stddef.h>
|
||
|
#include "compiler.h"
|
||
|
|
||
10 years ago
|
#define ETHASH_REVISION 23
|
||
|
#define ETHASH_DATASET_BYTES_INIT 1073741824U // 2**30
|
||
|
#define ETHASH_DATASET_BYTES_GROWTH 8388608U // 2**23
|
||
|
#define ETHASH_CACHE_BYTES_INIT 1073741824U // 2**24
|
||
|
#define ETHASH_CACHE_BYTES_GROWTH 131072U // 2**17
|
||
|
#define ETHASH_EPOCH_LENGTH 30000U
|
||
|
#define ETHASH_MIX_BYTES 128
|
||
|
#define ETHASH_HASH_BYTES 64
|
||
|
#define ETHASH_DATASET_PARENTS 256
|
||
|
#define ETHASH_CACHE_ROUNDS 3
|
||
|
#define ETHASH_ACCESSES 64
|
||
10 years ago
|
|
||
|
#ifdef __cplusplus
|
||
|
extern "C" {
|
||
|
#endif
|
||
|
|
||
10 years ago
|
/// Type of a seedhash/blockhash e.t.c.
|
||
10 years ago
|
typedef struct ethash_h256 { uint8_t b[32]; } ethash_h256_t;
|
||
10 years ago
|
|
||
10 years ago
|
struct ethash_light;
|
||
|
typedef struct ethash_light* ethash_light_t;
|
||
|
|
||
10 years ago
|
typedef struct ethash_return_value {
|
||
10 years ago
|
ethash_h256_t result;
|
||
|
ethash_h256_t mix_hash;
|
||
10 years ago
|
bool success;
|
||
10 years ago
|
} ethash_return_value_t;
|
||
10 years ago
|
|
||
10 years ago
|
/**
|
||
|
* Allocate and initialize a new ethash_light handler
|
||
|
*
|
||
10 years ago
|
* @param block_number The block number for which to create the handler
|
||
|
* @return Newly allocated ethash_light handler or NULL in case of
|
||
|
* ERRNOMEM or invalid parameters used for @ref ethash_compute_cache_nodes()
|
||
10 years ago
|
*/
|
||
10 years ago
|
ethash_light_t ethash_light_new(uint64_t block_number);
|
||
10 years ago
|
/**
|
||
|
* Frees a previously allocated ethash_light handler
|
||
10 years ago
|
* @param light The light handler to free
|
||
10 years ago
|
*/
|
||
|
void ethash_light_delete(ethash_light_t light);
|
||
10 years ago
|
/**
|
||
|
* Calculate the light client data
|
||
|
*
|
||
|
* @param light The light client handler
|
||
|
* @param header_hash The header hash to pack into the mix
|
||
|
* @param nonce The nonce to pack into the mix
|
||
10 years ago
|
* @return an object of ethash_return_value_t holding the return values
|
||
10 years ago
|
*/
|
||
10 years ago
|
ethash_return_value_t ethash_light_compute(
|
||
10 years ago
|
ethash_light_t light,
|
||
10 years ago
|
ethash_h256_t const header_hash,
|
||
10 years ago
|
uint64_t nonce
|
||
10 years ago
|
);
|
||
10 years ago
|
|
||
10 years ago
|
/**
|
||
10 years ago
|
* Calculate the seedhash for a given block number
|
||
10 years ago
|
*/
|
||
10 years ago
|
ethash_h256_t ethash_get_seedhash(uint64_t block_number);
|
||
10 years ago
|
|
||
10 years ago
|
#ifdef __cplusplus
|
||
|
}
|
||
|
#endif
|