Documentation ¶
Overview ¶
Package validators is a generated GoMock package.
Package validators is a generated GoMock package.
Package validators is a generated GoMock package.
Package validators is a generated GoMock package.
Index ¶
- func Add(m Manager, subnetID ids.ID, nodeID ids.NodeID, pk *bls.PublicKey, txID ids.ID, ...) error
- func AddWeight(m Manager, subnetID ids.ID, nodeID ids.NodeID, weight uint64) error
- func Contains(m Manager, subnetID ids.ID, nodeID ids.NodeID) bool
- func RemoveWeight(m Manager, subnetID ids.ID, nodeID ids.NodeID, weight uint64) error
- type Connector
- type GetValidatorOutput
- type Manager
- type MockManager
- type MockManagerMockRecorder
- type MockSet
- func (m *MockSet) Add(arg0 ids.NodeID, arg1 *bls.PublicKey, arg2 ids.ID, arg3 uint64) error
- func (m *MockSet) AddWeight(arg0 ids.NodeID, arg1 uint64) error
- func (m *MockSet) Contains(arg0 ids.NodeID) bool
- func (m *MockSet) EXPECT() *MockSetMockRecorder
- func (m *MockSet) Get(arg0 ids.NodeID) (*Validator, bool)
- func (m *MockSet) GetWeight(arg0 ids.NodeID) uint64
- func (m *MockSet) Len() int
- func (m *MockSet) List() []*Validator
- func (m *MockSet) PrefixedString(arg0 string) string
- func (m *MockSet) RegisterCallbackListener(arg0 SetCallbackListener)
- func (m *MockSet) RemoveWeight(arg0 ids.NodeID, arg1 uint64) error
- func (m *MockSet) Sample(arg0 int) ([]ids.NodeID, error)
- func (m *MockSet) String() string
- func (m *MockSet) SubsetWeight(arg0 set.Set[ids.NodeID]) uint64
- func (m *MockSet) Weight() uint64
- type MockSetMockRecorder
- func (mr *MockSetMockRecorder) Add(arg0, arg1, arg2, arg3 interface{}) *gomock.Call
- func (mr *MockSetMockRecorder) AddWeight(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockSetMockRecorder) Contains(arg0 interface{}) *gomock.Call
- func (mr *MockSetMockRecorder) Get(arg0 interface{}) *gomock.Call
- func (mr *MockSetMockRecorder) GetWeight(arg0 interface{}) *gomock.Call
- func (mr *MockSetMockRecorder) Len() *gomock.Call
- func (mr *MockSetMockRecorder) List() *gomock.Call
- func (mr *MockSetMockRecorder) PrefixedString(arg0 interface{}) *gomock.Call
- func (mr *MockSetMockRecorder) RegisterCallbackListener(arg0 interface{}) *gomock.Call
- func (mr *MockSetMockRecorder) RemoveWeight(arg0, arg1 interface{}) *gomock.Call
- func (mr *MockSetMockRecorder) Sample(arg0 interface{}) *gomock.Call
- func (mr *MockSetMockRecorder) String() *gomock.Call
- func (mr *MockSetMockRecorder) SubsetWeight(arg0 interface{}) *gomock.Call
- func (mr *MockSetMockRecorder) Weight() *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) GetValidatorSet(arg0 context.Context, arg1 uint64, arg2 ids.ID) (map[ids.NodeID]*GetValidatorOutput, error)
- type MockStateMockRecorder
- type MockSubnetConnector
- type MockSubnetConnectorMockRecorder
- type Set
- type SetCallbackListener
- type State
- type SubnetConnector
- type TestState
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶ added in v1.8.7
func Add(m Manager, subnetID ids.ID, nodeID ids.NodeID, pk *bls.PublicKey, txID ids.ID, weight uint64) error
Add is a helper that fetches the validator set of [subnetID] from [m] and adds [nodeID] to the validator set. Returns an error if: - [subnetID] does not have a registered validator set in [m] - adding [nodeID] to the validator set returns an error
func AddWeight ¶ added in v1.8.7
AddWeight is a helper that fetches the validator set of [subnetID] from [m] and adds [weight] to [nodeID] in the validator set. Returns an error if: - [subnetID] does not have a registered validator set in [m] - adding [weight] to [nodeID] in the validator set returns an error
func Contains ¶ added in v1.8.7
AddWeight is a helper that fetches the validator set of [subnetID] from [m] and returns if the validator set contains [nodeID]. If [m] does not contain a validator set for [subnetID], false is returned.
func RemoveWeight ¶ added in v1.8.7
RemoveWeight is a helper that fetches the validator set of [subnetID] from [m] and removes [weight] from [nodeID] in the validator set. Returns an error if: - [subnetID] does not have a registered validator set in [m] - removing [weight] from [nodeID] in the validator set returns an error
Types ¶
type Connector ¶
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.8.7
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 subnet's validator set to the manager. // // If the subnet had previously registered a validator set, false will be // returned and the manager will not be modified. Add(subnetID ids.ID, set Set) bool // Get returns the validator set for the given subnet // Returns false if the subnet doesn't exist Get(ids.ID) (Set, bool) }
Manager holds the validator set of each subnet
type MockManager ¶ added in v1.8.7
type MockManager struct {
// contains filtered or unexported fields
}
MockManager is a mock of Manager interface.
func NewMockManager ¶ added in v1.8.7
func NewMockManager(ctrl *gomock.Controller) *MockManager
NewMockManager creates a new mock instance.
func (*MockManager) Add ¶ added in v1.8.7
func (m *MockManager) Add(arg0 ids.ID, arg1 Set) bool
Add mocks base method.
func (*MockManager) EXPECT ¶ added in v1.8.7
func (m *MockManager) EXPECT() *MockManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockManager) Get ¶ added in v1.8.7
func (m *MockManager) Get(arg0 ids.ID) (Set, bool)
Get mocks base method.
func (*MockManager) String ¶ added in v1.8.7
func (m *MockManager) String() string
String mocks base method.
type MockManagerMockRecorder ¶ added in v1.8.7
type MockManagerMockRecorder struct {
// contains filtered or unexported fields
}
MockManagerMockRecorder is the mock recorder for MockManager.
func (*MockManagerMockRecorder) Add ¶ added in v1.8.7
func (mr *MockManagerMockRecorder) Add(arg0, arg1 interface{}) *gomock.Call
Add indicates an expected call of Add.
func (*MockManagerMockRecorder) Get ¶ added in v1.8.7
func (mr *MockManagerMockRecorder) Get(arg0 interface{}) *gomock.Call
Get indicates an expected call of Get.
func (*MockManagerMockRecorder) String ¶ added in v1.8.7
func (mr *MockManagerMockRecorder) String() *gomock.Call
String indicates an expected call of String.
type MockSet ¶ added in v1.8.7
type MockSet struct {
// contains filtered or unexported fields
}
MockSet is a mock of Set interface.
func NewMockSet ¶ added in v1.8.7
func NewMockSet(ctrl *gomock.Controller) *MockSet
NewMockSet creates a new mock instance.
func (*MockSet) EXPECT ¶ added in v1.8.7
func (m *MockSet) EXPECT() *MockSetMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockSet) PrefixedString ¶ added in v1.8.7
PrefixedString mocks base method.
func (*MockSet) RegisterCallbackListener ¶ added in v1.8.7
func (m *MockSet) RegisterCallbackListener(arg0 SetCallbackListener)
RegisterCallbackListener mocks base method.
func (*MockSet) RemoveWeight ¶ added in v1.8.7
RemoveWeight mocks base method.
func (*MockSet) SubsetWeight ¶ added in v1.8.7
SubsetWeight mocks base method.
type MockSetMockRecorder ¶ added in v1.8.7
type MockSetMockRecorder struct {
// contains filtered or unexported fields
}
MockSetMockRecorder is the mock recorder for MockSet.
func (*MockSetMockRecorder) Add ¶ added in v1.8.7
func (mr *MockSetMockRecorder) Add(arg0, arg1, arg2, arg3 interface{}) *gomock.Call
Add indicates an expected call of Add.
func (*MockSetMockRecorder) AddWeight ¶ added in v1.8.7
func (mr *MockSetMockRecorder) AddWeight(arg0, arg1 interface{}) *gomock.Call
AddWeight indicates an expected call of AddWeight.
func (*MockSetMockRecorder) Contains ¶ added in v1.8.7
func (mr *MockSetMockRecorder) Contains(arg0 interface{}) *gomock.Call
Contains indicates an expected call of Contains.
func (*MockSetMockRecorder) Get ¶ added in v1.8.7
func (mr *MockSetMockRecorder) Get(arg0 interface{}) *gomock.Call
Get indicates an expected call of Get.
func (*MockSetMockRecorder) GetWeight ¶ added in v1.8.7
func (mr *MockSetMockRecorder) GetWeight(arg0 interface{}) *gomock.Call
GetWeight indicates an expected call of GetWeight.
func (*MockSetMockRecorder) Len ¶ added in v1.8.7
func (mr *MockSetMockRecorder) Len() *gomock.Call
Len indicates an expected call of Len.
func (*MockSetMockRecorder) List ¶ added in v1.8.7
func (mr *MockSetMockRecorder) List() *gomock.Call
List indicates an expected call of List.
func (*MockSetMockRecorder) PrefixedString ¶ added in v1.8.7
func (mr *MockSetMockRecorder) PrefixedString(arg0 interface{}) *gomock.Call
PrefixedString indicates an expected call of PrefixedString.
func (*MockSetMockRecorder) RegisterCallbackListener ¶ added in v1.8.7
func (mr *MockSetMockRecorder) RegisterCallbackListener(arg0 interface{}) *gomock.Call
RegisterCallbackListener indicates an expected call of RegisterCallbackListener.
func (*MockSetMockRecorder) RemoveWeight ¶ added in v1.8.7
func (mr *MockSetMockRecorder) RemoveWeight(arg0, arg1 interface{}) *gomock.Call
RemoveWeight indicates an expected call of RemoveWeight.
func (*MockSetMockRecorder) Sample ¶ added in v1.8.7
func (mr *MockSetMockRecorder) Sample(arg0 interface{}) *gomock.Call
Sample indicates an expected call of Sample.
func (*MockSetMockRecorder) String ¶ added in v1.8.7
func (mr *MockSetMockRecorder) String() *gomock.Call
String indicates an expected call of String.
func (*MockSetMockRecorder) SubsetWeight ¶ added in v1.8.7
func (mr *MockSetMockRecorder) SubsetWeight(arg0 interface{}) *gomock.Call
SubsetWeight indicates an expected call of SubsetWeight.
func (*MockSetMockRecorder) Weight ¶ added in v1.8.7
func (mr *MockSetMockRecorder) Weight() *gomock.Call
Weight indicates an expected call of Weight.
type MockState ¶ added in v1.8.7
type MockState struct {
// contains filtered or unexported fields
}
MockState is a mock of State interface.
func NewMockState ¶ added in v1.8.7
func NewMockState(ctrl *gomock.Controller) *MockState
NewMockState creates a new mock instance.
func (*MockState) EXPECT ¶ added in v1.8.7
func (m *MockState) EXPECT() *MockStateMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockState) GetCurrentHeight ¶ added in v1.8.7
GetCurrentHeight mocks base method.
func (*MockState) GetMinimumHeight ¶ added in v1.8.7
GetMinimumHeight mocks base method.
type MockStateMockRecorder ¶ added in v1.8.7
type MockStateMockRecorder struct {
// contains filtered or unexported fields
}
MockStateMockRecorder is the mock recorder for MockState.
func (*MockStateMockRecorder) GetCurrentHeight ¶ added in v1.8.7
func (mr *MockStateMockRecorder) GetCurrentHeight(arg0 interface{}) *gomock.Call
GetCurrentHeight indicates an expected call of GetCurrentHeight.
func (*MockStateMockRecorder) GetMinimumHeight ¶ added in v1.8.7
func (mr *MockStateMockRecorder) GetMinimumHeight(arg0 interface{}) *gomock.Call
GetMinimumHeight indicates an expected call of GetMinimumHeight.
func (*MockStateMockRecorder) GetValidatorSet ¶ added in v1.8.7
func (mr *MockStateMockRecorder) GetValidatorSet(arg0, arg1, arg2 interface{}) *gomock.Call
GetValidatorSet indicates an expected call of GetValidatorSet.
type MockSubnetConnector ¶ added in v1.8.7
type MockSubnetConnector struct {
// contains filtered or unexported fields
}
MockSubnetConnector is a mock of SubnetConnector interface.
func NewMockSubnetConnector ¶ added in v1.8.7
func NewMockSubnetConnector(ctrl *gomock.Controller) *MockSubnetConnector
NewMockSubnetConnector creates a new mock instance.
func (*MockSubnetConnector) ConnectedSubnet ¶ added in v1.8.7
func (m *MockSubnetConnector) ConnectedSubnet(arg0 context.Context, arg1 ids.NodeID, arg2 ids.ID) error
ConnectedSubnet mocks base method.
func (*MockSubnetConnector) EXPECT ¶ added in v1.8.7
func (m *MockSubnetConnector) EXPECT() *MockSubnetConnectorMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockSubnetConnectorMockRecorder ¶ added in v1.8.7
type MockSubnetConnectorMockRecorder struct {
// contains filtered or unexported fields
}
MockSubnetConnectorMockRecorder is the mock recorder for MockSubnetConnector.
func (*MockSubnetConnectorMockRecorder) ConnectedSubnet ¶ added in v1.8.7
func (mr *MockSubnetConnectorMockRecorder) ConnectedSubnet(arg0, arg1, arg2 interface{}) *gomock.Call
ConnectedSubnet indicates an expected call of ConnectedSubnet.
type Set ¶
type Set interface { formatting.PrefixedStringer // Add a new staker to the set. // Returns an error if: // - [weight] is 0 // - [nodeID] is already in the validator set // - the total weight of the validator set would overflow uint64 // If an error is returned, the set will be unmodified. Add(nodeID ids.NodeID, pk *bls.PublicKey, txID ids.ID, weight uint64) error // AddWeight to an existing staker. // Returns an error if: // - [weight] is 0 // - [nodeID] is not already in the validator set // - the total weight of the validator set would overflow uint64 // If an error is returned, the set will be unmodified. AddWeight(nodeID ids.NodeID, weight uint64) error // GetWeight retrieves the validator weight from the set. GetWeight(ids.NodeID) uint64 // Get returns the validator tied to the specified ID. Get(ids.NodeID) (*Validator, bool) // SubsetWeight returns the sum of the weights of the validators. SubsetWeight(set.Set[ids.NodeID]) uint64 // RemoveWeight from a staker. If the staker's weight becomes 0, the staker // will be removed from the validator set. // Returns an error if: // - [weight] is 0 // - [nodeID] is not already in the validator set // - the weight of the validator would become negative // If an error is returned, the set will be unmodified. RemoveWeight(nodeID ids.NodeID, weight uint64) error // Contains returns true if there is a validator with the specified ID // currently in the set. Contains(ids.NodeID) bool // Len returns the number of validators currently in the set. Len() int // List all the validators in this group List() []*Validator // Weight returns the cumulative weight of all validators in the set. Weight() uint64 // Sample returns a collection of validatorIDs, potentially with duplicates. // If sampling the requested size isn't possible, an error will be returned. Sample(size int) ([]ids.NodeID, error) // When a validator's weight changes, or a validator is added/removed, // this listener is called. RegisterCallbackListener(SetCallbackListener) }
Set of validators that can be sampled
func NewBestSet ¶
NewBestSet returns a new, empty set of validators.
type SetCallbackListener ¶
type State ¶
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) // 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) }
State allows the lookup of validator sets on specified subnets at the requested P-chain height.
func NewNoValidatorsState ¶
type SubnetConnector ¶ added in v1.8.7
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 ¶
type TestState struct { T *testing.T CantGetMinimumHeight, CantGetCurrentHeight, CantGetValidatorSet bool GetMinimumHeightF func(ctx context.Context) (uint64, error) GetCurrentHeightF func(ctx context.Context) (uint64, error) GetValidatorSetF func(ctx context.Context, height uint64, subnetID ids.ID) (map[ids.NodeID]*GetValidatorOutput, error) }