datastore

package
v1.7.5-beta.1 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

This section is empty.

Types

type BlobStore

type BlobStore struct {
	DB sql.Executor
	// contains filtered or unexported fields
}

BlobStore gets data as a blob to serve direct fetch requests.

func NewBlobStore

func NewBlobStore(db sql.Executor, proposals *store.Store) *BlobStore

NewBlobStore returns a BlobStore.

func (*BlobStore) GetBlobSizes added in v1.4.1

func (bs *BlobStore) GetBlobSizes(hint Hint, ids [][]byte) (sizes []int, err error)

GetBlobSizes returns the sizes of the blobs corresponding to the specified ids. For non-existent objects, the corresponding items are set to -1.

func (*BlobStore) Has added in v1.4.0

func (bs *BlobStore) Has(hint Hint, key []byte) (bool, error)

func (*BlobStore) LoadBlob added in v1.4.1

func (bs *BlobStore) LoadBlob(ctx context.Context, hint Hint, key []byte, blob *sql.Blob) error

LoadBlob gets an blob as bytes by an object ID as bytes.

type CachedDB

type CachedDB struct {
	sql.Database
	// contains filtered or unexported fields
}

CachedDB is simply a database injected with cache.

func NewCachedDB

func NewCachedDB(db sql.StateDatabase, lg *zap.Logger, opts ...Opt) *CachedDB

NewCachedDB create an instance of a CachedDB.

func (*CachedDB) CacheMalfeasanceProof

func (db *CachedDB) CacheMalfeasanceProof(id types.NodeID, proof []byte)

func (*CachedDB) GetAtx added in v1.6.0

func (db *CachedDB) GetAtx(id types.ATXID) (*types.ActivationTx, error)

GetAtx returns the ATX by the given ID. This function is thread safe and will return an error if the ID is not found in the ATX DB.

func (*CachedDB) IterateMalfeasanceProofs added in v1.1.0

func (db *CachedDB) IterateMalfeasanceProofs(
	iter func(types.NodeID, []byte) error,
) error

func (*CachedDB) MalfeasanceCacheSize

func (db *CachedDB) MalfeasanceCacheSize() int

func (*CachedDB) MalfeasanceProof added in v1.7.0

func (db *CachedDB) MalfeasanceProof(id types.NodeID) ([]byte, error)

GetMalfeasanceProof gets the malfeasance proof associated with the NodeID.

func (*CachedDB) MaxHeightAtx

func (db *CachedDB) MaxHeightAtx() (types.ATXID, error)

func (*CachedDB) Previous added in v1.7.0

func (db *CachedDB) Previous(id types.ATXID) ([]types.ATXID, error)

Previous retrieves the list of previous ATXs for the given ATX ID.

func (*CachedDB) VRFNonce

func (db *CachedDB) VRFNonce(id types.NodeID, epoch types.EpochID) (types.VRFPostIndex, error)

VRFNonce returns the VRF nonce of for the given node in the given epoch. This function is thread safe and will return an error if the nonce is not found in the ATX DB.

type Config added in v1.1.2

type Config struct {
	// ATXSize must be larger than the sum of all ATXs in last 2 epochs to be effective
	ATXSize         int `mapstructure:"atx-size"`
	MalfeasanceSize int `mapstructure:"malfeasance-size"`
}

func DefaultConfig added in v1.1.2

func DefaultConfig() Config

type Hint

type Hint string

Hint marks which DB should be queried for a certain provided hash.

const (
	NoHint      Hint = ""
	BallotDB    Hint = "ballotDB"
	BlockDB     Hint = "blocksDB"
	ProposalDB  Hint = "proposalDB"
	ATXDB       Hint = "ATXDB"
	TXDB        Hint = "TXDB"
	POETDB      Hint = "POETDB"
	Malfeasance Hint = "malfeasance"
	ActiveSet   Hint = "activeset"
)

DB hints per DB.

type Opt added in v1.1.2

type Opt func(*cacheOpts)

func WithConfig added in v1.1.2

func WithConfig(cfg Config) Opt

func WithConsensusCache added in v1.3.0

func WithConsensusCache(c *atxsdata.Data) Opt

type VrfNonceKey

type VrfNonceKey struct {
	ID    types.NodeID
	Epoch types.EpochID
}

Jump to

Keyboard shortcuts

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