states

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	// Store a state.
	// Returns exists=true if the state exists (previously), false otherwise. If error, it may not be accurate.
	Store(ctx context.Context, state *beacon.BeaconStateView) (exists bool, err error)
	// Get a state. The state is a view of a shared immutable backing.
	// The view is save to mutate (it forks away from the original backing)
	Get(root beacon.Root) (state *beacon.BeaconStateView, exists bool, err error)
	// Remove removes a state from the DB. Removing a state that does not exist is safe.
	// Returns exists=true if the state exists (previously), false otherwise. If error, it may not be accurate.
	Remove(root beacon.Root) (exists bool, err error)
	// Stats shows some database statistics such as latest write key and entry count.
	Stats() DBStats
	// List all known state roots
	List() []beacon.Root
	// Get Path
	Path() string
	// Spec of states
	Spec() *beacon.Spec
}

type DBID added in v0.2.1

type DBID string

type DBMap added in v0.2.1

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

func (*DBMap) Create added in v0.2.1

func (dbm *DBMap) Create(id DBID, path string, spec *beacon.Spec) (db DB, err error)

func (*DBMap) Find added in v0.2.1

func (dbm *DBMap) Find(id DBID) (db DB, ok bool)

func (*DBMap) List added in v0.2.1

func (dbm *DBMap) List() (out []DBID)

func (*DBMap) Remove added in v0.2.1

func (dbm *DBMap) Remove(id DBID) (existed bool)

type DBStats

type DBStats struct {
	Count     int64
	LastWrite beacon.Root
}

type DBs added in v0.2.1

type DBs interface {
	Find(id DBID) (db DB, ok bool)
	// Create a new database. An empty path creates a memory DB.
	Create(id DBID, path string, spec *beacon.Spec) (db DB, err error)
	Remove(id DBID) (existed bool)
	List() []DBID
}

type MemDB

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

func (*MemDB) Get

func (db *MemDB) Get(root beacon.Root) (state *beacon.BeaconStateView, exists bool, err error)

func (*MemDB) List

func (db *MemDB) List() (out []beacon.Root)

func (*MemDB) Path added in v0.2.1

func (db *MemDB) Path() string

func (*MemDB) Remove

func (db *MemDB) Remove(root beacon.Root) (exists bool, err error)

func (*MemDB) Spec added in v0.3.0

func (db *MemDB) Spec() *beacon.Spec

func (*MemDB) Stats

func (db *MemDB) Stats() DBStats

func (*MemDB) Store

func (db *MemDB) Store(ctx context.Context, state *beacon.BeaconStateView) (exists bool, err error)

Jump to

Keyboard shortcuts

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