prysm-pulse/beacon-chain/db/schema.go

47 lines
1.6 KiB
Go
Raw Normal View History

2018-10-05 17:14:50 +00:00
package db
2019-03-03 17:31:29 +00:00
import (
"github.com/prysmaticlabs/prysm/shared/bytesutil"
)
// 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
//
2019-03-03 17:31:29 +00:00
// We store the state using the state lookup key, and
// also the genesis block using the genesis lookup key.
// The canonical head is stored using the canonical head lookup key.
2018-09-14 05:07:30 +00:00
// The fields below define the suffix of keys in the db.
var (
attestationBucket = []byte("attestation-bucket")
blockOperationsBucket = []byte("block-operations-bucket")
blockBucket = []byte("block-bucket")
mainChainBucket = []byte("main-chain-bucket")
2019-03-19 02:15:50 +00:00
histStateBucket = []byte("historical-state-bucket")
chainInfoBucket = []byte("chain-info")
validatorBucket = []byte("validator")
2018-10-17 06:11:24 +00:00
mainChainHeightKey = []byte("chain-height")
stateLookupKey = []byte("state")
finalizedStateLookupKey = []byte("finalized-state")
justifiedStateLookupKey = []byte("justified-state")
finalizedBlockLookupKey = []byte("finalized-block")
justifiedBlockLookupKey = []byte("justified-block")
// DB internal use
2019-03-27 14:24:34 +00:00
cleanupHistoryBucket = []byte("cleanup-history-bucket")
)
// encodeSlotNumber encodes a slot number as little-endian uint32.
func encodeSlotNumber(number uint64) []byte {
return bytesutil.Bytes8(number)
}
// decodeSlotNumber returns a slot number which has been
// encoded as a little-endian uint32 in the byte array.
func decodeToSlotNumber(bytearray []byte) uint64 {
return bytesutil.FromBytes8(bytearray)
}