git.gammaspectra.live/P2Pool/consensus@v0.0.0-20240403173234-a039820b20c9/monero/randomx/randomx.go (about) 1 package randomx 2 3 import ( 4 "git.gammaspectra.live/P2Pool/consensus/types" 5 ) 6 7 type Hasher interface { 8 Hash(key []byte, input []byte) (types.Hash, error) 9 OptionFlags(flags ...Flag) error 10 OptionNumberOfCachedStates(n int) error 11 Close() 12 } 13 14 func SeedHeights(height uint64) (seedHeight, nextHeight uint64) { 15 return SeedHeight(height), SeedHeight(height + SeedHashEpochLag) 16 } 17 18 func SeedHeight(height uint64) uint64 { 19 if height <= SeedHashEpochBlocks+SeedHashEpochLag { 20 return 0 21 } 22 23 return (height - SeedHashEpochLag - 1) & (^uint64(SeedHashEpochBlocks - 1)) 24 } 25 26 type Flag int 27 28 const ( 29 FlagLargePages Flag = 1 << iota 30 FlagFullMemory 31 FlagSecure 32 ) 33 34 const ( 35 SeedHashEpochLag = 64 36 SeedHashEpochBlocks = 2048 37 )