Documentation ¶
Index ¶
- type BeaconDB
- func (db *BeaconDB) Attestation(hash [32]byte) (*pb.Attestation, error)
- func (db *BeaconDB) Block(hash [32]byte) (*pb.BeaconBlock, error)
- func (db *BeaconDB) BlockBySlot(slot uint64) (*pb.BeaconBlock, error)
- func (db *BeaconDB) ChainHead() (*pb.BeaconBlock, error)
- func (db *BeaconDB) CleanedFinalizedSlot() (uint64, error)
- func (db *BeaconDB) Close() error
- func (db *BeaconDB) DeleteBlockVoteCache(blockHashes [][32]byte) error
- func (db *BeaconDB) GenesisTime() (time.Time, error)
- func (db *BeaconDB) HasAttestation(hash [32]byte) bool
- func (db *BeaconDB) HasBlock(hash [32]byte) bool
- func (db *BeaconDB) HasExit(hash [32]byte) bool
- func (db *BeaconDB) InitializeState(genesisTime uint64, deposits []*pb.Deposit) error
- func (db *BeaconDB) InsertPendingDeposit(ctx context.Context, d *pb.Deposit, blockNum *big.Int)
- func (db *BeaconDB) PendingDeposits(ctx context.Context, beforeBlk *big.Int) []*pb.Deposit
- func (db *BeaconDB) ReadBlockVoteCache(blockHashes [][32]byte) (utils.BlockVoteCache, error)
- func (db *BeaconDB) RemovePendingDeposit(ctx context.Context, d *pb.Deposit)
- 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) SaveExit(exit *pb.Exit) error
- func (db *BeaconDB) SaveState(beaconState *pb.BeaconState) error
- func (db *BeaconDB) SaveUnfinalizedBlockState(beaconState *pb.BeaconState) error
- func (db *BeaconDB) State() (*pb.BeaconState, error)
- func (db *BeaconDB) UnfinalizedBlockState(stateRoot [32]byte) (*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) Attestation ¶
func (db *BeaconDB) Attestation(hash [32]byte) (*pb.Attestation, error)
Attestation retrieves an attestation record from the db using its hash.
func (*BeaconDB) Block ¶
func (db *BeaconDB) Block(hash [32]byte) (*pb.BeaconBlock, error)
Block accepts a block hash and returns the corresponding block. Returns nil if the block does not exist.
func (*BeaconDB) BlockBySlot ¶
func (db *BeaconDB) BlockBySlot(slot uint64) (*pb.BeaconBlock, error)
BlockBySlot 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) ChainHead ¶
func (db *BeaconDB) ChainHead() (*pb.BeaconBlock, error)
ChainHead returns the head of the main chain.
func (*BeaconDB) CleanedFinalizedSlot ¶
CleanedFinalizedSlot returns the most recent finalized slot when we did a DB clean up.
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) 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 ¶
InitializeState creates an initial genesis state for the beacon node using a set of genesis validators.
func (*BeaconDB) InsertPendingDeposit ¶
InsertPendingDeposit into the database. If deposit or block number are nil then this method does nothing.
func (*BeaconDB) PendingDeposits ¶
PendingDeposits returns a list of deposits until the given block number (inclusive). If no block is specified then this method returns all pending deposits.
func (*BeaconDB) ReadBlockVoteCache ¶
func (db *BeaconDB) ReadBlockVoteCache(blockHashes [][32]byte) (utils.BlockVoteCache, error)
ReadBlockVoteCache read block vote cache from DB.
func (*BeaconDB) RemovePendingDeposit ¶
RemovePendingDeposit from the database. The deposit is indexed by the MerkleTreeIndex. This method does nothing if deposit ptr is nil.
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) 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) State ¶
func (db *BeaconDB) State() (*pb.BeaconState, error)
State fetches the canonical beacon chain's state from the DB.
func (*BeaconDB) UnfinalizedBlockState ¶
func (db *BeaconDB) UnfinalizedBlockState(stateRoot [32]byte) (*pb.BeaconState, error)
UnfinalizedBlockState fetches an unfinalized block's active and crystallized state pair.
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.