db

package
v0.0.0-...-b605237 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 29, 2018 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

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

func NewDB(dirPath string) (*BeaconDB, error)

NewDB initializes a new DB. If the genesis block and states do not exist, this method creates it.

func (*BeaconDB) Close

func (db *BeaconDB) Close() error

Close closes the underlying leveldb database.

func (*BeaconDB) DeleteBlockVoteCache

func (db *BeaconDB) DeleteBlockVoteCache(blockHashes [][32]byte) error

DeleteBlockVoteCache removes vote cache for specified blocks from DB.

func (*BeaconDB) GenesisTime

func (db *BeaconDB) GenesisTime() (time.Time, error)

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

func (db *BeaconDB) GetCleanedFinalizedSlot() (uint64, error)

GetCleanedFinalizedSlot returns the most recent finalized slot when we did a DB clean up.

func (*BeaconDB) GetSimulatorSlot

func (db *BeaconDB) GetSimulatorSlot() (uint64, error)

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

func (db *BeaconDB) HasAttestation(hash [32]byte) bool

HasAttestation checks if the attestation exists.

func (*BeaconDB) HasBlock

func (db *BeaconDB) HasBlock(hash [32]byte) bool

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

func (db *BeaconDB) SaveCleanedFinalizedSlot(slot uint64) error

SaveCleanedFinalizedSlot writes the slot when we did DB cleanup so we can start from here in future cleanup tasks.

func (*BeaconDB) SaveSimulatorSlot

func (db *BeaconDB) SaveSimulatorSlot(slot uint64) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址