consensus/monero/randomx/randomx.go
DataHoarder fe75cf259c
All checks were successful
continuous-integration/drone/tag Build is passing
continuous-integration/drone/push Build is passing
P2Pool consensus v3.0.0
Migrate cmd utils, cmds to own repository
2024-04-03 19:43:13 +02:00

38 lines
717 B
Go

package randomx
import (
"git.gammaspectra.live/P2Pool/consensus/v3/types"
)
type Hasher interface {
Hash(key []byte, input []byte) (types.Hash, error)
OptionFlags(flags ...Flag) error
OptionNumberOfCachedStates(n int) error
Close()
}
func SeedHeights(height uint64) (seedHeight, nextHeight uint64) {
return SeedHeight(height), SeedHeight(height + SeedHashEpochLag)
}
func SeedHeight(height uint64) uint64 {
if height <= SeedHashEpochBlocks+SeedHashEpochLag {
return 0
}
return (height - SeedHashEpochLag - 1) & (^uint64(SeedHashEpochBlocks - 1))
}
type Flag int
const (
FlagLargePages Flag = 1 << iota
FlagFullMemory
FlagSecure
)
const (
SeedHashEpochLag = 64
SeedHashEpochBlocks = 2048
)