Fabcoin Core  0.16.2
P2P Digital Currency
Classes | Macros | Typedefs | Functions
ethash.h File Reference
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <stddef.h>
#include "compiler.h"
Include dependency graph for ethash.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ethash_h256
 Type of a seedhash/blockhash e.t.c. More...
 
struct  ethash_return_value
 

Macros

#define ETHASH_REVISION   23
 
#define ETHASH_DATASET_BYTES_INIT   1073741824U
 
#define ETHASH_DATASET_BYTES_GROWTH   8388608U
 
#define ETHASH_CACHE_BYTES_INIT   1073741824U
 
#define ETHASH_CACHE_BYTES_GROWTH   131072U
 
#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
 
#define ETHASH_DAG_MAGIC_NUM_SIZE   8
 
#define ETHASH_DAG_MAGIC_NUM   0xFEE1DEADBADDCAFE
 
#define ethash_h256_static_init(...)   { {__VA_ARGS__} }
 

Typedefs

typedef struct ethash_h256 ethash_h256_t
 Type of a seedhash/blockhash e.t.c. More...
 
typedef struct ethash_lightethash_light_t
 
typedef struct ethash_fullethash_full_t
 
typedef int(* ethash_callback_t) (unsigned)
 
typedef struct ethash_return_value ethash_return_value_t
 

Functions

ethash_light_t ethash_light_new (uint64_t block_number)
 Allocate and initialize a new ethash_light handler. More...
 
void ethash_light_delete (ethash_light_t light)
 Frees a previously allocated ethash_light handler. More...
 
ethash_return_value_t ethash_light_compute (ethash_light_t light, ethash_h256_t const header_hash, uint64_t nonce)
 Calculate the light client data. More...
 
ethash_full_t ethash_full_new (ethash_light_t light, ethash_callback_t callback)
 Allocate and initialize a new ethash_full handler. More...
 
void ethash_full_delete (ethash_full_t full)
 Frees a previously allocated ethash_full handler. More...
 
ethash_return_value_t ethash_full_compute (ethash_full_t full, ethash_h256_t const header_hash, uint64_t nonce)
 Calculate the full client data. More...
 
void const * ethash_full_dag (ethash_full_t full)
 Get a pointer to the full DAG data. More...
 
uint64_t ethash_full_dag_size (ethash_full_t full)
 Get the size of the DAG data. More...
 
ethash_h256_t ethash_get_seedhash (uint64_t block_number)
 Calculate the seedhash for a given block number. More...
 

Detailed Description

Date
2015

Definition in file ethash.h.

Macro Definition Documentation

#define ETHASH_ACCESSES   64

Definition at line 39 of file ethash.h.

#define ETHASH_CACHE_BYTES_GROWTH   131072U

Definition at line 33 of file ethash.h.

#define ETHASH_CACHE_BYTES_INIT   1073741824U

Definition at line 32 of file ethash.h.

#define ETHASH_CACHE_ROUNDS   3

Definition at line 38 of file ethash.h.

#define ETHASH_DAG_MAGIC_NUM   0xFEE1DEADBADDCAFE

Definition at line 41 of file ethash.h.

#define ETHASH_DAG_MAGIC_NUM_SIZE   8

Definition at line 40 of file ethash.h.

#define ETHASH_DATASET_BYTES_GROWTH   8388608U

Definition at line 31 of file ethash.h.

#define ETHASH_DATASET_BYTES_INIT   1073741824U

Definition at line 30 of file ethash.h.

#define ETHASH_DATASET_PARENTS   256

Definition at line 37 of file ethash.h.

#define ETHASH_EPOCH_LENGTH   30000U

Definition at line 34 of file ethash.h.

#define ethash_h256_static_init (   ...)    { {__VA_ARGS__} }

Definition at line 55 of file ethash.h.

#define ETHASH_HASH_BYTES   64

Definition at line 36 of file ethash.h.

#define ETHASH_MIX_BYTES   128

Definition at line 35 of file ethash.h.

#define ETHASH_REVISION   23

Definition at line 29 of file ethash.h.

Typedef Documentation

typedef int(* ethash_callback_t) (unsigned)

Definition at line 62 of file ethash.h.

typedef struct ethash_full* ethash_full_t

Definition at line 61 of file ethash.h.

typedef struct ethash_h256 ethash_h256_t

Type of a seedhash/blockhash e.t.c.

typedef struct ethash_light* ethash_light_t

Definition at line 59 of file ethash.h.

Function Documentation

ethash_return_value_t ethash_full_compute ( ethash_full_t  full,
ethash_h256_t const  header_hash,
uint64_t  nonce 
)

Calculate the full client data.

Parameters
fullThe full client handler
header_hashThe header hash to pack into the mix
nonceThe nonce to pack into the mix
Returns
An object of ethash_return_value to hold the return value

Definition at line 575 of file internal.c.

Here is the caller graph for this function:

void const* ethash_full_dag ( ethash_full_t  full)

Get a pointer to the full DAG data.

Definition at line 595 of file internal.c.

Here is the caller graph for this function:

uint64_t ethash_full_dag_size ( ethash_full_t  full)

Get the size of the DAG data.

Definition at line 600 of file internal.c.

Here is the caller graph for this function:

void ethash_full_delete ( ethash_full_t  full)

Frees a previously allocated ethash_full handler.

Parameters
fullThe light handler to free

Definition at line 565 of file internal.c.

Here is the caller graph for this function:

ethash_full_t ethash_full_new ( ethash_light_t  light,
ethash_callback_t  callback 
)

Allocate and initialize a new ethash_full handler.

Parameters
lightThe light handler containing the cache.
callbackA callback function with signature of ethash_callback_t It accepts an unsigned with which a progress of DAG calculation can be displayed. If all goes well the callback should return 0. If a non-zero value is returned then DAG generation will stop. Be advised. A progress value of 100 means that DAG creation is almost complete and that this function will soon return succesfully. It does not mean that the function has already had a succesfull return.
Returns
Newly allocated ethash_full handler or NULL in case of ERRNOMEM or invalid parameters used for ethash_compute_full_data()

Definition at line 554 of file internal.c.

Here is the call graph for this function:

Here is the caller graph for this function:

ethash_h256_t ethash_get_seedhash ( uint64_t  block_number)

Calculate the seedhash for a given block number.

Definition at line 344 of file internal.c.

Here is the caller graph for this function:

ethash_return_value_t ethash_light_compute ( ethash_light_t  light,
ethash_h256_t const  header_hash,
uint64_t  nonce 
)

Calculate the light client data.

Parameters
lightThe light client handler
header_hashThe header hash to pack into the mix
nonceThe nonce to pack into the mix
Returns
an object of ethash_return_value_t holding the return values

Definition at line 432 of file internal.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void ethash_light_delete ( ethash_light_t  light)

Frees a previously allocated ethash_light handler.

Parameters
lightThe light handler to free

Definition at line 409 of file internal.c.

Here is the caller graph for this function:

ethash_light_t ethash_light_new ( uint64_t  block_number)

Allocate and initialize a new ethash_light handler.

Parameters
block_numberThe block number for which to create the handler
Returns
Newly allocated ethash_light handler or NULL in case of ERRNOMEM or invalid parameters used for ethash_compute_cache_nodes()

Definition at line 400 of file internal.c.

Here is the call graph for this function:

Here is the caller graph for this function: