prysm-pulse/beacon-chain/db/schema.go
Nishant Das 16b04699d0 Allow Initial Sync to Work with Simulator (#669)
* 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
2018-11-21 10:00:36 -08:00

41 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")
simulatorBucket = []byte("simulator-bucket")
mainChainHeightKey = []byte("chain-height")
aStateLookupKey = []byte("active-state")
cStateLookupKey = []byte("crystallized-state")
simSlotLookupKey = []byte("simulator-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)
}