storage

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MapStorage

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

MapStorage is a simple in-memory implementation of Storage.

func (*MapStorage) GetBlock

func (m *MapStorage) GetBlock(height int64) (*types.Block, error)

func (*MapStorage) GetCommit

func (m *MapStorage) GetCommit(height int64) (*types.Commit, error)

func (*MapStorage) GetResponses

func (m *MapStorage) GetResponses(height int64) (*abcitypes.ResponseFinalizeBlock, error)

func (*MapStorage) GetState

func (m *MapStorage) GetState(height int64) (*cometstate.State, error)

func (*MapStorage) LockBeforeStateUpdate

func (m *MapStorage) LockBeforeStateUpdate()

func (*MapStorage) UnlockAfterStateUpdate

func (m *MapStorage) UnlockAfterStateUpdate()

func (*MapStorage) UpdateStores

func (m *MapStorage) UpdateStores(height int64, block *types.Block, commit *types.Commit, state *cometstate.State, responses *abcitypes.ResponseFinalizeBlock) error

type Storage

type Storage interface {
	// GetBlock returns the block at a given height.
	GetBlock(height int64) (*types.Block, error)

	// GetCommit returns the commit at a given height.
	GetCommit(height int64) (*types.Commit, error)

	// GetState returns the state at a given height. This is the state after
	// applying the block at that height.
	GetState(height int64) (*cometstate.State, error)

	// GetResponses returns the ABCI responses from a given height.
	GetResponses(height int64) (*abcitypes.ResponseFinalizeBlock, error)

	// LockBeforeStateUpdate locks the storage for state update.
	LockBeforeStateUpdate()

	// UnlockAfterStateUpdate unlocks the storage for state update.
	UnlockAfterStateUpdate()

	// UpdateStores updates the storage with the given block, commit, state and responses.
	// It is assumed that the block, commit, state and responses are all from the same height.
	// If they are not, the storage will be in an inconsistent state.
	// If the storage is already updated with the given height, the storage will overwrite the existing data.
	// This method is *not* thread-safe.
	// Before calling this, the caller should call LockForStateUpdate().
	// After calling this, the caller should call UnlockForStateUpdate().
	UpdateStores(
		height int64,
		block *types.Block,
		commit *types.Commit,
		state *cometstate.State,
		responses *abcitypes.ResponseFinalizeBlock,
	) error
}

Storage is an interface for storing blocks, commits and states by height. All methods are thread-safe.

Jump to

Keyboard shortcuts

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