mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-09 19:21:19 +00:00
16b04699d0
* polling interval * adding proto message * changing proto messages * changing naming * adding slot functionality * initial sync working * new changes * more sync fixes * its working now * finally working * add tests * fix tests * tests * adding tests * lint * log checks * making changes to simulator * update logs * fix tests * get sync to work with crystallized state * fixing race * making requested changes * unexport * documentation * gazelle and fix merge conflicts * adding repeated requests * fix lint * adding new clock , db methods, and util func * revert change to test * gazelle * add in test * gazelle * finally working * save slot * fix lint and constant
48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
// Package bytes defines helper methods for converting integers to byte slices.
|
|
package bytes
|
|
|
|
import (
|
|
"encoding/binary"
|
|
)
|
|
|
|
// Bytes1 returns integer x to bytes in big-endian format, x.to_bytes(1, 'big').
|
|
func Bytes1(x uint64) []byte {
|
|
bytes := make([]byte, 8)
|
|
binary.BigEndian.PutUint64(bytes, x)
|
|
return bytes[7:]
|
|
}
|
|
|
|
// Bytes2 returns integer x to bytes in big-endian format, x.to_bytes(2, 'big').
|
|
func Bytes2(x uint64) []byte {
|
|
bytes := make([]byte, 8)
|
|
binary.BigEndian.PutUint64(bytes, x)
|
|
return bytes[6:]
|
|
}
|
|
|
|
// Bytes3 returns integer x to bytes in big-endian format, x.to_bytes(3, 'big').
|
|
func Bytes3(x uint64) []byte {
|
|
bytes := make([]byte, 8)
|
|
binary.BigEndian.PutUint64(bytes, x)
|
|
return bytes[5:]
|
|
}
|
|
|
|
// Bytes4 returns integer x to bytes in big-endian format, x.to_bytes(4, 'big').
|
|
func Bytes4(x uint64) []byte {
|
|
bytes := make([]byte, 8)
|
|
binary.BigEndian.PutUint64(bytes, x)
|
|
return bytes[4:]
|
|
}
|
|
|
|
// Bytes8 returns integer x to bytes in big-endian format, x.to_bytes(8, 'big').
|
|
func Bytes8(x uint64) []byte {
|
|
bytes := make([]byte, 8)
|
|
binary.BigEndian.PutUint64(bytes, x)
|
|
return bytes
|
|
}
|
|
|
|
// FromBytes8 returns an integer which is stored in the big-endian format(8, 'big')
|
|
// from a byte array.
|
|
func FromBytes8(x []byte) uint64 {
|
|
return binary.BigEndian.Uint64(x)
|
|
}
|