db

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2019 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TeardownSlasherDB

func TeardownSlasherDB(t testing.TB, db *Store)

TeardownSlasherDB cleans up a test BeaconDB instance.

func TempDir

func TempDir() string

TempDir returns a directory path for temporary test storage.

Types

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store defines an implementation of the Prysm Database interface using BoltDB as the underlying persistent kv-store for eth2.

func NewDB

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

NewDB initializes a new DB.

func NewKVStore

func NewKVStore(dirPath string) (*Store, error)

NewKVStore initializes a new boltDB key-value store at the directory path specified, creates the kv-buckets based on the schema, and stores an open connection db object as a property of the Store struct.

func SetupSlasherDB

func SetupSlasherDB(t testing.TB) *Store

SetupSlasherDB instantiates and returns a SlasherDB instance.

func (*Store) BlockHeader

func (db *Store) BlockHeader(epoch uint64, validatorID uint64) ([]*ethpb.BeaconBlockHeader, error)

BlockHeader accepts an epoch and validator id and returns the corresponding block header array. Returns nil if the block header for those values does not exist.

func (*Store) ClearDB

func (db *Store) ClearDB() error

ClearDB removes the previously stored directory at the data directory.

func (*Store) Close

func (db *Store) Close() error

Close closes the underlying boltdb database.

func (*Store) DatabasePath

func (db *Store) DatabasePath() string

DatabasePath at which this database writes files.

func (*Store) DeleteBlockHeader

func (db *Store) DeleteBlockHeader(epoch uint64, validatorID uint64, blockHeader *ethpb.BeaconBlockHeader) error

DeleteBlockHeader deletes a block header using the epoch and validator id.

func (*Store) DeleteIndexedAttestation

func (db *Store) DeleteIndexedAttestation(idxAttestation *ethpb.IndexedAttestation) error

DeleteIndexedAttestation deletes a indexed attestation using the slot and its root as keys in their respective buckets.

func (*Store) DeletePubKey added in v0.2.3

func (db *Store) DeletePubKey(validatorID uint64) error

DeletePubKey deletes a public key of a validator id.

func (*Store) DeleteValidatorSpanMap added in v0.2.3

func (db *Store) DeleteValidatorSpanMap(validatorIdx uint64) error

DeleteValidatorSpanMap deletes a validator span map using a validator index as bucket key.

func (*Store) HasBlockHeader

func (db *Store) HasBlockHeader(epoch uint64, validatorID uint64) bool

HasBlockHeader accepts an epoch and validator id and returns true if the block header exists.

func (*Store) HasIndexedAttestation

func (db *Store) HasIndexedAttestation(sourceEpoch uint64, targetEpoch uint64, validatorID uint64) bool

HasIndexedAttestation accepts an epoch and validator id and returns true if the indexed attestation exists.

func (*Store) IndexedAttestation

func (db *Store) IndexedAttestation(sourceEpoch uint64, targetEpoch uint64, validatorID uint64) ([]*ethpb.IndexedAttestation, error)

IndexedAttestation accepts a epoch and validator index and returns a list of indexed attestations. Returns nil if the indexed attestation does not exist.

func (*Store) PruneHistory

func (db *Store) PruneHistory(currentEpoch uint64, historySize uint64) error

PruneHistory leaves only records younger then history size.

func (*Store) SaveBlockHeader

func (db *Store) SaveBlockHeader(epoch uint64, validatorID uint64, blockHeader *ethpb.BeaconBlockHeader) error

SaveBlockHeader accepts a block header and writes it to disk.

func (*Store) SaveIndexedAttestation

func (db *Store) SaveIndexedAttestation(idxAttestation *ethpb.IndexedAttestation) error

SaveIndexedAttestation accepts epoch and indexed attestation and writes it to disk.

func (*Store) SavePubKey added in v0.2.3

func (db *Store) SavePubKey(validatorID uint64, pubKey []byte) error

SavePubKey accepts a validator id and its public key and writes it to disk.

func (*Store) SaveValidatorSpansMap added in v0.2.3

func (db *Store) SaveValidatorSpansMap(validatorIdx uint64, spanMap *ethpb.EpochSpanMap) error

SaveValidatorSpansMap accepts a validator index and span map and writes it to disk.

func (*Store) ValidatorPubKey added in v0.2.3

func (db *Store) ValidatorPubKey(validatorID uint64) ([]byte, error)

ValidatorPubKey accepts validator id and returns the corresponding pubkey. Returns nil if the pubkey for this validator id does not exist.

func (*Store) ValidatorSpansMap added in v0.2.3

func (db *Store) ValidatorSpansMap(validatorIdx uint64) (*ethpb.EpochSpanMap, error)

ValidatorSpansMap accepts validator index and returns the corresponding spans map for slashing detection. Returns nil if the span map for this validator index does not exist.

Jump to

Keyboard shortcuts

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