mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-27 21:57:16 +00:00
4d43f5128a
* remove all instances of simulator service * fix flag decl * fix lint
42 lines
1.3 KiB
Go
42 lines
1.3 KiB
Go
package db
|
|
|
|
import (
|
|
"github.com/prysmaticlabs/prysm/shared/bytes"
|
|
)
|
|
|
|
// The Schema will define how to store and retrieve data from the db.
|
|
// Currently we store blocks by prefixing `block` to their hash and
|
|
// using that as the key to store blocks.
|
|
// `block` + hash -> block
|
|
//
|
|
// We store the crystallized state using the crystallized state lookup key, and
|
|
// also the genesis block using the genesis lookup key.
|
|
// The canonical head is stored using the canonical head lookup key.
|
|
|
|
// The fields below define the suffix of keys in the db.
|
|
var (
|
|
attestationBucket = []byte("attestation-bucket")
|
|
blockBucket = []byte("block-bucket")
|
|
mainChainBucket = []byte("main-chain-bucket")
|
|
chainInfoBucket = []byte("chain-info")
|
|
blockVoteCacheBucket = []byte("block-vote-cache")
|
|
|
|
mainChainHeightKey = []byte("chain-height")
|
|
stateLookupKey = []byte("state")
|
|
|
|
// DB internal use
|
|
cleanupHistoryBucket = []byte("cleanup-history-bucket")
|
|
cleanedFinalizedSlotKey = []byte("cleaned-finalized-slot")
|
|
)
|
|
|
|
// encodeSlotNumber encodes a slot number as big endian uint64.
|
|
func encodeSlotNumber(number uint64) []byte {
|
|
return bytes.Bytes8(number)
|
|
}
|
|
|
|
// decodeSlotNumber returns a slot number which has been
|
|
// encoded as a big endian uint64 in the byte array.
|
|
func decodeToSlotNumber(bytearray []byte) uint64 {
|
|
return bytes.FromBytes8(bytearray)
|
|
}
|