mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-22 14:56:44 +00:00

* Add selected chain store and optimize block locator with it * Fix build error * Fix comments * Fix IsStaged * Rename CalculateSelectedParentChainChanges to CalculateChainPath and SelectedParentChainChanges->SelectedChainPath * Use binary.LittleEndian directly to allow compiler optimizations * Remove boolean from HeadersSelectedChainStore interface * Prevent endless loop in block locator
16 lines
441 B
Go
16 lines
441 B
Go
package binaryserialization
|
|
|
|
import "encoding/binary"
|
|
|
|
// SerializeChainBlockIndex serializes chain block index
|
|
func SerializeChainBlockIndex(index uint64) []byte {
|
|
var keyBytes [8]byte
|
|
binary.LittleEndian.PutUint64(keyBytes[:], index)
|
|
return keyBytes[:]
|
|
}
|
|
|
|
// DeserializeChainBlockIndex deserializes chain block index to uint64
|
|
func DeserializeChainBlockIndex(indexBytes []byte) uint64 {
|
|
return binary.LittleEndian.Uint64(indexBytes)
|
|
}
|