simplestack

package
v0.0.0-...-a40744b Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SimpleStack

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

SimpleStack is a simple in-memory stack used in tests.

func New

func New(retentionLimit int, miniHeaders []*types.MiniHeader) *SimpleStack

New instantiates a new SimpleStack.

func (*SimpleStack) Checkpoint

func (s *SimpleStack) Checkpoint() int

Checkpoint checkpoints the changes to the stack such that a subsequent call to `Reset(checkpointID)` with the checkpointID returned from this call will reset any subsequent changes back to the state of the stack at the time of this checkpoint.

func (*SimpleStack) Clear

func (s *SimpleStack) Clear()

Clear removes all items from the stack and clears any set checkpoint.

func (*SimpleStack) GetUpdates

func (s *SimpleStack) GetUpdates() []*Update

GetUpdates returns the updates applied since the last checkpoint.

func (*SimpleStack) Peek

func (s *SimpleStack) Peek() *types.MiniHeader

Peek returns the top of the stack.

func (*SimpleStack) PeekAll

func (s *SimpleStack) PeekAll() []*types.MiniHeader

PeekAll returns all the miniHeaders currently in the stack.

func (*SimpleStack) Pop

func (s *SimpleStack) Pop() *types.MiniHeader

Pop returns the top of the stack and removes it from the stack.

func (*SimpleStack) Push

func (s *SimpleStack) Push(miniHeader *types.MiniHeader) error

Push adds a types.MiniHeader to the stack.

func (*SimpleStack) Reset

func (s *SimpleStack) Reset(checkpointID int) error

Reset resets the in-memory stack with the contents from the latest checkpoint.

type Update

type Update struct {
	Type       UpdateType
	MiniHeader *types.MiniHeader
}

Update represents one update to the stack, either a pop or push of a miniHeader.

type UpdateType

type UpdateType int

UpdateType is the type of update applied to the in-memory stack.

const (
	Pop UpdateType = iota
	Push
)

Jump to

Keyboard shortcuts

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