Documentation ¶
Overview ¶
Package validators is a generated GoMock package.
Package validators is a generated GoMock package.
Index ¶
- Variables
- type Connector
- type GetValidatorOutput
- type Manager
- type ManagerCallbackListener
- 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) GetSupernetID(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)
- type MockStateMockRecorder
- func (mr *MockStateMockRecorder) GetCurrentHeight(arg0 any) *gomock.Call
- func (mr *MockStateMockRecorder) GetMinimumHeight(arg0 any) *gomock.Call
- func (mr *MockStateMockRecorder) GetSupernetID(arg0, arg1 any) *gomock.Call
- func (mr *MockStateMockRecorder) GetValidatorSet(arg0, arg1, arg2 any) *gomock.Call
- type MockSupernetConnector
- type MockSupernetConnectorMockRecorder
- type SetCallbackListener
- type State
- type SupernetConnector
- type TestState
- func (vm *TestState) GetCurrentHeight(ctx context.Context) (uint64, error)
- func (vm *TestState) GetMinimumHeight(ctx context.Context) (uint64, error)
- func (vm *TestState) GetSupernetID(ctx context.Context, chainID ids.ID) (ids.ID, error)
- func (vm *TestState) GetValidatorSet(ctx context.Context, height uint64, supernetID ids.ID) (map[ids.NodeID]*GetValidatorOutput, 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 ¶
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 ¶
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 supernet. // 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(supernetID ids.ID, nodeID ids.NodeID, pk *bls.PublicKey, txID ids.ID, weight uint64) error // AddWeight to an existing staker to the supernet. // 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(supernetID ids.ID, nodeID ids.NodeID, weight uint64) error // GetWeight retrieves the validator weight from the supernet. GetWeight(supernetID ids.ID, nodeID ids.NodeID) uint64 // GetValidator returns the validator tied to the specified ID in supernet. // If the validator doesn't exist, returns false. GetValidator(supernetID ids.ID, nodeID ids.NodeID) (*Validator, bool) // GetValidatoIDs returns the validator IDs in the supernet. GetValidatorIDs(supernetID ids.ID) []ids.NodeID // SubsetWeight returns the sum of the weights of the validators in the supernet. // Returns err if subset weight overflows uint64. SubsetWeight(supernetID ids.ID, validatorIDs set.Set[ids.NodeID]) (uint64, error) // RemoveWeight from a staker in the supernet. If the staker's weight becomes 0, the staker // will be removed from the supernet set. // Returns an error if: // - [weight] is 0 // - [nodeID] is not already in the supernet set // - the weight of the validator would become negative // If an error is returned, the set will be unmodified. RemoveWeight(supernetID ids.ID, nodeID ids.NodeID, weight uint64) error // Count returns the number of validators currently in the supernet. Count(supernetID ids.ID) int // TotalWeight returns the cumulative weight of all validators in the supernet. // Returns err if total weight overflows uint64. TotalWeight(supernetID ids.ID) (uint64, error) // Sample returns a collection of validatorIDs in the supernet, potentially with duplicates. // If sampling the requested size isn't possible, an error will be returned. Sample(supernetID ids.ID, size int) ([]ids.NodeID, error) // Map of the validators in this supernet GetMap(supernetID ids.ID) map[ids.NodeID]*GetValidatorOutput // When a validator is added, removed, or its weight changes, the listener // will be notified of the event. RegisterCallbackListener(listener ManagerCallbackListener) // When a validator is added, removed, or its weight changes on [supernetID], // the listener will be notified of the event. RegisterSetCallbackListener(supernetID ids.ID, listener SetCallbackListener) }
Manager holds the validator set of each supernet
type ManagerCallbackListener ¶
type ManagerCallbackListener interface { OnValidatorAdded(supernetID ids.ID, nodeID ids.NodeID, pk *bls.PublicKey, txID ids.ID, weight uint64) OnValidatorRemoved(supernetID ids.ID, nodeID ids.NodeID, weight uint64) OnValidatorWeightChanged(supernetID ids.ID, nodeID ids.NodeID, oldWeight, newWeight uint64) }
type MockState ¶
type MockState struct {
// contains filtered or unexported fields
}
MockState is a mock of State interface.
func NewMockState ¶
func NewMockState(ctrl *gomock.Controller) *MockState
NewMockState creates a new mock instance.
func (*MockState) EXPECT ¶
func (m *MockState) EXPECT() *MockStateMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockState) GetCurrentHeight ¶
GetCurrentHeight mocks base method.
func (*MockState) GetMinimumHeight ¶
GetMinimumHeight mocks base method.
func (*MockState) GetSupernetID ¶
GetSupernetID mocks base method.
type MockStateMockRecorder ¶
type MockStateMockRecorder struct {
// contains filtered or unexported fields
}
MockStateMockRecorder is the mock recorder for MockState.
func (*MockStateMockRecorder) GetCurrentHeight ¶
func (mr *MockStateMockRecorder) GetCurrentHeight(arg0 any) *gomock.Call
GetCurrentHeight indicates an expected call of GetCurrentHeight.
func (*MockStateMockRecorder) GetMinimumHeight ¶
func (mr *MockStateMockRecorder) GetMinimumHeight(arg0 any) *gomock.Call
GetMinimumHeight indicates an expected call of GetMinimumHeight.
func (*MockStateMockRecorder) GetSupernetID ¶
func (mr *MockStateMockRecorder) GetSupernetID(arg0, arg1 any) *gomock.Call
GetSupernetID indicates an expected call of GetSupernetID.
func (*MockStateMockRecorder) GetValidatorSet ¶
func (mr *MockStateMockRecorder) GetValidatorSet(arg0, arg1, arg2 any) *gomock.Call
GetValidatorSet indicates an expected call of GetValidatorSet.
type MockSupernetConnector ¶
type MockSupernetConnector struct {
// contains filtered or unexported fields
}
MockSupernetConnector is a mock of SupernetConnector interface.
func NewMockSupernetConnector ¶
func NewMockSupernetConnector(ctrl *gomock.Controller) *MockSupernetConnector
NewMockSupernetConnector creates a new mock instance.
func (*MockSupernetConnector) ConnectedSupernet ¶
func (m *MockSupernetConnector) ConnectedSupernet(arg0 context.Context, arg1 ids.NodeID, arg2 ids.ID) error
ConnectedSupernet mocks base method.
func (*MockSupernetConnector) EXPECT ¶
func (m *MockSupernetConnector) EXPECT() *MockSupernetConnectorMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockSupernetConnectorMockRecorder ¶
type MockSupernetConnectorMockRecorder struct {
// contains filtered or unexported fields
}
MockSupernetConnectorMockRecorder is the mock recorder for MockSupernetConnector.
func (*MockSupernetConnectorMockRecorder) ConnectedSupernet ¶
func (mr *MockSupernetConnectorMockRecorder) ConnectedSupernet(arg0, arg1, arg2 any) *gomock.Call
ConnectedSupernet indicates an expected call of ConnectedSupernet.
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) // GetSupernetID returns the supernetID of the provided chain. GetSupernetID(ctx context.Context, chainID ids.ID) (ids.ID, error) // GetValidatorSet returns the validators of the provided supernet at the // requested P-chain height. // The returned map should not be modified. GetValidatorSet( ctx context.Context, height uint64, supernetID ids.ID, ) (map[ids.NodeID]*GetValidatorOutput, error) }
State allows the lookup of validator sets on specified supernets at the requested P-chain height.
func NewNoValidatorsState ¶
type SupernetConnector ¶
type SupernetConnector interface {
ConnectedSupernet(ctx context.Context, nodeID ids.NodeID, supernetID ids.ID) error
}
SupernetConnector represents a handler that is called when a connection is marked as connected to a supernet
var UnhandledSupernetConnector SupernetConnector = &unhandledSupernetConnector{}
type TestState ¶
type TestState struct { T testing.TB CantGetMinimumHeight, CantGetCurrentHeight, CantGetSupernetID, CantGetValidatorSet bool GetMinimumHeightF func(ctx context.Context) (uint64, error) GetCurrentHeightF func(ctx context.Context) (uint64, error) GetSupernetIDF func(ctx context.Context, chainID ids.ID) (ids.ID, error) GetValidatorSetF func(ctx context.Context, height uint64, supernetID ids.ID) (map[ids.NodeID]*GetValidatorOutput, error) }