state

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Facade

type Facade interface {
	Genesis() *genesis.Genesis
	LastBlockHeight() uint32
	LastBlockHash() hash.Hash
	LastBlockTime() time.Time
	LastCertificate() *certificate.Certificate
	UpdateLastCertificate(v *vote.Vote) error
	ProposeBlock(valKey *bls.ValidatorKey, rewardAddr crypto.Address) (*block.Block, error)
	ValidateBlock(blk *block.Block, round int16) error
	CommitBlock(blk *block.Block, cert *certificate.Certificate) error
	CommitteeValidators() []*validator.Validator
	IsInCommittee(addr crypto.Address) bool
	Proposer(round int16) *validator.Validator
	IsProposer(addr crypto.Address, round int16) bool
	IsValidator(addr crypto.Address) bool
	TotalPower() int64
	TotalAccounts() int32
	TotalValidators() int32
	CommitteePower() int64
	PendingTx(id tx.ID) *tx.Tx
	AddPendingTx(trx *tx.Tx) error
	AddPendingTxAndBroadcast(trx *tx.Tx) error
	CommittedBlock(height uint32) *store.CommittedBlock
	CommittedTx(id tx.ID) *store.CommittedTx
	BlockHash(height uint32) hash.Hash
	BlockHeight(h hash.Hash) uint32
	AccountByAddress(addr crypto.Address) *account.Account
	ValidatorByAddress(addr crypto.Address) *validator.Validator
	ValidatorByNumber(number int32) *validator.Validator
	ValidatorAddresses() []crypto.Address
	Params() *param.Params
	Close() error
	CalculateFee(amount int64, payloadType payload.Type) (int64, error)
	PublicKey(addr crypto.Address) (crypto.PublicKey, error)
	AvailabilityScore(valNum int32) float64
}

func LoadOrNewState

func LoadOrNewState(
	genDoc *genesis.Genesis,
	valKeys []*bls.ValidatorKey,
	str store.Store,
	txPool txpool.TxPool, eventCh chan event.Event,
) (Facade, error)

type InvalidCertificateError added in v0.15.0

type InvalidCertificateError struct {
	Cert *certificate.Certificate
}

InvalidCertificateError is returned when the given certificate is invalid.

func (InvalidCertificateError) Error added in v0.15.0

func (e InvalidCertificateError) Error() string

type InvalidVoteForCertificateError added in v0.15.0

type InvalidVoteForCertificateError struct {
	Vote *vote.Vote
}

InvalidVoteForCertificateError is returned when an attempt to update the last certificate with an invalid vote is made.

func (InvalidVoteForCertificateError) Error added in v0.15.0

type MockState

type MockState struct {
	TestGenesis   *genesis.Genesis
	TestStore     *store.MockStore
	TestPool      *txpool.MockTxPool
	TestCommittee committee.Committee
	TestValKeys   []*bls.ValidatorKey
	TestParams    *param.Params
	// contains filtered or unexported fields
}

func MockingState

func MockingState(ts *testsuite.TestSuite) *MockState

func (*MockState) AccountByAddress

func (m *MockState) AccountByAddress(addr crypto.Address) *account.Account

func (*MockState) AccountByNumber added in v0.12.0

func (m *MockState) AccountByNumber(number int32) *account.Account

func (*MockState) AddPendingTx

func (m *MockState) AddPendingTx(trx *tx.Tx) error

func (*MockState) AddPendingTxAndBroadcast

func (m *MockState) AddPendingTxAndBroadcast(trx *tx.Tx) error

func (*MockState) AvailabilityScore added in v0.19.0

func (m *MockState) AvailabilityScore(_ int32) float64

func (*MockState) BlockHash

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

func (*MockState) BlockHeight

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

func (*MockState) CalculateFee added in v0.15.0

func (m *MockState) CalculateFee(_ int64, payloadType payload.Type) (int64, error)

func (*MockState) Close

func (m *MockState) Close() error

func (*MockState) CommitBlock

func (m *MockState) CommitBlock(b *block.Block, cert *certificate.Certificate) error

func (*MockState) CommitTestBlocks

func (m *MockState) CommitTestBlocks(num int)

func (*MockState) CommittedBlock added in v0.15.0

func (m *MockState) CommittedBlock(height uint32) *store.CommittedBlock

func (*MockState) CommittedTx added in v0.15.0

func (m *MockState) CommittedTx(id tx.ID) *store.CommittedTx

func (*MockState) CommitteePower

func (m *MockState) CommitteePower() int64

func (*MockState) CommitteeValidators

func (m *MockState) CommitteeValidators() []*validator.Validator

func (*MockState) Genesis added in v0.11.0

func (m *MockState) Genesis() *genesis.Genesis

func (*MockState) IsInCommittee

func (m *MockState) IsInCommittee(addr crypto.Address) bool

func (*MockState) IsProposer

func (m *MockState) IsProposer(addr crypto.Address, round int16) bool

func (*MockState) IsValidator

func (m *MockState) IsValidator(addr crypto.Address) bool

func (*MockState) LastBlockHash

func (m *MockState) LastBlockHash() hash.Hash

func (*MockState) LastBlockHeight

func (m *MockState) LastBlockHeight() uint32

func (*MockState) LastBlockTime

func (m *MockState) LastBlockTime() time.Time

func (*MockState) LastCertificate

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

func (*MockState) Params

func (m *MockState) Params() *param.Params

func (*MockState) PendingTx

func (m *MockState) PendingTx(id tx.ID) *tx.Tx

func (*MockState) ProposeBlock

func (m *MockState) ProposeBlock(valKey *bls.ValidatorKey, _ crypto.Address) (*block.Block, error)

func (*MockState) Proposer

func (m *MockState) Proposer(round int16) *validator.Validator

func (*MockState) PublicKey added in v0.15.0

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

func (*MockState) TotalAccounts added in v0.10.0

func (m *MockState) TotalAccounts() int32

func (*MockState) TotalPower

func (m *MockState) TotalPower() int64

func (*MockState) TotalValidators added in v0.10.0

func (m *MockState) TotalValidators() int32

func (*MockState) UpdateLastCertificate

func (m *MockState) UpdateLastCertificate(_ *vote.Vote) error

func (*MockState) ValidateBlock

func (m *MockState) ValidateBlock(_ *block.Block, _ int16) error

func (*MockState) ValidatorAddresses added in v0.12.0

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

func (*MockState) ValidatorByAddress

func (m *MockState) ValidatorByAddress(addr crypto.Address) *validator.Validator

func (*MockState) ValidatorByNumber

func (m *MockState) ValidatorByNumber(n int32) *validator.Validator

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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