mirror of
				https://git.wownero.com/wownero/RandomWOW.git
				synced 2024-08-15 00:23:14 +00:00 
			
		
		
		
	Fixed API examples
This commit is contained in:
		
							parent
							
								
									1037cc0139
								
							
						
					
					
						commit
						cb3d57376f
					
				
					 2 changed files with 10 additions and 5 deletions
				
			
		|  | @ -2,12 +2,12 @@ | |||
| #include <stdio.h> | ||||
| 
 | ||||
| int main() { | ||||
| 	const char mySeed[] = "RandomX example seed"; | ||||
| 	const char myKey[] = "RandomX example key"; | ||||
| 	const char myInput[] = "RandomX example input"; | ||||
| 	char hash[RANDOMX_HASH_SIZE]; | ||||
| 
 | ||||
| 	randomx_cache *myCache = randomx_alloc_cache(RANDOMX_FLAG_DEFAULT); | ||||
| 	randomx_init_cache(myCache, mySeed, sizeof mySeed); | ||||
| 	randomx_init_cache(myCache, &myKey, sizeof myKey); | ||||
| 	randomx_vm *myMachine = randomx_create_vm(RANDOMX_FLAG_DEFAULT, myCache, NULL); | ||||
| 
 | ||||
| 	randomx_calculate_hash(myMachine, &myInput, sizeof myInput, hash); | ||||
|  |  | |||
|  | @ -4,7 +4,7 @@ | |||
| #include <thread> | ||||
| 
 | ||||
| int main() { | ||||
| 	const char mySeed[] = "RandomX example seed"; | ||||
| 	const char myKey[] = "RandomX example key"; | ||||
| 	const char myInput[] = "RandomX example input"; | ||||
| 	char hash[RANDOMX_HASH_SIZE]; | ||||
| 
 | ||||
|  | @ -13,21 +13,26 @@ int main() { | |||
| 		std::cout << "Cache allocation failed" << std::endl; | ||||
| 		return 1; | ||||
| 	} | ||||
| 	randomx_init_cache(myCache, mySeed, sizeof mySeed); | ||||
| 	randomx_init_cache(myCache, myKey, sizeof myKey); | ||||
| 
 | ||||
| 	randomx_dataset *myDataset = randomx_alloc_dataset(RANDOMX_FLAG_LARGE_PAGES); | ||||
| 	if (myDataset == nullptr) { | ||||
| 		std::cout << "Dataset allocation failed" << std::endl; | ||||
| 		return 1; | ||||
| 	} | ||||
| 
 | ||||
| 	auto datasetItemCount = randomx_dataset_item_count(); | ||||
| 	std::thread t1(&randomx_init_dataset, myDataset, myCache, 0, datasetItemCount / 2); | ||||
| 	std::thread t2(&randomx_init_dataset, myDataset, myCache, datasetItemCount / 2, datasetItemCount / 2); | ||||
| 	std::thread t2(&randomx_init_dataset, myDataset, myCache, datasetItemCount / 2, datasetItemCount - datasetItemCount / 2); | ||||
| 	t1.join(); | ||||
| 	t2.join(); | ||||
| 	randomx_release_cache(myCache); | ||||
| 
 | ||||
| 	randomx_vm *myMachine = randomx_create_vm((randomx_flags)(RANDOMX_FLAG_FULL_MEM | RANDOMX_FLAG_JIT | RANDOMX_FLAG_HARD_AES | RANDOMX_FLAG_LARGE_PAGES), nullptr, myDataset); | ||||
| 	if (myMachine == nullptr) { | ||||
| 		std::cout << "Failed to create a virtual machine" << std::endl; | ||||
| 		return 1; | ||||
| 	} | ||||
| 
 | ||||
| 	randomx_calculate_hash(myMachine, &myInput, sizeof myInput, hash); | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue