Calculate randomx hashes
This commit is contained in:
@@ -1133,9 +1133,33 @@ void static RandomXMiner()
|
|||||||
arith_uint256 hashTarget;
|
arith_uint256 hashTarget;
|
||||||
hashTarget = HASHTarget;
|
hashTarget = HASHTarget;
|
||||||
|
|
||||||
// TODO: RandomX solver code
|
char randomxHash[RANDOMX_HASH_SIZE];
|
||||||
randomx_flags flags = randomx_get_flags();
|
// TODO: decide on real RandomX key and input
|
||||||
randomx_cache *myCache = randomx_alloc_cache(flags);
|
const char randomxKey[] = "HUSH RandomX testing key";
|
||||||
|
const char randomxInput[] = "HUSH RandomX testing input";
|
||||||
|
randomx_flags flags = randomx_get_flags();
|
||||||
|
randomx_cache *randomxCache = randomx_alloc_cache(flags);
|
||||||
|
|
||||||
|
if (randomxCache == NULL) {
|
||||||
|
LogPrintf("RandomX cache is null, something is wrong, cannot mine!\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
randomx_init_cache(randomxCache, &randomxKey, sizeof randomxKey);
|
||||||
|
randomx_vm *myVM = randomx_create_vm(flags, randomxCache, NULL);
|
||||||
|
|
||||||
|
randomx_calculate_hash(myVM, &randomxInput, sizeof randomxInput, randomxHash);
|
||||||
|
|
||||||
|
randomx_destroy_vm(myVM);
|
||||||
|
randomx_release_cache(randomxCache);
|
||||||
|
|
||||||
|
printf("RandomX Hash: ");
|
||||||
|
for (unsigned i = 0; i < RANDOMX_HASH_SIZE; ++i) {
|
||||||
|
printf("%02x", randomxHash[i] & 0xff);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
// TODO: use randomx hash to build a block
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user