stage.go raw

   1  package lattice
   2  
   3  // MakeCodeKey encodes a stage in the high 8 bits and a 56-bit hash below it.
   4  // The parameter order is (stage, hash). iskra/stage.mx MakeCodeKey.
   5  func MakeCodeKey(stage uint8, hash uint64) Key {
   6  	return Key(uint64(stage)<<56 | hash&0x00FFFFFFFFFFFFFF)
   7  }
   8  
   9  // KeyStage extracts the stage byte from a key.
  10  func KeyStage(key Key) uint8 { return uint8(key >> 56) }
  11  
  12  // KeyHash extracts the 56-bit hash from a key.
  13  func KeyHash(key Key) uint64 { return uint64(key) & 0x00FFFFFFFFFFFFFF }
  14