Skip to content

Commit

Permalink
Implement randomx_get_cache_memory function
Browse files Browse the repository at this point in the history
  • Loading branch information
shizzard committed Dec 6, 2024
1 parent 9c4edf9 commit 150f16c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/randomx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ extern "C" {
}
}

void *randomx_get_cache_memory(randomx_cache *cache) {
assert(cache != nullptr);
return cache->memory;
}

void randomx_release_cache(randomx_cache* cache) {
assert(cache != nullptr);
cache->dealloc(cache);
Expand Down Expand Up @@ -416,8 +421,6 @@ extern "C" {
assert(blakeResult == 0);
}
machine->run(&tempHash);
unsigned char output[64];
machine->getFinalResult(output, RANDOMX_HASH_SIZE);

#ifdef USE_CSR_INTRINSICS
_mm_setcsr(fpstate);
Expand Down
10 changes: 10 additions & 0 deletions src/randomx.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ RANDOMX_EXPORT randomx_cache *randomx_alloc_cache(randomx_flags flags);
*/
RANDOMX_EXPORT void randomx_init_cache(randomx_cache *cache, const void *key, size_t keySize);

/**
* Returns a pointer to the internal memory buffer of the cache structure. The size
* of the internal memory buffer is RANDOMX_ARGON_MEMORY * ArgonBlockSize.
*
* @param cache is a pointer to a previously allocated randomx_cache structure. Must not be NULL.
*
* @return Pointer to the internal memory buffer of the cache structure.
*/
RANDOMX_EXPORT void *randomx_get_cache_memory(randomx_cache *cache);

/**
* Releases all memory occupied by the randomx_cache structure.
*
Expand Down

0 comments on commit 150f16c

Please sign in to comment.