store

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound  = errors.New("not found")
	ErrBadOffset = errors.New("offset is out of range")
)

Functions

This section is empty.

Types

type CommittedBlock added in v0.15.0

type CommittedBlock struct {
	BlockHash hash.Hash
	Height    uint32
	Data      []byte
	// contains filtered or unexported fields
}

func (*CommittedBlock) ToBlock added in v0.15.0

func (s *CommittedBlock) ToBlock() (*block.Block, error)

type CommittedTx added in v0.15.0

type CommittedTx struct {
	TxID      tx.ID
	Height    uint32
	BlockTime uint32
	Data      []byte
	// contains filtered or unexported fields
}

func (*CommittedTx) ToTx added in v0.15.0

func (s *CommittedTx) ToTx() (*tx.Tx, error)

type Config

type Config struct {
	Path string `toml:"path"`

	// Private configs
	TxCacheSize        uint32 `toml:"-"`
	SortitionCacheSize uint32 `toml:"-"`
	AccountCacheSize   int    `toml:"-"`
	PublicKeyCacheSize int    `toml:"-"`
}

func DefaultConfig

func DefaultConfig() *Config

func (*Config) BasicCheck added in v0.15.0

func (conf *Config) BasicCheck() error

BasicCheck performs basic checks on the configuration.

func (*Config) DataPath

func (conf *Config) DataPath() string

func (*Config) StorePath

func (conf *Config) StorePath() string

type ConfigError added in v1.1.0

type ConfigError struct {
	Reason string
}

ConfigError is returned when the store configuration is invalid.

func (ConfigError) Error added in v1.1.0

func (e ConfigError) Error() string

type MockStore

type MockStore struct {
	Blocks     map[uint32]*block.Block
	Accounts   map[crypto.Address]*account.Account
	Validators map[crypto.Address]*validator.Validator
	LastCert   *certificate.Certificate
	LastHeight uint32
	// contains filtered or unexported fields
}

func MockingStore

func MockingStore(ts *testsuite.TestSuite) *MockStore

func (*MockStore) Account

func (m *MockStore) Account(addr crypto.Address) (*account.Account, error)

func (*MockStore) AccountByNumber added in v0.12.0

func (m *MockStore) AccountByNumber(number int32) (*account.Account, error)

func (*MockStore) AddTestAccount

func (m *MockStore) AddTestAccount() (*account.Account, crypto.Address)

func (*MockStore) AddTestBlock

func (m *MockStore) AddTestBlock(height uint32) *block.Block

func (*MockStore) AddTestValidator

func (m *MockStore) AddTestValidator() *validator.Validator

func (*MockStore) AnyRecentTransaction added in v0.15.0

func (m *MockStore) AnyRecentTransaction(id tx.ID) bool

func (*MockStore) Block

func (m *MockStore) Block(height uint32) (*CommittedBlock, error)

func (*MockStore) BlockHash

func (m *MockStore) BlockHash(height uint32) hash.Hash

func (*MockStore) BlockHeight

func (m *MockStore) BlockHeight(h hash.Hash) uint32

func (*MockStore) Close

func (m *MockStore) Close() error

func (*MockStore) HasAccount

func (m *MockStore) HasAccount(addr crypto.Address) bool

func (*MockStore) HasAnyBlock

func (m *MockStore) HasAnyBlock() bool

func (*MockStore) HasValidator

func (m *MockStore) HasValidator(addr crypto.Address) bool

func (*MockStore) IterateAccounts

func (m *MockStore) IterateAccounts(consumer func(crypto.Address, *account.Account) (stop bool))

func (*MockStore) IterateValidators

func (m *MockStore) IterateValidators(consumer func(*validator.Validator) (stop bool))

func (*MockStore) LastCertificate

func (m *MockStore) LastCertificate() *certificate.Certificate

func (*MockStore) PublicKey added in v0.15.0

func (m *MockStore) PublicKey(addr crypto.Address) (*bls.PublicKey, error)

func (*MockStore) RandomTestAcc

func (m *MockStore) RandomTestAcc() (crypto.Address, *account.Account)

func (*MockStore) RandomTestVal

func (m *MockStore) RandomTestVal() *validator.Validator

func (*MockStore) SaveBlock

func (m *MockStore) SaveBlock(b *block.Block, cert *certificate.Certificate)

func (*MockStore) SortitionSeed added in v0.19.0

func (m *MockStore) SortitionSeed(blockHeight uint32) *sortition.VerifiableSeed

func (*MockStore) TotalAccounts

func (m *MockStore) TotalAccounts() int32

func (*MockStore) TotalValidators

func (m *MockStore) TotalValidators() int32

func (*MockStore) Transaction

func (m *MockStore) Transaction(id tx.ID) (*CommittedTx, error)

func (*MockStore) UpdateAccount

func (m *MockStore) UpdateAccount(addr crypto.Address, acc *account.Account)

func (*MockStore) UpdateValidator

func (m *MockStore) UpdateValidator(val *validator.Validator)

func (*MockStore) Validator

func (m *MockStore) Validator(addr crypto.Address) (*validator.Validator, error)

func (*MockStore) ValidatorAddresses added in v0.12.0

func (m *MockStore) ValidatorAddresses() []crypto.Address

func (*MockStore) ValidatorByNumber

func (m *MockStore) ValidatorByNumber(num int32) (*validator.Validator, error)

func (*MockStore) WriteBatch

func (m *MockStore) WriteBatch() error

type PublicKeyNotFoundError added in v0.15.0

type PublicKeyNotFoundError struct {
	Address crypto.Address
}

PublicKeyNotFoundError is returned when the public key associated with an address is not found in the store.

func (PublicKeyNotFoundError) Error added in v0.15.0

func (e PublicKeyNotFoundError) Error() string

type Reader

type Reader interface {
	Block(height uint32) (*CommittedBlock, error)
	BlockHeight(h hash.Hash) uint32
	BlockHash(height uint32) hash.Hash
	SortitionSeed(blockHeight uint32) *sortition.VerifiableSeed
	Transaction(id tx.ID) (*CommittedTx, error)
	AnyRecentTransaction(id tx.ID) bool
	PublicKey(addr crypto.Address) (*bls.PublicKey, error)
	HasAccount(crypto.Address) bool
	Account(addr crypto.Address) (*account.Account, error)
	TotalAccounts() int32
	HasValidator(addr crypto.Address) bool
	ValidatorAddresses() []crypto.Address
	Validator(addr crypto.Address) (*validator.Validator, error)
	ValidatorByNumber(num int32) (*validator.Validator, error)
	IterateValidators(consumer func(*validator.Validator) (stop bool))
	IterateAccounts(consumer func(crypto.Address, *account.Account) (stop bool))
	TotalValidators() int32
	LastCertificate() *certificate.Certificate
}

type Store

type Store interface {
	Reader

	UpdateAccount(addr crypto.Address, acc *account.Account)
	UpdateValidator(val *validator.Validator)
	SaveBlock(blk *block.Block, cert *certificate.Certificate)
	WriteBatch() error
	Close() error
}

func NewStore

func NewStore(conf *Config) (Store, error)

Jump to

Keyboard shortcuts

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