Monero
Classes | Macros | Typedefs | Functions | Variables
rx-slow-hash.c File Reference
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
#include "randomx.h"
#include "c_threads.h"
#include "hash-ops.h"
#include "misc_log_ex.h"
Include dependency graph for rx-slow-hash.c:

Classes

struct  seedinfo
 
struct  thread_info
 

Macros

#define RX_LOGCAT   "randomx"
 
#define alloc_err_msg(x)   mdebug(RX_LOGCAT, x);
 
#define THREADV   __thread
 
#define SEEDHASH_EPOCH_BLOCKS   2048 /* Must be same as BLOCKS_SYNCHRONIZING_MAX_COUNT in cryptonote_config.h */
 
#define SEEDHASH_EPOCH_LAG   64
 

Typedefs

typedef struct seedinfo seedinfo
 
typedef struct thread_info thread_info
 

Functions

static bool is_main (const char *seedhash)
 
static bool is_secondary (const char *seedhash)
 
static void local_abort (const char *msg)
 
static void hash2hex (const char *hash, char *hex)
 
static int disabled_flags (void)
 
static int enabled_flags (void)
 
static int is_power_of_2 (uint64_t n)
 
static int get_seedhash_epoch_lag (void)
 
static unsigned int get_seedhash_epoch_blocks (void)
 
uint64_t rx_seedheight (const uint64_t height)
 
void rx_seedheights (const uint64_t height, uint64_t *seedheight, uint64_t *nextheight)
 
static void rx_alloc_dataset (randomx_flags flags, randomx_dataset **dataset, int ignore_env)
 
static void rx_alloc_cache (randomx_flags flags, randomx_cache **cache)
 
static void rx_init_full_vm (randomx_flags flags, randomx_vm **vm)
 
static void rx_init_light_vm (randomx_flags flags, randomx_vm **vm, randomx_cache *cache)
 
static CTHR_THREAD_RTYPE rx_seedthread (void *arg)
 
static void rx_init_dataset (size_t max_threads)
 
static CTHR_THREAD_RTYPE rx_set_main_seedhash_thread (void *arg)
 
void rx_set_main_seedhash (const char *seedhash, size_t max_dataset_init_threads)
 
void rx_slow_hash (const char *seedhash, const void *data, size_t length, char *result_hash)
 
void rx_set_miner_thread (uint32_t value, size_t max_dataset_init_threads)
 
uint32_t rx_get_miner_thread ()
 
void rx_slow_hash_allocate_state ()
 
static void rx_destroy_vm (randomx_vm **vm)
 
void rx_slow_hash_free_state ()
 

Variables

static CTHR_RWLOCK_TYPE main_dataset_lock = CTHR_RWLOCK_INIT
 
static CTHR_RWLOCK_TYPE main_cache_lock = CTHR_RWLOCK_INIT
 
static randomx_datasetmain_dataset = NULL
 
static randomx_cachemain_cache = NULL
 
static char main_seedhash [HASH_SIZE]
 
static int main_seedhash_set = 0
 
static CTHR_RWLOCK_TYPE secondary_cache_lock = CTHR_RWLOCK_INIT
 
static randomx_cachesecondary_cache = NULL
 
static char secondary_seedhash [HASH_SIZE]
 
static int secondary_seedhash_set = 0
 
static THREADV randomx_vmmain_vm_full = NULL
 
static THREADV randomx_vmmain_vm_light = NULL
 
static THREADV randomx_vmsecondary_vm_light = NULL
 
static THREADV uint32_t miner_thread = 0
 

Macro Definition Documentation

◆ alloc_err_msg

#define alloc_err_msg (   x)    mdebug(RX_LOGCAT, x);

◆ RX_LOGCAT

#define RX_LOGCAT   "randomx"

◆ SEEDHASH_EPOCH_BLOCKS

#define SEEDHASH_EPOCH_BLOCKS   2048 /* Must be same as BLOCKS_SYNCHRONIZING_MAX_COUNT in cryptonote_config.h */

◆ SEEDHASH_EPOCH_LAG

#define SEEDHASH_EPOCH_LAG   64

◆ THREADV

#define THREADV   __thread

Typedef Documentation

◆ seedinfo

typedef struct seedinfo seedinfo

◆ thread_info

typedef struct thread_info thread_info

Function Documentation

◆ disabled_flags()

static int disabled_flags ( void  )
inlinestatic

◆ enabled_flags()

static int enabled_flags ( void  )
inlinestatic

◆ get_seedhash_epoch_blocks()

static unsigned int get_seedhash_epoch_blocks ( void  )
static

◆ get_seedhash_epoch_lag()

static int get_seedhash_epoch_lag ( void  )
static

◆ hash2hex()

static void hash2hex ( const char *  hash,
char *  hex 
)
static

◆ is_main()

static bool is_main ( const char *  seedhash)
static

◆ is_power_of_2()

static int is_power_of_2 ( uint64_t  n)
inlinestatic

◆ is_secondary()

static bool is_secondary ( const char *  seedhash)
static

◆ local_abort()

static void local_abort ( const char *  msg)
static

◆ rx_alloc_cache()

static void rx_alloc_cache ( randomx_flags  flags,
randomx_cache **  cache 
)
static

◆ rx_alloc_dataset()

static void rx_alloc_dataset ( randomx_flags  flags,
randomx_dataset **  dataset,
int  ignore_env 
)
static

◆ rx_destroy_vm()

static void rx_destroy_vm ( randomx_vm **  vm)
static

◆ rx_get_miner_thread()

uint32_t rx_get_miner_thread ( void  )

◆ rx_init_dataset()

static void rx_init_dataset ( size_t  max_threads)
static

◆ rx_init_full_vm()

static void rx_init_full_vm ( randomx_flags  flags,
randomx_vm **  vm 
)
static

◆ rx_init_light_vm()

static void rx_init_light_vm ( randomx_flags  flags,
randomx_vm **  vm,
randomx_cache cache 
)
static

◆ rx_seedheight()

uint64_t rx_seedheight ( const uint64_t  height)

◆ rx_seedheights()

void rx_seedheights ( const uint64_t  height,
uint64_t seedheight,
uint64_t nextheight 
)

◆ rx_seedthread()

static CTHR_THREAD_RTYPE rx_seedthread ( void *  arg)
static

◆ rx_set_main_seedhash()

void rx_set_main_seedhash ( const char *  seedhash,
size_t  max_dataset_init_threads 
)

◆ rx_set_main_seedhash_thread()

static CTHR_THREAD_RTYPE rx_set_main_seedhash_thread ( void *  arg)
static

◆ rx_set_miner_thread()

void rx_set_miner_thread ( uint32_t  value,
size_t  max_dataset_init_threads 
)

◆ rx_slow_hash()

void rx_slow_hash ( const char *  seedhash,
const void *  data,
size_t  length,
char *  result_hash 
)

◆ rx_slow_hash_allocate_state()

void rx_slow_hash_allocate_state ( void  )

◆ rx_slow_hash_free_state()

void rx_slow_hash_free_state ( void  )

Variable Documentation

◆ main_cache

randomx_cache* main_cache = NULL
static

◆ main_cache_lock

CTHR_RWLOCK_TYPE main_cache_lock = CTHR_RWLOCK_INIT
static

◆ main_dataset

randomx_dataset* main_dataset = NULL
static

◆ main_dataset_lock

CTHR_RWLOCK_TYPE main_dataset_lock = CTHR_RWLOCK_INIT
static

◆ main_seedhash

char main_seedhash[HASH_SIZE]
static

◆ main_seedhash_set

int main_seedhash_set = 0
static

◆ main_vm_full

THREADV randomx_vm* main_vm_full = NULL
static

◆ main_vm_light

THREADV randomx_vm* main_vm_light = NULL
static

◆ miner_thread

THREADV uint32_t miner_thread = 0
static

◆ secondary_cache

randomx_cache* secondary_cache = NULL
static

◆ secondary_cache_lock

CTHR_RWLOCK_TYPE secondary_cache_lock = CTHR_RWLOCK_INIT
static

◆ secondary_seedhash

char secondary_seedhash[HASH_SIZE]
static

◆ secondary_seedhash_set

int secondary_seedhash_set = 0
static

◆ secondary_vm_light

THREADV randomx_vm* secondary_vm_light = NULL
static