Documentation
¶
Index ¶
- type BeaconDB
- func (db *BeaconDB) Close() error
- func (db *BeaconDB) DeleteBlockVoteCache(blockHashes [][32]byte) error
- func (db *BeaconDB) GenesisTime() (time.Time, error)
- func (db *BeaconDB) GetAttestation(hash [32]byte) (*pb.Attestation, error)
- func (db *BeaconDB) GetBlock(hash [32]byte) (*pb.BeaconBlock, error)
- func (db *BeaconDB) GetBlockBySlot(slot uint64) (*pb.BeaconBlock, error)
- func (db *BeaconDB) GetChainHead() (*pb.BeaconBlock, error)
- func (db *BeaconDB) GetCleanedFinalizedSlot() (uint64, error)
- func (db *BeaconDB) GetSimulatorSlot() (uint64, error)
- func (db *BeaconDB) GetState() (*pb.BeaconState, error)
- func (db *BeaconDB) GetUnfinalizedBlockState(stateRoot [32]byte) (*pb.BeaconState, error)
- func (db *BeaconDB) HasAttestation(hash [32]byte) bool
- func (db *BeaconDB) HasBlock(hash [32]byte) bool
- func (db *BeaconDB) InitializeState(genesisValidatorRegistry []*pb.ValidatorRecord) error
- func (db *BeaconDB) ReadBlockVoteCache(blockHashes [][32]byte) (utils.BlockVoteCache, error)
- func (db *BeaconDB) SaveAttestation(attestation *pb.Attestation) error
- func (db *BeaconDB) SaveBlock(block *pb.BeaconBlock) error
- func (db *BeaconDB) SaveCleanedFinalizedSlot(slot uint64) error
- func (db *BeaconDB) SaveSimulatorSlot(slot uint64) error
- func (db *BeaconDB) SaveState(beaconState *pb.BeaconState) error
- func (db *BeaconDB) SaveUnfinalizedBlockState(beaconState *pb.BeaconState) error
- func (db *BeaconDB) UpdateChainHead(block *pb.BeaconBlock, beaconState *pb.BeaconState) error
- func (db *BeaconDB) WriteBlockVoteCache(blockVoteCache utils.BlockVoteCache) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BeaconDB ¶
type BeaconDB struct {
DatabasePath string
// contains filtered or unexported fields
}
BeaconDB manages the data layer of the beacon chain implementation. The exposed methods do not have an opinion of the underlying data engine, but instead reflect the beacon chain logic. For example, instead of defining get, put, remove This defines methods such as getBlock, saveBlocksAndAttestations, etc.
func NewDB ¶
NewDB initializes a new DB. If the genesis block and states do not exist, this method creates it.
func (*BeaconDB) DeleteBlockVoteCache ¶
DeleteBlockVoteCache removes vote cache for specified blocks from DB.
func (*BeaconDB) GenesisTime ¶
GenesisTime returns the genesis timestamp for the state.
func (*BeaconDB) GetAttestation ¶
func (db *BeaconDB) GetAttestation(hash [32]byte) (*pb.Attestation, error)
GetAttestation retrieves an attestation record from the db using its hash.
func (*BeaconDB) GetBlock ¶
func (db *BeaconDB) GetBlock(hash [32]byte) (*pb.BeaconBlock, error)
GetBlock accepts a block hash and returns the corresponding block. Returns nil if the block does not exist.
func (*BeaconDB) GetBlockBySlot ¶
func (db *BeaconDB) GetBlockBySlot(slot uint64) (*pb.BeaconBlock, error)
GetBlockBySlot accepts a slot number and returns the corresponding block in the main chain. Returns nil if a block was not recorded for the given slot.
func (*BeaconDB) GetChainHead ¶
func (db *BeaconDB) GetChainHead() (*pb.BeaconBlock, error)
GetChainHead returns the head of the main chain.
func (*BeaconDB) GetCleanedFinalizedSlot ¶
GetCleanedFinalizedSlot returns the most recent finalized slot when we did a DB clean up.
func (*BeaconDB) GetSimulatorSlot ¶
GetSimulatorSlot returns the last saved simulator slot from the disk.
func (*BeaconDB) GetState ¶
func (db *BeaconDB) GetState() (*pb.BeaconState, error)
GetState fetches the canonical beacon chain's state from the DB.
func (*BeaconDB) GetUnfinalizedBlockState ¶
func (db *BeaconDB) GetUnfinalizedBlockState(stateRoot [32]byte) (*pb.BeaconState, error)
GetUnfinalizedBlockState fetches an unfinalized block's active and crystallized state pair.
func (*BeaconDB) HasAttestation ¶
HasAttestation checks if the attestation exists.
func (*BeaconDB) HasBlock ¶
HasBlock accepts a block hash and returns true if the block does not exist.
func (*BeaconDB) InitializeState ¶
func (db *BeaconDB) InitializeState(genesisValidatorRegistry []*pb.ValidatorRecord) error
InitializeState creates an initial genesis state for the beacon node using a set of genesis validators.
func (*BeaconDB) ReadBlockVoteCache ¶
func (db *BeaconDB) ReadBlockVoteCache(blockHashes [][32]byte) (utils.BlockVoteCache, error)
ReadBlockVoteCache read block vote cache from DB.
func (*BeaconDB) SaveAttestation ¶
func (db *BeaconDB) SaveAttestation(attestation *pb.Attestation) error
SaveAttestation puts the attestation record into the beacon chain db.
func (*BeaconDB) SaveBlock ¶
func (db *BeaconDB) SaveBlock(block *pb.BeaconBlock) error
SaveBlock accepts a block and writes it to disk.
func (*BeaconDB) SaveCleanedFinalizedSlot ¶
SaveCleanedFinalizedSlot writes the slot when we did DB cleanup so we can start from here in future cleanup tasks.
func (*BeaconDB) SaveSimulatorSlot ¶
SaveSimulatorSlot saves the current slot of the simulator to the disk.
func (*BeaconDB) SaveState ¶
func (db *BeaconDB) SaveState(beaconState *pb.BeaconState) error
SaveState updates the beacon chain state.
func (*BeaconDB) SaveUnfinalizedBlockState ¶
func (db *BeaconDB) SaveUnfinalizedBlockState(beaconState *pb.BeaconState) error
SaveUnfinalizedBlockState persists the associated state for a given unfinalized block.
func (*BeaconDB) UpdateChainHead ¶
func (db *BeaconDB) UpdateChainHead(block *pb.BeaconBlock, beaconState *pb.BeaconState) error
UpdateChainHead atomically updates the head of the chain as well as the corresponding state changes Including a new crystallized state is optional.
func (*BeaconDB) WriteBlockVoteCache ¶
func (db *BeaconDB) WriteBlockVoteCache(blockVoteCache utils.BlockVoteCache) error
WriteBlockVoteCache write block vote cache object into DB.