cache

package
v0.2.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotCommittee will be returned when a cache object is not a pointer to
	// a Committee struct.
	ErrNotCommittee = errors.New("object is not a committee struct")

	// CommitteeCacheMiss tracks the number of committee requests that aren't present in the cache.
	CommitteeCacheMiss = promauto.NewCounter(prometheus.CounterOpts{
		Name: "committee_cache_miss",
		Help: "The number of committee requests that aren't present in the cache.",
	})
	// CommitteeCacheHit tracks the number of committee requests that are in the cache.
	CommitteeCacheHit = promauto.NewCounter(prometheus.CounterOpts{
		Name: "committee_cache_hit",
		Help: "The number of committee requests that are present in the cache.",
	})
)
View Source
var ErrAlreadyInProgress = errors.New("already in progress")

ErrAlreadyInProgress appears when attempting to mark a cache as in progress while it is already in progress. The client should handle this error and wait for the in progress data to resolve via Get.

View Source
var (
	// ErrNotActiveCountInfo will be returned when a cache object is not a pointer to
	// a ActiveCountByEpoch struct.
	ErrNotActiveCountInfo = errors.New("object is not a active count obj")
)
View Source
var (
	// ErrNotActiveIndicesInfo will be returned when a cache object is not a pointer to
	// a ActiveIndicesByEpoch struct.
	ErrNotActiveIndicesInfo = errors.New("object is not a active indices list")
)
View Source
var (
	// ErrNotCheckpointState will be returned when a cache object is not a pointer to
	// a CheckpointState struct.
	ErrNotCheckpointState = errors.New("object is not a state by check point struct")
)
View Source
var (
	// ErrNotEth1DataVote will be returned when a cache object is not a pointer to
	// a Eth1DataVote struct.
	ErrNotEth1DataVote = errors.New("object is not a eth1 data vote obj")
)

Functions

This section is empty.

Types

type ActiveCountByEpoch

type ActiveCountByEpoch struct {
	Epoch       uint64
	ActiveCount uint64
}

ActiveCountByEpoch defines the active validator count per epoch.

type ActiveCountCache

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

ActiveCountCache is a struct with 1 queue for looking up active count by epoch.

func NewActiveCountCache

func NewActiveCountCache() *ActiveCountCache

NewActiveCountCache creates a new active count cache for storing/accessing active validator count.

func (*ActiveCountCache) ActiveCountInEpoch

func (c *ActiveCountCache) ActiveCountInEpoch(epoch uint64) (uint64, error)

ActiveCountInEpoch fetches ActiveCountByEpoch by epoch. Returns true with a reference to the ActiveCountInEpoch info, if exists. Otherwise returns false, nil.

func (*ActiveCountCache) AddActiveCount

func (c *ActiveCountCache) AddActiveCount(activeCount *ActiveCountByEpoch) error

AddActiveCount adds ActiveCountByEpoch object to the cache. This method also trims the least recently added ActiveCountByEpoch object if the cache size has ready the max cache size limit.

type ActiveIndicesByEpoch

type ActiveIndicesByEpoch struct {
	Epoch         uint64
	ActiveIndices []uint64
}

ActiveIndicesByEpoch defines the active validator indices per epoch.

type ActiveIndicesCache

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

ActiveIndicesCache is a struct with 1 queue for looking up active indices by epoch.

func NewActiveIndicesCache

func NewActiveIndicesCache() *ActiveIndicesCache

NewActiveIndicesCache creates a new active indices cache for storing/accessing active validator indices.

func (*ActiveIndicesCache) ActiveIndicesInEpoch

func (c *ActiveIndicesCache) ActiveIndicesInEpoch(epoch uint64) ([]uint64, error)

ActiveIndicesInEpoch fetches ActiveIndicesByEpoch by epoch. Returns true with a reference to the ActiveIndicesInEpoch info, if exists. Otherwise returns false, nil.

func (*ActiveIndicesCache) ActiveIndicesKeys

func (c *ActiveIndicesCache) ActiveIndicesKeys() []string

ActiveIndicesKeys returns the keys of the active indices cache.

func (*ActiveIndicesCache) AddActiveIndicesList

func (c *ActiveIndicesCache) AddActiveIndicesList(activeIndices *ActiveIndicesByEpoch) error

AddActiveIndicesList adds ActiveIndicesByEpoch object to the cache. This method also trims the least recently added ActiveIndicesByEpoch object if the cache size has ready the max cache size limit.

type AttestationCache

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

AttestationCache is used to store the cached results of an AttestationData request.

func NewAttestationCache

func NewAttestationCache() *AttestationCache

NewAttestationCache initializes the map and underlying cache.

func (*AttestationCache) Get

Get waits for any in progress calculation to complete before returning a cached response, if any.

func (*AttestationCache) MarkInProgress

func (c *AttestationCache) MarkInProgress(req *pb.AttestationRequest) error

MarkInProgress a request so that any other similar requests will block on Get until MarkNotInProgress is called.

func (*AttestationCache) MarkNotInProgress

func (c *AttestationCache) MarkNotInProgress(req *pb.AttestationRequest) error

MarkNotInProgress will release the lock on a given request. This should be called after put.

func (*AttestationCache) Put

Put the response in the cache.

type CheckpointState

type CheckpointState struct {
	Checkpoint *ethpb.Checkpoint
	State      *pb.BeaconState
}

CheckpointState defines the active validator indices per epoch.

type CheckpointStateCache

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

CheckpointStateCache is a struct with 1 queue for looking up state by checkpoint.

func NewCheckpointStateCache

func NewCheckpointStateCache() *CheckpointStateCache

NewCheckpointStateCache creates a new checkpoint state cache for storing/accessing processed state.

func (*CheckpointStateCache) AddCheckpointState

func (c *CheckpointStateCache) AddCheckpointState(cp *CheckpointState) error

AddCheckpointState adds CheckpointState object to the cache. This method also trims the least recently added CheckpointState object if the cache size has ready the max cache size limit.

func (*CheckpointStateCache) CheckpointStateKeys

func (c *CheckpointStateCache) CheckpointStateKeys() []string

CheckpointStateKeys returns the keys of the state in cache.

func (*CheckpointStateCache) StateByCheckpoint

func (c *CheckpointStateCache) StateByCheckpoint(cp *ethpb.Checkpoint) (*pb.BeaconState, error)

StateByCheckpoint fetches state by checkpoint. Returns true with a reference to the CheckpointState info, if exists. Otherwise returns false, nil.

type Committee

type Committee struct {
	CommitteeCount uint64
	Epoch          uint64
	Committee      []uint64
}

Committee defines the committee per epoch and index.

type CommitteeCache

type CommitteeCache struct {
	CommitteeCache *cache.FIFO
	// contains filtered or unexported fields
}

CommitteeCache is a struct with 1 queue for looking up shuffled indices list by epoch and committee index.

func NewCommitteeCache

func NewCommitteeCache() *CommitteeCache

NewCommitteeCache creates a new committee cache for storing/accessing shuffled indices of a committee.

func (*CommitteeCache) ActiveIndices

func (c *CommitteeCache) ActiveIndices(epoch uint64) ([]uint64, error)

ActiveIndices returns the active indices of a given epoch stored in cache.

func (*CommitteeCache) AddCommitteeShuffledList

func (c *CommitteeCache) AddCommitteeShuffledList(committee *Committee) error

AddCommitteeShuffledList adds Committee shuffled list object to the cache. T his method also trims the least recently list if the cache size has ready the max cache size limit.

func (*CommitteeCache) CommitteeCountPerSlot added in v0.2.3

func (c *CommitteeCache) CommitteeCountPerSlot(slot uint64) (uint64, bool, error)

CommitteeCountPerSlot returns the number of committees in a given slot as stored in cache.

func (*CommitteeCache) EpochInCache

func (c *CommitteeCache) EpochInCache(wantedEpoch uint64) (bool, error)

EpochInCache returns true if an input epoch is part of keys in cache.

func (*CommitteeCache) Epochs

func (c *CommitteeCache) Epochs() ([]uint64, error)

Epochs returns the epochs stored in the committee cache. These are the keys to the cache.

func (*CommitteeCache) ShuffledIndices

func (c *CommitteeCache) ShuffledIndices(slot uint64, index uint64) ([]uint64, error)

ShuffledIndices fetches the shuffled indices by slot and committee index. Every list of indices represent one committee. Returns true if the list exists with slot and committee index. Otherwise returns false, nil.

type Eth1DataVote

type Eth1DataVote struct {
	Eth1DataHash [32]byte
	VoteCount    uint64
}

Eth1DataVote defines the struct which keeps track of the vote count of individual deposit root.

type Eth1DataVoteCache

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

Eth1DataVoteCache is a struct with 1 queue for looking up eth1 data vote count by deposit root.

func NewEth1DataVoteCache

func NewEth1DataVoteCache() *Eth1DataVoteCache

NewEth1DataVoteCache creates a new eth1 data vote count cache for storing/accessing Eth1DataVote.

func (*Eth1DataVoteCache) AddEth1DataVote

func (c *Eth1DataVoteCache) AddEth1DataVote(eth1DataVote *Eth1DataVote) error

AddEth1DataVote adds eth1 data vote object to the cache. This method also trims the least recently added Eth1DataVoteByEpoch object if the cache size has ready the max cache size limit.

func (*Eth1DataVoteCache) Eth1DataVote

func (c *Eth1DataVoteCache) Eth1DataVote(eth1DataHash [32]byte) (uint64, error)

Eth1DataVote fetches eth1 data vote count by the eth1data hash. Returns vote count, if exists. Otherwise returns false, nil.

func (*Eth1DataVoteCache) IncrementEth1DataVote

func (c *Eth1DataVoteCache) IncrementEth1DataVote(eth1DataHash [32]byte) (uint64, error)

IncrementEth1DataVote increments the existing eth1 data object's vote count by 1, and returns the vote count.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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