eviction

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: Apache-2.0, BSD-2-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewEvents = event.CreateGroupConstructor(func() (self *Events) {
	return &Events{
		SlotEvicted: event.New1[slot.Index](),
	}
})

NewEvents contains the constructor of the Events object (it is generated by a generic factory).

Functions

func WithRootBlocksEvictionDelay

func WithRootBlocksEvictionDelay(delay slot.Index) options.Option[State]

WithRootBlocksEvictionDelay sets the time since confirmation threshold.

Types

type Events

type Events struct {
	SlotEvicted *event.Event1[slot.Index]

	event.Group[Events, *Events]
}

type State

type State struct {
	Events *Events
	// contains filtered or unexported fields
}

State represents the state of the eviction and keeps track of the root blocks.

func NewState

func NewState(storageInstance *storage.Storage, opts ...options.Option[State]) (state *State)

NewState creates a new eviction State.

func (*State) AddRootBlock

func (s *State) AddRootBlock(id models.BlockID, commitmentID commitment.ID)

AddRootBlock inserts a solid entry point to the seps map.

func (*State) EarliestRootCommitmentID

func (s *State) EarliestRootCommitmentID() (earliestCommitment commitment.ID)

EarliestRootCommitmentID returns the earliest commitment that rootblocks are committing to across all rootblocks.

func (*State) EvictUntil

func (s *State) EvictUntil(index slot.Index)

EvictUntil triggers the SlotEvicted event for every evicted slot and evicts all root blocks until the delayed root blocks eviction threshold.

func (*State) Export

func (s *State) Export(writer io.WriteSeeker, evictedSlot slot.Index) (err error)

Export exports the root blocks to the given writer.

func (*State) Import

func (s *State) Import(reader io.ReadSeeker) (err error)

Import imports the root blocks from the given reader.

func (*State) InEvictedSlot

func (s *State) InEvictedSlot(id models.BlockID) bool

InEvictedSlot checks if the Block associated with the given id is too old (in a pruned slot).

func (*State) IsRootBlock

func (s *State) IsRootBlock(id models.BlockID) (has bool)

IsRootBlock returns true if the given block is a root block.

func (*State) LastEvictedSlot

func (s *State) LastEvictedSlot() slot.Index

LastEvictedSlot returns the last evicted slot.

func (*State) LatestRootBlocks

func (s *State) LatestRootBlocks() models.BlockIDs

LatestRootBlocks returns the latest root blocks.

func (*State) PopulateFromStorage

func (s *State) PopulateFromStorage(latestCommitmentIndex slot.Index)

PopulateFromStorage populates the root blocks from the storage.

func (*State) RemoveRootBlock

func (s *State) RemoveRootBlock(id models.BlockID)

RemoveRootBlock removes a solid entry points from the map.

Jump to

Keyboard shortcuts

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