store

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

func DefaultConfig

func DefaultConfig() *Config

func (*Config) DataPath

func (conf *Config) DataPath() string

func (*Config) SanityCheck

func (conf *Config) SanityCheck() error

SanityCheck performs basic checks on the configuration.

func (*Config) StorePath

func (conf *Config) StorePath() string

type MockStore

type MockStore struct {
	Blocks     map[uint32]block.Block
	Accounts   map[crypto.Address]account.Account
	Validators map[crypto.Address]validator.Validator
	LastCert   *block.Certificate
	LastHeight uint32
}

func MockingStore

func MockingStore() *MockStore

func (*MockStore) Account

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

func (*MockStore) AddTestAccount

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

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) (*StoredBlock, error)

func (*MockStore) BlockHash

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

func (*MockStore) BlockHeight

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

func (*MockStore) Close

func (m *MockStore) Close() error

func (*MockStore) FindBlockHashByStamp

func (m *MockStore) FindBlockHashByStamp(stamp hash.Stamp) (hash.Hash, bool)

func (*MockStore) FindBlockHeightByStamp

func (m *MockStore) FindBlockHeightByStamp(stamp hash.Stamp) (uint32, bool)

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() (uint32, *block.Certificate)

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(height uint32, b *block.Block, cert *block.Certificate)

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) (*StoredTx, 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) ValidatorByNumber

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

func (*MockStore) WriteBatch

func (m *MockStore) WriteBatch() error

type Reader

type Reader interface {
	Block(height uint32) (*StoredBlock, error)
	BlockHeight(hash hash.Hash) uint32
	BlockHash(height uint32) hash.Hash
	// It only remembers most recent stamps
	FindBlockHashByStamp(stamp hash.Stamp) (hash.Hash, bool)
	// It only remembers most recent stamps
	FindBlockHeightByStamp(stamp hash.Stamp) (uint32, bool)
	Transaction(id tx.ID) (*StoredTx, error)
	HasAccount(crypto.Address) bool
	Account(addr crypto.Address) (*account.Account, error)
	TotalAccounts() int32
	HasValidator(crypto.Address) bool
	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() (uint32, *block.Certificate)
}

type Store

type Store interface {
	Reader

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

func NewStore

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

type StoredBlock

type StoredBlock struct {
	BlockHash hash.Hash
	Height    uint32
	Data      []byte
}

func (*StoredBlock) ToBlock

func (s *StoredBlock) ToBlock() *block.Block

type StoredTx

type StoredTx struct {
	TxID      tx.ID
	Height    uint32
	BlockTime uint32
	Data      []byte
}

func (*StoredTx) ToTx

func (s *StoredTx) ToTx() *tx.Tx

Jump to

Keyboard shortcuts

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