2018-10-05 17:14:50 +00:00
|
|
|
package db
|
2018-09-02 16:44:03 +00:00
|
|
|
|
|
|
|
import (
|
2018-11-08 16:52:51 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/bytes"
|
2018-09-02 16:44:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
|
2018-09-14 05:07:30 +00:00
|
|
|
// The fields below define the suffix of keys in the db.
|
2018-09-02 16:44:03 +00:00
|
|
|
var (
|
2018-11-11 16:54:17 +00:00
|
|
|
attestationBucket = []byte("attestation-bucket")
|
|
|
|
blockBucket = []byte("block-bucket")
|
|
|
|
mainChainBucket = []byte("main-chain-bucket")
|
|
|
|
chainInfoBucket = []byte("chain-info")
|
|
|
|
blockVoteCacheBucket = []byte("block-vote-cache")
|
2018-10-17 06:11:24 +00:00
|
|
|
|
|
|
|
mainChainHeightKey = []byte("chain-height")
|
|
|
|
aStateLookupKey = []byte("active-state")
|
|
|
|
cStateLookupKey = []byte("crystallized-state")
|
2018-09-02 16:44:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// encodeSlotNumber encodes a slot number as big endian uint64.
|
|
|
|
func encodeSlotNumber(number uint64) []byte {
|
2018-11-08 16:52:51 +00:00
|
|
|
return bytes.Bytes8(number)
|
2018-09-02 16:44:03 +00:00
|
|
|
}
|