Documentation ¶
Overview ¶
Package validators provides a module for processing validator requests from a blockchain application using a pluggable validator manager and account store.
Package validators provides a module for processing validator requests from a blockchain application using a pluggable validator manager and account store.
Index ¶
- type ExecutionResponse
- type Spender
- type ValidatorMgr
- type ValidatorModule
- func (vm *ValidatorModule) Approve(ctx context.Context, joiner []byte, txn *transactions.Transaction) (*ExecutionResponse, error)
- func (vm *ValidatorModule) CurrentSet(ctx context.Context) ([]*validators.Validator, error)
- func (vm *ValidatorModule) Finalize(ctx context.Context) ([]*validators.Validator, error)
- func (vm *ValidatorModule) GenesisInit(ctx context.Context, vals []*validators.Validator, blockHeight int64) error
- func (vm *ValidatorModule) Join(ctx context.Context, power int64, txn *transactions.Transaction) (*ExecutionResponse, error)
- func (vm *ValidatorModule) Leave(ctx context.Context, txn *transactions.Transaction) (*ExecutionResponse, error)
- func (v *ValidatorModule) PriceApprove(ctx context.Context) (*big.Int, error)
- func (v *ValidatorModule) PriceJoin(ctx context.Context) (*big.Int, error)
- func (v *ValidatorModule) PriceLeave(ctx context.Context) (*big.Int, error)
- func (v *ValidatorModule) PriceRemove(ctx context.Context) (*big.Int, error)
- func (vm *ValidatorModule) Punish(ctx context.Context, validator []byte, newPower int64) error
- func (vm *ValidatorModule) Remove(ctx context.Context, validator []byte, txn *transactions.Transaction) (*ExecutionResponse, error)
- func (vm *ValidatorModule) UpdateBlockHeight(ctx context.Context, blockHeight int64)
- type ValidatorModuleOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExecutionResponse ¶
type ValidatorMgr ¶
type ValidatorMgr interface { GenesisInit(ctx context.Context, vals []*validators.Validator, blockHeight int64) error CurrentSet(ctx context.Context) ([]*validators.Validator, error) Update(ctx context.Context, validator []byte, power int64) error Join(ctx context.Context, joiner []byte, power int64) error Leave(ctx context.Context, joiner []byte) error Approve(ctx context.Context, joiner, approver []byte) error Remove(ctx context.Context, target, validator []byte) error Finalize(ctx context.Context) ([]*validators.Validator, error) // end of block processing requires providing list of updates to the node's consensus client UpdateBlockHeight(blockHeight int64) PriceJoin(ctx context.Context) (*big.Int, error) PriceApprove(ctx context.Context) (*big.Int, error) PriceLeave(ctx context.Context) (*big.Int, error) PriceRemove(ctx context.Context) (*big.Int, error) }
type ValidatorModule ¶
type ValidatorModule struct {
// contains filtered or unexported fields
}
ValidatorModule separates validator update and state persistence details from the processing of validator related transactions (pricing and account updates i.e. "spending").
func NewValidatorModule ¶
func NewValidatorModule(mgr ValidatorMgr, accts Spender, opts ...ValidatorModuleOpt) *ValidatorModule
NewValidatorModule constructs a validator module. The ValidatorMgr handles the details of computing validator updates to be included in a block, while the Spender provides handles account balance updates when processing the transactions.
func (*ValidatorModule) Approve ¶
func (vm *ValidatorModule) Approve(ctx context.Context, joiner []byte, txn *transactions.Transaction) (*ExecutionResponse, error)
Approve records an approval transaction from a current validator.
func (*ValidatorModule) CurrentSet ¶
func (vm *ValidatorModule) CurrentSet(ctx context.Context) ([]*validators.Validator, error)
CurrentSet returns the current validator list. This may be used on construction of a resuming application.
func (*ValidatorModule) Finalize ¶
func (vm *ValidatorModule) Finalize(ctx context.Context) ([]*validators.Validator, error)
Finalize is used at the end of block processing to retrieve the validator updates to be provided to the consensus client for the next block. This is not idempotent. The modules working list of updates is reset until subsequent join/approves are processed for the next block. end of block processing requires providing list of updates to the node's consensus client
func (*ValidatorModule) GenesisInit ¶
func (vm *ValidatorModule) GenesisInit(ctx context.Context, vals []*validators.Validator, blockHeight int64) error
GenesisInit is called at the genesis block to set and initial list of validators.
func (*ValidatorModule) Join ¶
func (vm *ValidatorModule) Join(ctx context.Context, power int64, txn *transactions.Transaction) (*ExecutionResponse, error)
Join creates a join request for a prospective validator.
func (*ValidatorModule) Leave ¶
func (vm *ValidatorModule) Leave(ctx context.Context, txn *transactions.Transaction) (*ExecutionResponse, error)
Leave creates a leave request for a current validator.
func (*ValidatorModule) PriceApprove ¶
func (*ValidatorModule) PriceLeave ¶
func (*ValidatorModule) PriceRemove ¶
func (*ValidatorModule) Punish ¶
Punish may be used at the start of block processing when byzantine validators are listed by the consensus client.
func (*ValidatorModule) Remove ¶
func (vm *ValidatorModule) Remove(ctx context.Context, validator []byte, txn *transactions.Transaction) (*ExecutionResponse, error)
Remove records a removal transaction targeting the given validator pubkey. The transaction sender must be a current validator. The caller ensures that the transaction signature is verified.
func (*ValidatorModule) UpdateBlockHeight ¶
func (vm *ValidatorModule) UpdateBlockHeight(ctx context.Context, blockHeight int64)
Updates block height stored by the validator manager. Called in the abci Commit
type ValidatorModuleOpt ¶
type ValidatorModuleOpt func(*ValidatorModule)