db

package
v0.0.0-...-c85edb6 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2019 License: GPL-3.0 Imports: 21 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) 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

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

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

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) 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) HasExit

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

HasExit checks if the exit request exists.

func (*BeaconDB) InitializeState

func (db *BeaconDB) InitializeState(genesisTime uint64, deposits []*pb.Deposit) error

InitializeState creates an initial genesis state for the beacon node using a set of genesis validators.

func (*BeaconDB) InsertPendingDeposit

func (db *BeaconDB) InsertPendingDeposit(ctx context.Context, d *pb.Deposit, blockNum *big.Int)

InsertPendingDeposit into the database. If deposit or block number are nil then this method does nothing.

func (*BeaconDB) PendingDeposits

func (db *BeaconDB) PendingDeposits(ctx context.Context, beforeBlk *big.Int) []*pb.Deposit

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

func (db *BeaconDB) RemovePendingDeposit(ctx context.Context, d *pb.Deposit)

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

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) SaveExit

func (db *BeaconDB) SaveExit(exit *pb.Exit) error

SaveExit puts the exit request into the beacon chain db.

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.

Jump to

Keyboard shortcuts

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