store

package
v4.7.4 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2024 License: BSD-2-Clause, BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckedRounds

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

func LoadCheckedRounds

func LoadCheckedRounds(maxRounds int, kv versioned.KV) (*CheckedRounds, error)

LoadCheckedRounds restores the list from storage.

func NewCheckedRounds

func NewCheckedRounds(maxRounds int, kv versioned.KV) (*CheckedRounds, error)

NewCheckedRounds returns a new CheckedRounds with an initialized map.

func (*CheckedRounds) Check

func (cr *CheckedRounds) Check(rid id.Round) bool

Check determines if the round ID has been added to the checklist. If it has not, then it is added and the function returns true. Otherwise, if it already exists, then the function returns false.

func (*CheckedRounds) IsChecked

func (cr *CheckedRounds) IsChecked(rid id.Round) bool

IsChecked determines if the round has been added to the checklist.

func (*CheckedRounds) Next

func (cr *CheckedRounds) Next() ([]byte, bool)

Next pops the oldest recent round ID from the list and returns it as bytes. Returns false if the list is empty

func (*CheckedRounds) Prune

func (cr *CheckedRounds) Prune()

Prune any rounds that are earlier than the earliestAllowed.

func (*CheckedRounds) SaveCheckedRounds

func (cr *CheckedRounds) SaveCheckedRounds() error

SaveCheckedRounds stores the list to storage.

type EarliestRound

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

func LoadEarliestRound

func LoadEarliestRound(kv versioned.KV) *EarliestRound

func NewEarliestRound

func NewEarliestRound(stored bool, kv versioned.KV) *EarliestRound

func (*EarliestRound) Get

func (ur *EarliestRound) Get() id.Round

func (*EarliestRound) Set

func (ur *EarliestRound) Set(rid id.Round) (id.Round, id.Round, bool)

Set returns the updated earliest round, the old earliest round, and if they are changed. Updates the earliest round if it is newer than stored one.

type UnknownRounds

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

UnknownRounds tracks data for unknown rounds. Should adhere to UnknownRounds interface.

func LoadUnknownRounds

func LoadUnknownRounds(kv versioned.KV,
	params UnknownRoundsParams) *UnknownRounds

LoadUnknownRounds loads the data for a UnknownRounds from disk into an object.

func NewUnknownRounds

func NewUnknownRounds(kv versioned.KV,
	params UnknownRoundsParams) *UnknownRounds

NewUnknownRounds builds and returns a new UnknownRounds object.

func (*UnknownRounds) Delete

func (urs *UnknownRounds) Delete()

func (*UnknownRounds) Get

func (urs *UnknownRounds) Get(round id.Round) (bool, uint64)

func (*UnknownRounds) Iterate

func (urs *UnknownRounds) Iterate(checker func(rid id.Round) bool,
	roundsToAdd []id.Round, abandon func(round id.Round)) []id.Round

Iterate iterates over all rounds. First it runs the checker function on the stored rounds: If true, it removes from the map and adds to the return slice. If false, it increments the counter and if it has passed the maxChecks in params, it removes from the map. Afterwards it adds the roundToAdd to the map if an entry isn't present. Finally, it saves the modified map to disk. The abandon function can be used to pass the abandoned round somewhere else.

type UnknownRoundsParams

type UnknownRoundsParams struct {
	// MaxChecks is the maximum amount of checks of a round before that round
	// gets discarded
	MaxChecks uint64

	// Stored determines if the unknown rounds is stored to disk
	Stored bool
}

UnknownRoundsParams allows configuration of UnknownRounds parameters.

func DefaultUnknownRoundsParams

func DefaultUnknownRoundsParams() UnknownRoundsParams

DefaultUnknownRoundsParams returns a default set of UnknownRoundsParams.

func GetParameters

func GetParameters(params string) (UnknownRoundsParams, error)

GetParameters returns the default UnknownRoundsParams, or override with given parameters, if set.

func (UnknownRoundsParams) MarshalJSON

func (urp UnknownRoundsParams) MarshalJSON() ([]byte, error)

MarshalJSON adheres to the json.Marshaler interface.

func (*UnknownRoundsParams) UnmarshalJSON

func (urp *UnknownRoundsParams) UnmarshalJSON(data []byte) error

UnmarshalJSON adheres to the json.Unmarshaler interface.

Jump to

Keyboard shortcuts

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