randomx_cache and randomx_dataset changed to standard-layout structs

This commit is contained in:
tevador
2019-04-28 12:44:28 +02:00
parent fd7186f873
commit 22a3aa8d79
19 changed files with 155 additions and 173 deletions

View File

@@ -165,15 +165,13 @@ int main(int argc, char** argv) {
Stopwatch sw(true);
cache = randomx_alloc_cache(flags);
if (cache == nullptr) {
std::cout << "ERROR: Cache allocation failed" << std::endl;
return 1;
throw std::runtime_error("Cache allocation failed");
}
randomx_init_cache(cache, &seed, sizeof(seed));
if (miningMode) {
dataset = randomx_alloc_dataset(flags);
if (dataset == nullptr) {
std::cout << "ERROR: Dataset allocation failed" << std::endl;
return 1;
throw std::runtime_error("Dataset allocation failed");
}
uint32_t datasetItemCount = randomx_dataset_item_count();
if (initThreadCount > 1) {
@@ -200,8 +198,7 @@ int main(int argc, char** argv) {
for (int i = 0; i < threadCount; ++i) {
randomx_vm *vm = randomx_create_vm(flags, cache, dataset);
if (vm == nullptr) {
std::cout << "ERROR: Unsupported virtual machine options" << std::endl;
return 1;
throw std::runtime_error("Unsupported virtual machine options");
}
vms.push_back(vm);
}
@@ -221,7 +218,14 @@ int main(int argc, char** argv) {
else {
mine(vms[0], std::ref(atomicNonce), std::ref(result), noncesCount, 0);
}
double elapsed = sw.getElapsed();
for (unsigned i = 0; i < vms.size(); ++i)
randomx_destroy_vm(vms[i]);
if (miningMode)
randomx_release_dataset(dataset);
else
randomx_release_cache(cache);
std::cout << "Calculated result: ";
result.print(std::cout);
if (noncesCount == 1000 && seedValue == 0)