From 150f16ccc785d7f4f613d98d49976f862c3b5133 Mon Sep 17 00:00:00 2001 From: Denis Fakhrtdinov Date: Wed, 13 Nov 2024 22:06:57 +0200 Subject: [PATCH] Implement `randomx_get_cache_memory` function --- src/randomx.cpp | 7 +++++-- src/randomx.h | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/randomx.cpp b/src/randomx.cpp index 7eac750..f34a5de 100644 --- a/src/randomx.cpp +++ b/src/randomx.cpp @@ -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); @@ -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); diff --git a/src/randomx.h b/src/randomx.h index f7b85a1..df2e7df 100644 --- a/src/randomx.h +++ b/src/randomx.h @@ -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. *