storage

package
v0.0.0-...-5a6e01e Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package storage provides databases for storage.

Index

Constants

This section is empty.

Variables

View Source
var (
	TimeoutError    = util.NewError("timeout")
	StorageError    = util.NewError("storage error")
	FSError         = util.NewError("fs error")
	ConnectionError = util.NewError("storage connection error")
)

Functions

func CheckBlock

func CheckBlock(st Database, networkID base.NetworkID) (block.Manifest, error)

func CheckBlockEmpty

func CheckBlockEmpty(st Database) (block.Manifest, error)

CheckBlockEmpty checks whether local has block data. If empty, return nil block.Manifest.

func MergeFSError

func MergeFSError(err error) error

func MergeStorageError

func MergeStorageError(err error) error

Types

type Database

type Database interface {
	util.Initializer
	Encoder() encoder.Encoder
	Encoders() *encoder.Encoders
	Close() error
	Clean() error
	CleanByHeight(base.Height) error
	Copy(Database) error

	NewSession(block.Block) (DatabaseSession, error)
	NewSyncerSession() (SyncerSession, error)

	LastManifest() (block.Manifest, bool, error)
	Manifest(valuehash.Hash) (block.Manifest, bool, error)
	ManifestByHeight(base.Height) (block.Manifest, bool, error)
	Manifests(bool, bool, int64, func(base.Height, valuehash.Hash, block.Manifest) (bool, error)) error

	NewOperationSeals([]operation.Seal) error
	NewOperations([]operation.Operation) error

	NewProposal(base.Proposal) error
	Proposal(valuehash.Hash) (base.Proposal, bool, error)
	ProposalByPoint(base.Height, base.Round, base.Address) (base.Proposal, bool, error)
	Proposals(func(base.Proposal) (bool, error), bool) error

	State(key string) (state.State, bool, error)
	LastVoteproof(base.Stage) base.Voteproof
	Voteproof(base.Height, base.Stage) (base.Voteproof, error)

	HasOperationFact(valuehash.Hash) (bool, error)

	// NOTE StagedOperationOperations returns operation.Operation by incoming order.
	StagedOperationsByFact(facts []valuehash.Hash) ([]operation.Operation, error)
	HasStagedOperation(valuehash.Hash) (bool, error)
	StagedOperations(func(operation.Operation) (bool, error), bool) error
	UnstagedOperations([]valuehash.Hash) error

	SetInfo(string, []byte) error
	Info(string) ([]byte, bool, error)

	BlockdataMap(base.Height) (block.BlockdataMap, bool, error)
	SetBlockdataMaps([]block.BlockdataMap) error
	LocalBlockdataMapsByHeight(base.Height, func(block.BlockdataMap) (bool, error)) error
}

type DatabaseSession

type DatabaseSession interface {
	Block() block.Block
	SetBlock(context.Context, block.Block) error
	SetACCEPTVoteproof(base.Voteproof) error
	Commit(context.Context, block.BlockdataMap) error
	Close() error
	Cancel() error
}

type LastBlockSaver

type LastBlockSaver interface {
	SaveLastBlock(base.Height) error
}

type StateUpdater

type StateUpdater interface {
	NewState(state.State) error
}

type Statepool

type Statepool struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewStatepool

func NewStatepool(st Database) (*Statepool, error)

func NewStatepoolWithBase

func NewStatepoolWithBase(st Database, b map[string]state.State) (*Statepool, error)

NewStatepoolWithBase only used for testing

func (*Statepool) AddOperations

func (sp *Statepool) AddOperations(ops ...operation.Operation)

func (*Statepool) AddedOperations

func (sp *Statepool) AddedOperations() map[string]operation.Operation

func (*Statepool) Done

func (sp *Statepool) Done()

Done cleans up the resources.

func (*Statepool) Get

func (sp *Statepool) Get(key string) (state.State, bool, error)

func (*Statepool) Height

func (sp *Statepool) Height() base.Height

func (*Statepool) InsertedOperations

func (sp *Statepool) InsertedOperations() map[string]valuehash.Hash

func (*Statepool) IsUpdated

func (sp *Statepool) IsUpdated() bool

func (*Statepool) Set

func (sp *Statepool) Set(fact valuehash.Hash, s ...state.State) error

func (*Statepool) Updates

func (sp *Statepool) Updates() []*state.StateUpdater

type SyncerSession

type SyncerSession interface {
	Manifest(base.Height) (block.Manifest, bool, error)
	SetManifests([]block.Manifest) error
	HasBlock(base.Height) (bool, error)
	SetBlocks([]block.Block, []block.BlockdataMap) error
	Commit() error
	Close() error
	SetSkipLastBlock(bool)
}

Directories

Path Synopsis
Package blockdata provides entire block data.
Package blockdata provides entire block data.
localfs
Package localfs provides block data from local filesystem.
Package localfs provides block data from local filesystem.
Package leveldb provides storages of leveldb.
Package leveldb provides storages of leveldb.
Package mongodb provides storages of mongodb.
Package mongodb provides storages of mongodb.

Jump to

Keyboard shortcuts

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