store

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: MIT Imports: 25 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"`
	RetentionDays uint32 `toml:"retention_days"`

	// Private configs
	TxCacheWindow      uint32                  `toml:"-"`
	SeedCacheWindow    uint32                  `toml:"-"`
	AccountCacheSize   int                     `toml:"-"`
	PublicKeyCacheSize int                     `toml:"-"`
	BannedAddrs        map[crypto.Address]bool `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) RetentionBlocks added in v1.4.0

func (conf *Config) RetentionBlocks() uint32

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.BlockCertificate
	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) 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 (*MockStore) Close()

func (*MockStore) HasAccount

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

func (*MockStore) HasAnyBlock

func (m *MockStore) HasAnyBlock() bool

func (*MockStore) HasPublicKey added in v1.6.0

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

func (*MockStore) HasValidator

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

func (*MockStore) IsBanned added in v1.1.3

func (*MockStore) IsBanned(_ crypto.Address) bool

func (*MockStore) IsPruned added in v1.4.0

func (*MockStore) IsPruned() 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.BlockCertificate

func (*MockStore) Prune added in v1.4.0

func (*MockStore) Prune(_ func(_ bool, _ uint32) bool) error

func (*MockStore) PruningHeight added in v1.4.0

func (*MockStore) PruningHeight() uint32

func (*MockStore) PublicKey added in v0.15.0

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

func (*MockStore) RandomTestAcc

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

func (*MockStore) RandomTestVal

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

func (*MockStore) RecentTransaction added in v1.5.0

func (m *MockStore) RecentTransaction(txID tx.ID) bool

func (*MockStore) SaveBlock

func (m *MockStore) SaveBlock(blk *block.Block, cert *certificate.BlockCertificate)

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(txID 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 (*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(txID tx.ID) (*CommittedTx, error)
	RecentTransaction(txID tx.ID) bool
	PublicKey(addr crypto.Address) (crypto.PublicKey, error)
	HasPublicKey(addr crypto.Address) bool
	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.BlockCertificate
	IsBanned(addr crypto.Address) bool
	IsPruned() bool
	PruningHeight() uint32
}

type Store

type Store interface {
	Reader

	UpdateAccount(addr crypto.Address, acc *account.Account)
	UpdateValidator(val *validator.Validator)
	SaveBlock(blk *block.Block, cert *certificate.BlockCertificate)
	Prune(callback func(pruned bool, pruningHeight uint32) bool) error
	WriteBatch() error
	Close()
}

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