store

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DataPath the subdir for the data folder containing the p2p data relative to the path.
	DataPath = "data"
	// SignaturePath the subdir for the signatures folder containing all the signatures that the relayer query.
	SignaturePath = "signatures"
	// EVMKeyStorePath the subdir for the path containing the EVM keystore.
	EVMKeyStorePath = "keystore/evm"
	// P2PKeyStorePath the subdir for the path containing the p2p keystore.
	P2PKeyStorePath = "keystore/p2p"
)

Variables

View Source
var (
	// ErrOpened is thrown on attempt to open already open/in-use Store.
	ErrOpened = errors.New("store is in use")
	// ErrNotInited is thrown on attempt to open Store without initialization.
	ErrNotInited = errors.New("store is not initialized")
)

Functions

func DefaultBadgerOptions

func DefaultBadgerOptions(path string) *badger.Options

DefaultBadgerOptions creates the default options for badger. For our purposes, we don't want the store to perform any garbage collection or expire newly added keys after a certain period, because: 1. the data in the store will be light. 2. we want to keep the data, i.e. confirms, for the longest time possible to be able to retrieve them if needed.

func Exists

func Exists(path string) bool

Exists checks whether file or directory exists under the given 'path' on the system.

func Init

func Init(log tmlog.Logger, path string, options InitOptions) error

Init initializes the Blobstream file system in the directory under 'path'. It also creates a lock under that directory, so it can't be used by multiple processes.

func IsInit

func IsInit(logger tmlog.Logger, path string, options InitOptions) bool

IsInit checks whether FileSystem Store was set up under given 'path'. If the paths of the provided options don't exist, then it returns false.

Types

type InitOptions

type InitOptions struct {
	NeedDataStore      bool
	NeedSignatureStore bool
	NeedEVMKeyStore    bool
	NeedP2PKeyStore    bool
}

InitOptions contains the options used to init a path or check if a path is already initiated.

type OpenOptions

type OpenOptions struct {
	HasDataStore      bool
	BadgerOptions     *badger.Options
	HasSignatureStore bool
	HasEVMKeyStore    bool
	HasP2PKeyStore    bool
}

OpenOptions contains the options used to create the store

type Store

type Store struct {
	// DataStore provides a Datastore - a KV store for dht p2p data to be stored on disk.
	DataStore datastore.Batching

	// SignatureStore provides a signature store - a KV store for all orchestrator signatures to be stored on disk.
	SignatureStore *badger.Datastore

	// EVMKeyStore provides a keystore for EVM private keys.
	EVMKeyStore *keystore.KeyStore

	// P2PKeyStore provides a keystore for P2P private keys.
	P2PKeyStore *keystore2.FSKeystore

	// Path the path to the Blobstream storage root.
	Path string
	// contains filtered or unexported fields
}

Store contains relevant information about the Blobstream store.

func OpenStore

func OpenStore(logger tmlog.Logger, path string, options OpenOptions) (*Store, error)

OpenStore creates new FS Store under the given 'path'. To be opened, the Store must be initialized first, otherwise ErrNotInited is thrown. OpenStore takes a file Lock on directory, hence only one Store can be opened at a time under the given 'path', otherwise ErrOpened is thrown. The store is locked only in the case of also opening the data store, however, in the case of the keys, the store can still be opened.

func (Store) Close

func (s Store) Close(logger tmlog.Logger, options OpenOptions) error

Close closes an opened store and removes the lock file.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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