Documentation ¶
Index ¶
- func AllocCache(flags ...Flag) (*C.randomx_cache, error)
- func AllocDataset(flags ...Flag) (*C.randomx_dataset, error)
- func CalculateHash(vm *C.randomx_vm, in []byte) []byte
- func CalculateHashFirst(vm *C.randomx_vm, in []byte)
- func CalculateHashNext(vm *C.randomx_vm, in []byte) []byte
- func CreateVM(cache *C.randomx_cache, dataset *C.randomx_dataset, flags ...Flag) (*C.randomx_vm, error)
- func DatasetItemCount() uint32
- func DestroyVM(vm *C.randomx_vm)
- func FastInitFullDataset(dataset *C.randomx_dataset, cache *C.randomx_cache, workerNum uint32)
- func GetDatasetMemory(dataset *C.randomx_dataset) unsafe.Pointer
- func InitCache(cache *C.randomx_cache, seed []byte)
- func InitDataset(dataset *C.randomx_dataset, cache *C.randomx_cache, startItem uint32, ...)
- func ReleaseCache(cache *C.randomx_cache)
- func ReleaseDataset(dataset *C.randomx_dataset)
- func Search(vm *C.randomx_vm, in []byte, target uint64, maxTimes uint64, jump uint32, ...) (Hash []byte, Found bool, Sol []byte)
- func SetVMCache(vm *C.randomx_vm, cache *C.randomx_cache)
- func SetVMDataset(vm *C.randomx_vm, dataset *C.randomx_dataset)
- type Flag
- type RxCache
- type RxDataset
- type RxVM
- func (vm *RxVM) CalcHash(in []byte) []byte
- func (vm *RxVM) CalcHashFirst(in []byte)
- func (vm *RxVM) CalcHashNext(in []byte) []byte
- func (vm *RxVM) Close()
- func (vm *RxVM) Search(in []byte, target uint64, maxTimes uint64, jump uint32, nonce []byte) (hash []byte, found bool, sol []byte)
- func (vm *RxVM) UpdateDataset(rxDataset *RxDataset)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllocCache ¶
func AllocCache(flags ...Flag) (*C.randomx_cache, error)
AllocCache allocates and initializes a new RandomX cache with given flags.
func AllocDataset ¶
func AllocDataset(flags ...Flag) (*C.randomx_dataset, error)
AllocDataset allocates and initializes a new RandomX dataset with given flags.
func CalculateHash ¶
func CalculateHash(vm *C.randomx_vm, in []byte) []byte
CalculateHash calculates the hash for the given input using the specified RandomX VM.
func CalculateHashFirst ¶
func CalculateHashFirst(vm *C.randomx_vm, in []byte)
CalculateHashFirst prepares the calculation of a hash for the given input using the specified RandomX VM.
func CalculateHashNext ¶
func CalculateHashNext(vm *C.randomx_vm, in []byte) []byte
CalculateHashNext calculates the hash for the next input using the specified RandomX VM.
func CreateVM ¶
func CreateVM(cache *C.randomx_cache, dataset *C.randomx_dataset, flags ...Flag) (*C.randomx_vm, error)
CreateVM creates a new RandomX VM with the given cache, dataset, and flags.
func DatasetItemCount ¶
func DatasetItemCount() uint32
DatasetItemCount returns the count of items in the RandomX dataset.
func FastInitFullDataset ¶
func FastInitFullDataset(dataset *C.randomx_dataset, cache *C.randomx_cache, workerNum uint32)
FastInitFullDataset using c's pthread to boost the dataset init. 472s -> 466s
func GetDatasetMemory ¶
func GetDatasetMemory(dataset *C.randomx_dataset) unsafe.Pointer
GetDatasetMemory returns a pointer to the memory of the given RandomX dataset.
func InitCache ¶
func InitCache(cache *C.randomx_cache, seed []byte)
InitCache initializes the given RandomX cache with the specified seed.
func InitDataset ¶
func InitDataset(dataset *C.randomx_dataset, cache *C.randomx_cache, startItem uint32, itemCount uint32)
InitDataset initializes the given RandomX dataset with specified parameters.
func ReleaseCache ¶
func ReleaseCache(cache *C.randomx_cache)
ReleaseCache releases the allocated RandomX cache.
func ReleaseDataset ¶
func ReleaseDataset(dataset *C.randomx_dataset)
ReleaseDataset releases the allocated RandomX dataset.
func Search ¶
func Search(vm *C.randomx_vm, in []byte, target uint64, maxTimes uint64, jump uint32, nonce []byte) (Hash []byte, Found bool, Sol []byte)
Search performs a hash search operation using the provided RandomX VM, input bytes, target, maximum iterations, jump, and nonce. It returns the hash, a boolean indicating if a solution was found, and the solution bytes.
func SetVMCache ¶
func SetVMCache(vm *C.randomx_vm, cache *C.randomx_cache)
SetVMCache sets the cache for the given RandomX VM.
func SetVMDataset ¶
func SetVMDataset(vm *C.randomx_vm, dataset *C.randomx_dataset)
SetVMDataset sets the dataset for the given RandomX VM.
Types ¶
type Flag ¶
type Flag int
Flag represents the type for various configuration flags in RandomX.
var ( FlagDefault Flag = 0 // FlagDefault represents the default configuration. FlagLargePages Flag = 1 // FlagLargePages enables large pages for dataset, cache, and VM. FlagHardAES Flag = 2 // FlagHardAES enables the use of hardware AES for VM. FlagFullMEM Flag = 4 // FlagFullMEM uses full memory for VM. FlagJIT Flag = 8 // FlagJIT enables Just-In-Time compilation for VM and cache. FlagSecure Flag = 16 // FlagSecure represents a secure configuration setting. FlagArgon2SSSE3 Flag = 32 // FlagArgon2SSSE3 uses SSSE3 instructions for cache. FlagArgon2AVX2 Flag = 64 // FlagArgon2AVX2 uses AVX2 instructions for cache. FlagArgon2 Flag = 96 // FlagArgon2 combines AVX2 and SSSE3 for cache. )
Various flags used to configure RandomX.
type RxCache ¶
type RxCache struct {
// contains filtered or unexported fields
}
RxCache represents a RandomX cache with associated seed and initialization count.
func NewRxCache ¶
NewRxCache creates a new RxCache with the specified flags.
func (*RxCache) Close ¶
func (c *RxCache) Close()
Close releases the resources associated with the RxCache.
type RxDataset ¶
type RxDataset struct {
// contains filtered or unexported fields
}
RxDataset represents a RandomX dataset with associated cache and worker number.
func NewRxDataset ¶
NewRxDataset creates a new RxDataset with the specified flags.
func (*RxDataset) CInit ¶
CInit initializes the RxDataset using C's pthreads for a faster setup. Returns true if initialization was successful.
type RxVM ¶
type RxVM struct {
// contains filtered or unexported fields
}
RxVM represents a RandomX Virtual Machine with associated dataset.
func NewRxVM ¶
NewRxVM creates a new RxVM (RandomX Virtual Machine) using the provided RxDataset and flags.
func (*RxVM) CalcHash ¶
CalcHash calculates and returns the hash of the given input using this RxVM.
func (*RxVM) CalcHashFirst ¶
CalcHashFirst prepares the RxVM to calculate the hash of the given input.
func (*RxVM) CalcHashNext ¶
CalcHashNext calculates and returns the hash of the next input using this RxVM.
func (*RxVM) Search ¶
func (vm *RxVM) Search(in []byte, target uint64, maxTimes uint64, jump uint32, nonce []byte) (hash []byte, found bool, sol []byte)
Search performs a hash search operation using this RxVM with the given input bytes, target, maximum iterations, jump, and nonce. It returns the hash, a boolean indicating if a solution was found, and the solution bytes.
func (*RxVM) UpdateDataset ¶
UpdateDataset updates the RxVM with a new dataset and cache from the provided RxDataset.