Fabcoin Core
0.16.2
P2P Digital Currency
|
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <inttypes.h>
#include "endian.h"
#include "ethash.h"
Go to the source code of this file.
Macros | |
#define | DAG_MUTABLE_NAME_MAX_SIZE (6 + 10 + 1 + 16 + 1) |
#define | ETHASH_CRITICAL(...) |
Logs a critical error in important parts of ethash. More... | |
Enumerations | |
enum | ethash_io_rc { ETHASH_IO_FAIL = 0, ETHASH_IO_MEMO_SIZE_MISMATCH, ETHASH_IO_MEMO_MISMATCH, ETHASH_IO_MEMO_MATCH } |
Possible return values of. More... | |
Functions | |
enum ethash_io_rc | ethash_io_prepare (char const *dirname, ethash_h256_t const seedhash, FILE **output_file, uint64_t file_size, bool force_create) |
Prepares io for ethash. More... | |
FILE * | ethash_fopen (char const *file_name, char const *mode) |
An fopen wrapper for no-warnings crossplatform fopen. More... | |
char * | ethash_strncat (char *dest, size_t dest_size, char const *src, size_t count) |
An strncat wrapper for no-warnings crossplatform strncat. More... | |
bool | ethash_mkdir (char const *dirname) |
A cross-platform mkdir wrapper to create a directory or assert it's there. More... | |
bool | ethash_file_size (FILE *f, size_t *ret_size) |
Get a file's size. More... | |
int | ethash_fileno (FILE *f) |
Get a file descriptor number from a FILE stream. More... | |
char * | ethash_io_create_filename (char const *dirname, char const *filename, size_t filename_length) |
Create the filename for the DAG. More... | |
bool | ethash_get_default_dirname (char *strbuf, size_t buffsize) |
Gets the default directory name for the DAG depending on the system. More... | |
Definition in file io.h.
#define ETHASH_CRITICAL | ( | ... | ) |
enum ethash_io_rc |
Possible return values of.
bool ethash_file_size | ( | FILE * | f, |
size_t * | ret_size | ||
) |
Get a file's size.
[in] | f | The open file stream whose size to get |
[out] | size | Pass a size_t by reference to contain the file size |
Definition at line 78 of file io_posix.c.
int ethash_fileno | ( | FILE * | f | ) |
Get a file descriptor number from a FILE stream.
f | The file stream whose fd to get |
Definition at line 48 of file io_posix.c.
FILE* ethash_fopen | ( | char const * | file_name, |
char const * | mode | ||
) |
An fopen wrapper for no-warnings crossplatform fopen.
Msvc compiler considers fopen to be insecure and suggests to use their alternative. This is a wrapper for this alternative. Another way is to #define _CRT_SECURE_NO_WARNINGS, but disabling all security warnings does not sound like a good idea.
file_name | The path to the file to open |
mode | Opening mode. Check fopen() |
Definition at line 32 of file io_posix.c.
bool ethash_get_default_dirname | ( | char * | strbuf, |
size_t | buffsize | ||
) |
Gets the default directory name for the DAG depending on the system.
The spec defining this directory is here: https://github.com/ethereum/wiki/wiki/Ethash-DAG
[out] | strbuf | A string buffer of sufficient size to keep the null termninated string of the directory name |
[in] | buffsize | Size of strbuf in bytes |
Definition at line 89 of file io_posix.c.
char* ethash_io_create_filename | ( | char const * | dirname, |
char const * | filename, | ||
size_t | filename_length | ||
) |
Create the filename for the DAG.
dirname | The directory name in which the DAG file should reside If it does not end with a directory separator it is appended. |
filename | The actual name of the file |
filename_length | The length of the filename in bytes |
Definition at line 53 of file io_posix.c.
enum ethash_io_rc ethash_io_prepare | ( | char const * | dirname, |
ethash_h256_t const | seedhash, | ||
FILE ** | output_file, | ||
uint64_t | file_size, | ||
bool | force_create | ||
) |
Prepares io for ethash.
Create the DAG directory and the DAG file if they don't exist.
[in] | dirname | A null terminated c-string of the path of the ethash data directory. If it does not exist it's created. |
[in] | seedhash | The seedhash of the current block number, used in the naming of the file as can be seen from the spec at: https://github.com/ethereum/wiki/wiki/Ethash-DAG |
[out] | output_file | If there was no failure then this will point to an open file descriptor. User is responsible for closing it. In the case of memo match then the file is open on read mode, while on the case of mismatch a new file is created on write mode |
[in] | file_size | The size that the DAG file should have on disk |
[out] | force_create | If true then there is no check to see if the file already exists |
Definition at line 26 of file io.c.
bool ethash_mkdir | ( | char const * | dirname | ) |
A cross-platform mkdir wrapper to create a directory or assert it's there.
dirname | The full path of the directory to create |
Definition at line 42 of file io_posix.c.
char* ethash_strncat | ( | char * | dest, |
size_t | dest_size, | ||
char const * | src, | ||
size_t | count | ||
) |
An strncat wrapper for no-warnings crossplatform strncat.
Msvc compiler considers strncat to be insecure and suggests to use their alternative. This is a wrapper for this alternative. Another way is to #define _CRT_SECURE_NO_WARNINGS, but disabling all security warnings does not sound like a good idea.
des | Destination buffer |
dest_size | Maximum size of the destination buffer. This is the extra argument for the MSVC secure strncat |
src | Souce buffer |
count | Number of bytes to copy from source |
Definition at line 37 of file io_posix.c.