mirror of
https://git.wownero.com/wownero/RandomWOW.git
synced 2024-12-22 15:58:53 +00:00
Cache seed renamed to key
This commit is contained in:
parent
1a4bde36be
commit
c87dcc8ae5
@ -47,15 +47,15 @@ static_assert(ARGON2_BLOCK_SIZE == randomx::ArgonBlockSize, "Unpexpected value o
|
|||||||
|
|
||||||
namespace randomx {
|
namespace randomx {
|
||||||
|
|
||||||
void initCache(randomx_cache* cache, const void* seed, size_t seedSize) {
|
void initCache(randomx_cache* cache, const void* key, size_t keySize) {
|
||||||
uint32_t memory_blocks, segment_length;
|
uint32_t memory_blocks, segment_length;
|
||||||
argon2_instance_t instance;
|
argon2_instance_t instance;
|
||||||
argon2_context context;
|
argon2_context context;
|
||||||
|
|
||||||
context.out = nullptr;
|
context.out = nullptr;
|
||||||
context.outlen = 0;
|
context.outlen = 0;
|
||||||
context.pwd = CONST_CAST(uint8_t *)seed;
|
context.pwd = CONST_CAST(uint8_t *)key;
|
||||||
context.pwdlen = (uint32_t)seedSize;
|
context.pwdlen = (uint32_t)keySize;
|
||||||
context.salt = CONST_CAST(uint8_t *)RANDOMX_ARGON_SALT;
|
context.salt = CONST_CAST(uint8_t *)RANDOMX_ARGON_SALT;
|
||||||
context.saltlen = (uint32_t)randomx::ArgonSaltSize;
|
context.saltlen = (uint32_t)randomx::ArgonSaltSize;
|
||||||
context.secret = NULL;
|
context.secret = NULL;
|
||||||
@ -100,7 +100,7 @@ namespace randomx {
|
|||||||
fill_memory_blocks(&instance);
|
fill_memory_blocks(&instance);
|
||||||
|
|
||||||
cache->reciprocalCache.clear();
|
cache->reciprocalCache.clear();
|
||||||
randomx::Blake2Generator gen(seed, seedSize);
|
randomx::Blake2Generator gen(key, keySize);
|
||||||
for (int i = 0; i < RANDOMX_CACHE_ACCESSES; ++i) {
|
for (int i = 0; i < RANDOMX_CACHE_ACCESSES; ++i) {
|
||||||
randomx::generateSuperscalar(cache->programs[i], gen);
|
randomx::generateSuperscalar(cache->programs[i], gen);
|
||||||
for (unsigned j = 0; j < cache->programs[i].getSize(); ++j) {
|
for (unsigned j = 0; j < cache->programs[i].getSize(); ++j) {
|
||||||
@ -114,8 +114,8 @@ namespace randomx {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void initCacheCompile(randomx_cache* cache, const void* seed, size_t seedSize) {
|
void initCacheCompile(randomx_cache* cache, const void* key, size_t keySize) {
|
||||||
initCache(cache, seed, seedSize);
|
initCache(cache, key, keySize);
|
||||||
cache->jit->generateSuperscalarHash(cache->programs, cache->reciprocalCache);
|
cache->jit->generateSuperscalarHash(cache->programs, cache->reciprocalCache);
|
||||||
cache->jit->generateDatasetInitCode();
|
cache->jit->generateDatasetInitCode();
|
||||||
}
|
}
|
||||||
|
@ -76,8 +76,8 @@ extern "C" {
|
|||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
void randomx_init_cache(randomx_cache *cache, const void *seed, size_t seedSize) {
|
void randomx_init_cache(randomx_cache *cache, const void *key, size_t keySize) {
|
||||||
cache->initialize(cache, seed, seedSize);
|
cache->initialize(cache, key, keySize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void randomx_release_cache(randomx_cache* cache) {
|
void randomx_release_cache(randomx_cache* cache) {
|
||||||
|
@ -56,13 +56,13 @@ extern "C" {
|
|||||||
randomx_cache *randomx_alloc_cache(randomx_flags flags);
|
randomx_cache *randomx_alloc_cache(randomx_flags flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the cache memory and SuperscalarHash using the provided seed value.
|
* Initializes the cache memory and SuperscalarHash using the provided key value.
|
||||||
*
|
*
|
||||||
* @param cache is a pointer to a previously allocated randomx_cache structure. Must not be NULL.
|
* @param cache is a pointer to a previously allocated randomx_cache structure. Must not be NULL.
|
||||||
* @param seed is a pointer to memory which contains the seed value. Must not be NULL.
|
* @param key is a pointer to memory which contains the key value. Must not be NULL.
|
||||||
* @param seedSize is the number of bytes of the seed.
|
* @param keySize is the number of bytes of the key.
|
||||||
*/
|
*/
|
||||||
void randomx_init_cache(randomx_cache *cache, const void *seed, size_t seedSize);
|
void randomx_init_cache(randomx_cache *cache, const void *key, size_t keySize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Releases all memory occupied by the randomx_cache structure.
|
* Releases all memory occupied by the randomx_cache structure.
|
||||||
@ -146,7 +146,7 @@ randomx_vm *randomx_create_vm(randomx_flags flags, randomx_cache *cache, randomx
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Reinitializes a virtual machine with a new Cache. This function should be called anytime
|
* Reinitializes a virtual machine with a new Cache. This function should be called anytime
|
||||||
* the Cache is reinitialized with a new seed.
|
* the Cache is reinitialized with a new key.
|
||||||
*
|
*
|
||||||
* @param machine is a pointer to a randomx_vm structure that was initialized
|
* @param machine is a pointer to a randomx_vm structure that was initialized
|
||||||
* without RANDOMX_FLAG_FULL_MEM. Must not be NULL.
|
* without RANDOMX_FLAG_FULL_MEM. Must not be NULL.
|
||||||
|
@ -126,7 +126,7 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
if (miningMode) {
|
if (miningMode) {
|
||||||
flags = (randomx_flags)(flags | RANDOMX_FLAG_FULL_MEM);
|
flags = (randomx_flags)(flags | RANDOMX_FLAG_FULL_MEM);
|
||||||
std::cout << " - full memory mode (2 GiB)" << std::endl;
|
std::cout << " - full memory mode (2080 MiB)" << std::endl;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::cout << " - light memory mode (256 MiB)" << std::endl;
|
std::cout << " - light memory mode (256 MiB)" << std::endl;
|
||||||
|
@ -23,7 +23,6 @@ along with RandomX. If not, see<http://www.gnu.org/licenses/>.
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
#include <climits>
|
|
||||||
#include "vm_interpreted.hpp"
|
#include "vm_interpreted.hpp"
|
||||||
#include "dataset.hpp"
|
#include "dataset.hpp"
|
||||||
#include "intrin_portable.h"
|
#include "intrin_portable.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user