Fabcoin Core
0.16.2
P2P Digital Currency
|
#include <assert.h>
#include <inttypes.h>
#include <stddef.h>
#include <errno.h>
#include <math.h>
#include "mmap.h"
#include "ethash.h"
#include "fnv.h"
#include "endian.h"
#include "internal.h"
#include "data_sizes.h"
#include "io.h"
#include "sha3.h"
Go to the source code of this file.
Functions | |
uint64_t | ethash_get_datasize (uint64_t const block_number) |
uint64_t | ethash_get_cachesize (uint64_t const block_number) |
void | ethash_calculate_dag_item (node *const ret, uint32_t node_index, ethash_light_t const light) |
bool | ethash_compute_full_data (void *mem, uint64_t full_size, ethash_light_t const light, ethash_callback_t callback) |
Compute the memory data for a full node's memory. More... | |
void | ethash_quick_hash (ethash_h256_t *return_hash, ethash_h256_t const *header_hash, uint64_t const nonce, ethash_h256_t const *mix_hash) |
ethash_h256_t | ethash_get_seedhash (uint64_t block_number) |
Calculate the seedhash for a given block number. More... | |
bool | ethash_quick_check_difficulty (ethash_h256_t const *header_hash, uint64_t const nonce, ethash_h256_t const *mix_hash, ethash_h256_t const *boundary) |
Difficulty quick check for POW preverification. More... | |
ethash_light_t | ethash_light_new_internal (uint64_t cache_size, ethash_h256_t const *seed) |
Allocate and initialize a new ethash_light handler. More... | |
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_internal (ethash_light_t light, uint64_t full_size, ethash_h256_t const header_hash, uint64_t nonce) |
Calculate the light client data. 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_internal (char const *dirname, ethash_h256_t const seed_hash, uint64_t full_size, ethash_light_t const light, ethash_callback_t callback) |
Allocate and initialize a new ethash_full handler. 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... | |
Definition in file internal.c.
void ethash_calculate_dag_item | ( | node *const | ret, |
uint32_t | node_index, | ||
ethash_light_t const | light | ||
) |
Definition at line 125 of file internal.c.
bool ethash_compute_full_data | ( | void * | mem, |
uint64_t | full_size, | ||
ethash_light_t const | light, | ||
ethash_callback_t | callback | ||
) |
Compute the memory data for a full node's memory.
mem | A pointer to an ethash full's memory |
full_size | The size of the full data in bytes |
cache | A cache object to use in the calculation |
callback | The callback function. Check ethash_full_new() for details. |
Definition at line 188 of file internal.c.
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.
full | The full client handler |
header_hash | The header hash to pack into the mix |
nonce | The nonce to pack into the mix |
Definition at line 575 of file internal.c.
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.
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.
void ethash_full_delete | ( | ethash_full_t | full | ) |
Frees a previously allocated ethash_full handler.
full | The light handler to free |
Definition at line 565 of file internal.c.
ethash_full_t ethash_full_new | ( | ethash_light_t | light, |
ethash_callback_t | callback | ||
) |
Allocate and initialize a new ethash_full handler.
light | The light handler containing the cache. |
callback | A 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. |
Definition at line 554 of file internal.c.
ethash_full_t ethash_full_new_internal | ( | char const * | dirname, |
ethash_h256_t const | seed_hash, | ||
uint64_t | full_size, | ||
ethash_light_t const | light, | ||
ethash_callback_t | callback | ||
) |
Allocate and initialize a new ethash_full handler.
Internal version.
dirname | The directory in which to put the DAG file. |
seedhash | The seed hash of the block. Used in the DAG file naming. |
full_size | The size of the full data in bytes. |
cache | A cache object to use that was allocated with ethash_cache_new(). Iff this function succeeds the ethash_full_t will take memory memory ownership of the cache and free it at deletion. If not then the user still has to handle freeing of the cache himself. |
callback | A 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. |
Definition at line 466 of file internal.c.
uint64_t ethash_get_cachesize | ( | uint64_t const | block_number | ) |
Definition at line 82 of file internal.c.
uint64_t ethash_get_datasize | ( | uint64_t const | block_number | ) |
Definition at line 76 of file internal.c.
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.
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.
light | The light client handler |
header_hash | The header hash to pack into the mix |
nonce | The nonce to pack into the mix |
Definition at line 432 of file internal.c.
ethash_return_value_t ethash_light_compute_internal | ( | ethash_light_t | light, |
uint64_t | full_size, | ||
ethash_h256_t const | header_hash, | ||
uint64_t | nonce | ||
) |
Calculate the light client data.
Internal version.
light | The light client handler |
full_size | The size of the full data in bytes. |
header_hash | The header hash to pack into the mix |
nonce | The nonce to pack into the mix |
Definition at line 417 of file internal.c.
void ethash_light_delete | ( | ethash_light_t | light | ) |
Frees a previously allocated ethash_light handler.
light | The light handler to free |
Definition at line 409 of file internal.c.
ethash_light_t ethash_light_new | ( | uint64_t | block_number | ) |
Allocate and initialize a new ethash_light handler.
block_number | The block number for which to create the handler |
Definition at line 400 of file internal.c.
ethash_light_t ethash_light_new_internal | ( | uint64_t | cache_size, |
ethash_h256_t const * | seed | ||
) |
Allocate and initialize a new ethash_light handler.
Internal version
cache_size | The size of the cache in bytes |
seed | Block seedhash to be used during the computation of the cache nodes |
Definition at line 367 of file internal.c.
bool ethash_quick_check_difficulty | ( | ethash_h256_t const * | header_hash, |
uint64_t const | nonce, | ||
ethash_h256_t const * | mix_hash, | ||
ethash_h256_t const * | boundary | ||
) |
Difficulty quick check for POW preverification.
header_hash | The hash of the header |
nonce | The block's nonce |
mix_hash | The mix digest hash |
boundary | The boundary is defined as (2^256 / difficulty) |
Definition at line 354 of file internal.c.
void ethash_quick_hash | ( | ethash_h256_t * | return_hash, |
ethash_h256_t const * | header_hash, | ||
uint64_t const | nonce, | ||
ethash_h256_t const * | mix_hash | ||
) |
Definition at line 328 of file internal.c.