Documentation
¶
Overview ¶
Package validators is a generated GoMock package.
Package validators is a generated GoMock package.
Package validators is a generated GoMock package.
Index ¶
- Variables
- type Connector
- type GetValidatorOutput
- type Manager
- type MockManager
- func (m *MockManager) AddStaker(subnetID ids.ID, nodeID ids.NodeID, pk *bls.PublicKey, txID ids.ID, ...) error
- func (m *MockManager) AddWeight(subnetID ids.ID, nodeID ids.NodeID, weight uint64) error
- func (m *MockManager) Count(subnetID ids.ID) int
- func (m *MockManager) EXPECT() *MockManagerMockRecorder
- func (m *MockManager) GetMap(subnetID ids.ID) map[ids.NodeID]*GetValidatorOutput
- func (m *MockManager) GetValidator(subnetID ids.ID, nodeID ids.NodeID) (*Validator, bool)
- func (m *MockManager) GetValidatorIDs(subnetID ids.ID) []ids.NodeID
- func (m *MockManager) GetWeight(subnetID ids.ID, nodeID ids.NodeID) uint64
- func (m *MockManager) RegisterCallbackListener(subnetID ids.ID, listener SetCallbackListener)
- func (m *MockManager) RemoveWeight(subnetID ids.ID, nodeID ids.NodeID, weight uint64) error
- func (m *MockManager) Sample(subnetID ids.ID, size int) ([]ids.NodeID, error)
- func (m *MockManager) String() string
- func (m *MockManager) SubsetWeight(subnetID ids.ID, validatorIDs set.Set[ids.NodeID]) (uint64, error)
- func (m *MockManager) TotalWeight(subnetID ids.ID) (uint64, error)
- type MockManagerMockRecorder
- func (mr *MockManagerMockRecorder) AddStaker(subnetID, nodeID, pk, txID, weight any) *gomock.Call
- func (mr *MockManagerMockRecorder) AddWeight(subnetID, nodeID, weight any) *gomock.Call
- func (mr *MockManagerMockRecorder) Count(subnetID any) *gomock.Call
- func (mr *MockManagerMockRecorder) GetMap(subnetID any) *gomock.Call
- func (mr *MockManagerMockRecorder) GetValidator(subnetID, nodeID any) *gomock.Call
- func (mr *MockManagerMockRecorder) GetValidatorIDs(subnetID any) *gomock.Call
- func (mr *MockManagerMockRecorder) GetWeight(subnetID, nodeID any) *gomock.Call
- func (mr *MockManagerMockRecorder) RegisterCallbackListener(subnetID, listener any) *gomock.Call
- func (mr *MockManagerMockRecorder) RemoveWeight(subnetID, nodeID, weight any) *gomock.Call
- func (mr *MockManagerMockRecorder) Sample(subnetID, size any) *gomock.Call
- func (mr *MockManagerMockRecorder) String() *gomock.Call
- func (mr *MockManagerMockRecorder) SubsetWeight(subnetID, validatorIDs any) *gomock.Call
- func (mr *MockManagerMockRecorder) TotalWeight(subnetID any) *gomock.Call
- type MockState
- func (m *MockState) EXPECT() *MockStateMockRecorder
- func (m *MockState) GetCurrentHeight(arg0 context.Context) (uint64, error)
- func (m *MockState) GetMinimumHeight(arg0 context.Context) (uint64, error)
- func (m *MockState) GetSubnetID(arg0 context.Context, arg1 ids.ID) (ids.ID, error)
- func (m *MockState) GetValidatorSet(arg0 context.Context, arg1 uint64, arg2 ids.ID) (map[ids.NodeID]*GetValidatorOutput, error)
- func (m *MockState) ValidateCachedGetValidatorSet(arg0 context.Context, arg1 uint64, arg2 ids.ID) error
- type MockStateMockRecorder
- func (mr *MockStateMockRecorder) GetCurrentHeight(arg0 any) *gomock.Call
- func (mr *MockStateMockRecorder) GetMinimumHeight(arg0 any) *gomock.Call
- func (mr *MockStateMockRecorder) GetSubnetID(arg0, arg1 any) *gomock.Call
- func (mr *MockStateMockRecorder) GetValidatorSet(arg0, arg1, arg2 any) *gomock.Call
- func (mr *MockStateMockRecorder) ValidateCachedGetValidatorSet(arg0, arg1, arg2 any) *gomock.Call
- type MockSubnetConnector
- type MockSubnetConnectorMockRecorder
- type SetCallbackListener
- type State
- type SubnetConnector
- type TestState
- func (vm *TestState) GetCurrentHeight(ctx context.Context) (uint64, error)
- func (vm *TestState) GetMinimumHeight(ctx context.Context) (uint64, error)
- func (vm *TestState) GetSubnetID(ctx context.Context, chainID ids.ID) (ids.ID, error)
- func (vm *TestState) GetValidatorSet(ctx context.Context, height uint64, subnetID ids.ID) (map[ids.NodeID]*GetValidatorOutput, error)
- func (*TestState) ValidateCachedGetValidatorSet(context.Context, uint64, ids.ID) error
- type Validator
Constants ¶
This section is empty.
Variables ¶
var ( ErrZeroWeight = errors.New("weight must be non-zero") ErrMissingValidators = errors.New("missing validators") )
Functions ¶
This section is empty.
Types ¶
type Connector ¶ added in v0.8.0
type Connector interface {
Connected(
ctx context.Context,
nodeID ids.NodeID,
nodeVersion *version.Application,
) error
Disconnected(ctx context.Context, nodeID ids.NodeID) error
}
Connector represents a handler that is called when a connection is marked as connected or disconnected
type GetValidatorOutput ¶ added in v1.9.4
GetValidatorOutput is a struct that contains the publicly relevant values of a validator of the Avalanche Network for the output of GetValidator.
type Manager ¶
type Manager interface {
fmt.Stringer
// Add a new staker to the subnet.
// Returns an error if:
// - [weight] is 0
// - [nodeID] is already in the validator set
// If an error is returned, the set will be unmodified.
AddStaker(subnetID ids.ID, nodeID ids.NodeID, pk *bls.PublicKey, txID ids.ID, weight uint64) error
// AddWeight to an existing staker to the subnet.
// Returns an error if:
// - [weight] is 0
// - [nodeID] is not already in the validator set
// If an error is returned, the set will be unmodified.
// AddWeight can result in a total weight that overflows uint64.
// In this case no error will be returned for this call.
// However, the next TotalWeight call will return an error.
AddWeight(subnetID ids.ID, nodeID ids.NodeID, weight uint64) error
// GetWeight retrieves the validator weight from the subnet.
GetWeight(subnetID ids.ID, nodeID ids.NodeID) uint64
// GetValidator returns the validator tied to the specified ID in subnet.
// If the validator doesn't exist, returns false.
GetValidator(subnetID ids.ID, nodeID ids.NodeID) (*Validator, bool)
// GetValidatoIDs returns the validator IDs in the subnet.
GetValidatorIDs(subnetID ids.ID) []ids.NodeID
// SubsetWeight returns the sum of the weights of the validators in the subnet.
// Returns err if subset weight overflows uint64.
SubsetWeight(subnetID ids.ID, validatorIDs set.Set[ids.NodeID]) (uint64, error)
// RemoveWeight from a staker in the subnet. If the staker's weight becomes 0, the staker
// will be removed from the subnet set.
// Returns an error if:
// - [weight] is 0
// - [nodeID] is not already in the subnet set
// - the weight of the validator would become negative
// If an error is returned, the set will be unmodified.
RemoveWeight(subnetID ids.ID, nodeID ids.NodeID, weight uint64) error
// Count returns the number of validators currently in the subnet.
Count(subnetID ids.ID) int
// TotalWeight returns the cumulative weight of all validators in the subnet.
// Returns err if total weight overflows uint64.
TotalWeight(subnetID ids.ID) (uint64, error)
// Sample returns a collection of validatorIDs in the subnet, potentially with duplicates.
// If sampling the requested size isn't possible, an error will be returned.
Sample(subnetID ids.ID, size int) ([]ids.NodeID, error)
// Map of the validators in this subnet
GetMap(subnetID ids.ID) map[ids.NodeID]*GetValidatorOutput
// When a validator's weight changes, or a validator is added/removed,
// this listener is called.
RegisterCallbackListener(subnetID ids.ID, listener SetCallbackListener)
}
Manager holds the validator set of each subnet
type MockManager ¶ added in v1.9.4
type MockManager struct {
// contains filtered or unexported fields
}
MockManager is a mock of Manager interface.
func NewMockManager ¶ added in v1.9.4
func NewMockManager(ctrl *gomock.Controller) *MockManager
NewMockManager creates a new mock instance.
func (*MockManager) AddStaker ¶ added in v1.10.14
func (m *MockManager) AddStaker(subnetID ids.ID, nodeID ids.NodeID, pk *bls.PublicKey, txID ids.ID, weight uint64) error
AddStaker mocks base method.
func (*MockManager) Count ¶ added in v1.10.18
func (m *MockManager) Count(subnetID ids.ID) int
Count mocks base method.
func (*MockManager) EXPECT ¶ added in v1.9.4
func (m *MockManager) EXPECT() *MockManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockManager) GetMap ¶ added in v1.10.14
func (m *MockManager) GetMap(subnetID ids.ID) map[ids.NodeID]*GetValidatorOutput
GetMap mocks base method.
func (*MockManager) GetValidator ¶ added in v1.10.14
GetValidator mocks base method.
func (*MockManager) GetValidatorIDs ¶ added in v1.10.14
func (m *MockManager) GetValidatorIDs(subnetID ids.ID) []ids.NodeID
GetValidatorIDs mocks base method.
func (*MockManager) RegisterCallbackListener ¶ added in v1.10.14
func (m *MockManager) RegisterCallbackListener(subnetID ids.ID, listener SetCallbackListener)
RegisterCallbackListener mocks base method.
func (*MockManager) RemoveWeight ¶ added in v1.10.14
RemoveWeight mocks base method.
func (*MockManager) String ¶ added in v1.9.4
func (m *MockManager) String() string
String mocks base method.
func (*MockManager) SubsetWeight ¶ added in v1.10.14
func (m *MockManager) SubsetWeight(subnetID ids.ID, validatorIDs set.Set[ids.NodeID]) (uint64, error)
SubsetWeight mocks base method.
func (*MockManager) TotalWeight ¶ added in v1.10.14
func (m *MockManager) TotalWeight(subnetID ids.ID) (uint64, error)
TotalWeight mocks base method.
type MockManagerMockRecorder ¶ added in v1.9.4
type MockManagerMockRecorder struct {
// contains filtered or unexported fields
}
MockManagerMockRecorder is the mock recorder for MockManager.
func (*MockManagerMockRecorder) AddStaker ¶ added in v1.10.14
func (mr *MockManagerMockRecorder) AddStaker(subnetID, nodeID, pk, txID, weight any) *gomock.Call
AddStaker indicates an expected call of AddStaker.
func (*MockManagerMockRecorder) AddWeight ¶ added in v1.10.14
func (mr *MockManagerMockRecorder) AddWeight(subnetID, nodeID, weight any) *gomock.Call
AddWeight indicates an expected call of AddWeight.
func (*MockManagerMockRecorder) Count ¶ added in v1.10.18
func (mr *MockManagerMockRecorder) Count(subnetID any) *gomock.Call
Count indicates an expected call of Count.
func (*MockManagerMockRecorder) GetMap ¶ added in v1.10.14
func (mr *MockManagerMockRecorder) GetMap(subnetID any) *gomock.Call
GetMap indicates an expected call of GetMap.
func (*MockManagerMockRecorder) GetValidator ¶ added in v1.10.14
func (mr *MockManagerMockRecorder) GetValidator(subnetID, nodeID any) *gomock.Call
GetValidator indicates an expected call of GetValidator.
func (*MockManagerMockRecorder) GetValidatorIDs ¶ added in v1.10.14
func (mr *MockManagerMockRecorder) GetValidatorIDs(subnetID any) *gomock.Call
GetValidatorIDs indicates an expected call of GetValidatorIDs.
func (*MockManagerMockRecorder) GetWeight ¶ added in v1.10.14
func (mr *MockManagerMockRecorder) GetWeight(subnetID, nodeID any) *gomock.Call
GetWeight indicates an expected call of GetWeight.
func (*MockManagerMockRecorder) RegisterCallbackListener ¶ added in v1.10.14
func (mr *MockManagerMockRecorder) RegisterCallbackListener(subnetID, listener any) *gomock.Call
RegisterCallbackListener indicates an expected call of RegisterCallbackListener.
func (*MockManagerMockRecorder) RemoveWeight ¶ added in v1.10.14
func (mr *MockManagerMockRecorder) RemoveWeight(subnetID, nodeID, weight any) *gomock.Call
RemoveWeight indicates an expected call of RemoveWeight.
func (*MockManagerMockRecorder) Sample ¶ added in v1.10.14
func (mr *MockManagerMockRecorder) Sample(subnetID, size any) *gomock.Call
Sample indicates an expected call of Sample.
func (*MockManagerMockRecorder) String ¶ added in v1.9.4
func (mr *MockManagerMockRecorder) String() *gomock.Call
String indicates an expected call of String.
func (*MockManagerMockRecorder) SubsetWeight ¶ added in v1.10.14
func (mr *MockManagerMockRecorder) SubsetWeight(subnetID, validatorIDs any) *gomock.Call
SubsetWeight indicates an expected call of SubsetWeight.
func (*MockManagerMockRecorder) TotalWeight ¶ added in v1.10.14
func (mr *MockManagerMockRecorder) TotalWeight(subnetID any) *gomock.Call
TotalWeight indicates an expected call of TotalWeight.
type MockState ¶ added in v1.9.2
type MockState struct {
// contains filtered or unexported fields
}
MockState is a mock of State interface.
func NewMockState ¶ added in v1.9.2
func NewMockState(ctrl *gomock.Controller) *MockState
NewMockState creates a new mock instance.
func (*MockState) EXPECT ¶ added in v1.9.2
func (m *MockState) EXPECT() *MockStateMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockState) GetCurrentHeight ¶ added in v1.9.2
GetCurrentHeight mocks base method.
func (*MockState) GetMinimumHeight ¶ added in v1.9.2
GetMinimumHeight mocks base method.
func (*MockState) GetSubnetID ¶ added in v1.9.5
GetSubnetID mocks base method.
type MockStateMockRecorder ¶ added in v1.9.2
type MockStateMockRecorder struct {
// contains filtered or unexported fields
}
MockStateMockRecorder is the mock recorder for MockState.
func (*MockStateMockRecorder) GetCurrentHeight ¶ added in v1.9.2
func (mr *MockStateMockRecorder) GetCurrentHeight(arg0 any) *gomock.Call
GetCurrentHeight indicates an expected call of GetCurrentHeight.
func (*MockStateMockRecorder) GetMinimumHeight ¶ added in v1.9.2
func (mr *MockStateMockRecorder) GetMinimumHeight(arg0 any) *gomock.Call
GetMinimumHeight indicates an expected call of GetMinimumHeight.
func (*MockStateMockRecorder) GetSubnetID ¶ added in v1.9.5
func (mr *MockStateMockRecorder) GetSubnetID(arg0, arg1 any) *gomock.Call
GetSubnetID indicates an expected call of GetSubnetID.
func (*MockStateMockRecorder) GetValidatorSet ¶ added in v1.9.2
func (mr *MockStateMockRecorder) GetValidatorSet(arg0, arg1, arg2 any) *gomock.Call
GetValidatorSet indicates an expected call of GetValidatorSet.
func (*MockStateMockRecorder) ValidateCachedGetValidatorSet ¶
func (mr *MockStateMockRecorder) ValidateCachedGetValidatorSet(arg0, arg1, arg2 any) *gomock.Call
ValidateCachedGetValidatorSet indicates an expected call of ValidateCachedGetValidatorSet.
type MockSubnetConnector ¶ added in v1.9.4
type MockSubnetConnector struct {
// contains filtered or unexported fields
}
MockSubnetConnector is a mock of SubnetConnector interface.
func NewMockSubnetConnector ¶ added in v1.9.4
func NewMockSubnetConnector(ctrl *gomock.Controller) *MockSubnetConnector
NewMockSubnetConnector creates a new mock instance.
func (*MockSubnetConnector) ConnectedSubnet ¶ added in v1.9.4
func (m *MockSubnetConnector) ConnectedSubnet(arg0 context.Context, arg1 ids.NodeID, arg2 ids.ID) error
ConnectedSubnet mocks base method.
func (*MockSubnetConnector) EXPECT ¶ added in v1.9.4
func (m *MockSubnetConnector) EXPECT() *MockSubnetConnectorMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockSubnetConnectorMockRecorder ¶ added in v1.9.4
type MockSubnetConnectorMockRecorder struct {
// contains filtered or unexported fields
}
MockSubnetConnectorMockRecorder is the mock recorder for MockSubnetConnector.
func (*MockSubnetConnectorMockRecorder) ConnectedSubnet ¶ added in v1.9.4
func (mr *MockSubnetConnectorMockRecorder) ConnectedSubnet(arg0, arg1, arg2 any) *gomock.Call
ConnectedSubnet indicates an expected call of ConnectedSubnet.
type SetCallbackListener ¶ added in v1.7.11
type State ¶ added in v1.6.0
type State interface {
// GetMinimumHeight returns the minimum height of the block still in the
// proposal window.
GetMinimumHeight(context.Context) (uint64, error)
// GetCurrentHeight returns the current height of the P-chain.
GetCurrentHeight(context.Context) (uint64, error)
// GetSubnetID returns the subnetID of the provided chain.
GetSubnetID(ctx context.Context, chainID ids.ID) (ids.ID, error)
// GetValidatorSet returns the validators of the provided subnet at the
// requested P-chain height.
// The returned map should not be modified.
GetValidatorSet(
ctx context.Context,
height uint64,
subnetID ids.ID,
) (map[ids.NodeID]*GetValidatorOutput, error)
ValidateCachedGetValidatorSet(
ctx context.Context,
targetHeight uint64,
subnetID ids.ID,
) error
}
State allows the lookup of validator sets on specified subnets at the requested P-chain height.
func NewNoValidatorsState ¶ added in v1.7.14
type SubnetConnector ¶ added in v1.9.4
type SubnetConnector interface {
ConnectedSubnet(ctx context.Context, nodeID ids.NodeID, subnetID ids.ID) error
}
SubnetConnector represents a handler that is called when a connection is marked as connected to a subnet
var UnhandledSubnetConnector SubnetConnector = &unhandledSubnetConnector{}
type TestState ¶ added in v1.6.0
type TestState struct {
T testing.TB
CantGetMinimumHeight,
CantGetCurrentHeight,
CantGetSubnetID,
CantGetValidatorSet bool
GetMinimumHeightF func(ctx context.Context) (uint64, error)
GetCurrentHeightF func(ctx context.Context) (uint64, error)
GetSubnetIDF func(ctx context.Context, chainID ids.ID) (ids.ID, error)
GetValidatorSetF func(ctx context.Context, height uint64, subnetID ids.ID) (map[ids.NodeID]*GetValidatorOutput, error)
}