store

package
v0.6.2-dirty Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(ctx context.Context, store header.Store, ex header.Exchange, hash tmbytes.HexBytes) error

Init ensures a Store is initialized. If it is not already initialized, it initializes the Store by requesting the header with the given hash.

func NewTestStore

func NewTestStore(ctx context.Context, t *testing.T, head *header.ExtendedHeader) header.Store

NewTestStore creates initialized and started in memory header Store which is useful for testing.

Types

type Option added in v0.5.0

type Option func(*Parameters)

Option is the functional option that is applied to the store instance to configure store parameters.

func WithIndexCacheSize added in v0.5.0

func WithIndexCacheSize(size int) Option

WithIndexCacheSize is a functional option that configures the `IndexCacheSize` parameter.

func WithStoreCacheSize added in v0.5.0

func WithStoreCacheSize(size int) Option

WithStoreCacheSize is a functional option that configures the `StoreCacheSize` parameter.

func WithWriteBatchSize added in v0.5.0

func WithWriteBatchSize(size int) Option

WithWriteBatchSize is a functional option that configures the `WriteBatchSize` parameter.

type Parameters added in v0.5.0

type Parameters struct {
	// StoreCacheSize defines the maximum amount of entries in the Header Store cache.
	StoreCacheSize int

	// IndexCacheSize defines the maximum amount of entries in the Height to Hash index cache.
	IndexCacheSize int

	// WriteBatchSize defines the size of the batched header write.
	// Headers are written in batches not to thrash the underlying Datastore with writes.
	WriteBatchSize int
}

Parameters is the set of parameters that must be configured for the store.

func DefaultParameters added in v0.5.0

func DefaultParameters() *Parameters

DefaultParameters returns the default params to configure the store.

func (*Parameters) Validate added in v0.5.0

func (p *Parameters) Validate() error

type Store added in v0.5.0

type Store struct {
	Params *Parameters
	// contains filtered or unexported fields
}

store implements the Store interface for ExtendedHeaders over Datastore.

func NewStore

func NewStore(ds datastore.Batching, opts ...Option) (*Store, error)

NewStore constructs a Store over datastore. The datastore must have a head there otherwise Start will error. For first initialization of Store use NewStoreWithHead.

func NewStoreWithHead

func NewStoreWithHead(
	ctx context.Context,
	ds datastore.Batching,
	head *header.ExtendedHeader,
	opts ...Option,
) (*Store, error)

NewStoreWithHead initiates a new Store and forcefully sets a given trusted header as head.

func (*Store) Append added in v0.5.0

func (s *Store) Append(ctx context.Context, headers ...*header.ExtendedHeader) (int, error)

func (*Store) Get added in v0.5.0

func (*Store) GetByHeight added in v0.5.0

func (s *Store) GetByHeight(ctx context.Context, height uint64) (*header.ExtendedHeader, error)

func (*Store) GetRangeByHeight added in v0.5.0

func (s *Store) GetRangeByHeight(ctx context.Context, from, to uint64) ([]*header.ExtendedHeader, error)

func (*Store) GetVerifiedRange added in v0.5.0

func (s *Store) GetVerifiedRange(
	ctx context.Context,
	from *header.ExtendedHeader,
	to uint64,
) ([]*header.ExtendedHeader, error)

func (*Store) Has added in v0.5.0

func (s *Store) Has(ctx context.Context, hash tmbytes.HexBytes) (bool, error)

func (*Store) Head added in v0.5.0

func (s *Store) Head(ctx context.Context) (*header.ExtendedHeader, error)

func (*Store) Height added in v0.5.0

func (s *Store) Height() uint64

func (*Store) Init added in v0.5.0

func (s *Store) Init(ctx context.Context, initial *header.ExtendedHeader) error

func (*Store) Start added in v0.5.0

func (s *Store) Start(context.Context) error

func (*Store) Stop added in v0.5.0

func (s *Store) Stop(ctx context.Context) error

Jump to

Keyboard shortcuts

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