datastore

package
v0.2.18-beta.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AtxCache

type AtxCache struct {
	*lru.Cache
}

AtxCache holds an lru cache of ActivationTxHeader structs of recent atx used to calculate active set size ideally this cache will hold the atxs created in latest epoch, on which most of active set size calculation will be performed.

func NewAtxCache

func NewAtxCache(size int) AtxCache

NewAtxCache creates a new cache for activation transaction headers.

func (*AtxCache) Add

func (bc *AtxCache) Add(id types.ATXID, atxHeader *types.ActivationTxHeader)

Add adds an ActivationTxHeader to cache.

func (AtxCache) Get

Get gets the corresponding ActivationTxHeader for the given id, it also returns a boolean to indicate whether the item was found in cache.

type BlobStore

type BlobStore struct {
	DB *sql.Database
}

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

func NewBlobStore

func NewBlobStore(db *sql.Database) *BlobStore

NewBlobStore returns a BlobStore.

func (*BlobStore) Get

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

Get gets an ATX as bytes by an ATX 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.Database, lg log.Log) *CachedDB

NewCachedDB create an instance of a CachedDB.

func (*CachedDB) GetAtxHeader

func (db *CachedDB) GetAtxHeader(id types.ATXID) (*types.ActivationTxHeader, error)

GetAtxHeader returns the ATX header 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) GetEpochWeight

func (db *CachedDB) GetEpochWeight(epoch types.EpochID) (uint64, []types.ATXID, error)

GetEpochWeight returns the total weight of ATXs targeting the given epochID.

func (*CachedDB) GetFullAtx

func (db *CachedDB) GetFullAtx(id types.ATXID) (*types.VerifiedActivationTx, error)

GetFullAtx returns the full atx struct of the given atxId id, it returns an error if the full atx cannot be found in all databases.

func (*CachedDB) GetPrevAtx

func (db *CachedDB) GetPrevAtx(nodeID types.NodeID) (*types.ActivationTxHeader, error)

GetPrevAtx gets the last atx header of specified node Id, it returns error if no previous atx found or if no AtxHeader struct in db.

func (*CachedDB) IterateEpochATXHeaders

func (db *CachedDB) IterateEpochATXHeaders(epoch types.EpochID, iter func(*types.ActivationTxHeader) bool) error

IterateEpochATXHeaders iterates over ActivationTxs that target an epoch.

type Getter

type Getter interface {
	Get(Hint, []byte) ([]byte, error)
}

Getter wraps the database read operation.

type Hint

type Hint string

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

const (
	BallotDB   Hint = "ballotDB"
	BlockDB    Hint = "blocksDB"
	ProposalDB Hint = "proposalDB"
	ATXDB      Hint = "ATXDB"
	TXDB       Hint = "TXDB"
	POETDB     Hint = "POETDB"
)

DB hints per DB.

Jump to

Keyboard shortcuts

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