Documentation
¶
Overview ¶
Package vms provides a clean, generic handler delegation system for VM wrappers. This follows Go's philosophy of simple, composable interfaces with clear semantics.
Package vms is a generated GoMock package.
Index ¶
- Variables
- func DelegateHandlers(ctx context.Context, vm any) (map[string]http.Handler, error)
- func DelegateStaticHandlers(ctx context.Context, vm any) (map[string]http.Handler, error)
- func ExampleUsage()
- type ExampleCChainVM
- type ExampleVMWrapper
- type Factory
- type HandlerDelegator
- type HandlerProvider
- type Manager
- type MockFactory
- type MockFactoryMockRecorder
- type MockManager
- func (m *MockManager) Alias(arg0 ids.ID, arg1 string) error
- func (m *MockManager) Aliases(arg0 ids.ID) ([]string, error)
- func (m *MockManager) EXPECT() *MockManagerMockRecorder
- func (m *MockManager) GetFactory(arg0 ids.ID) (Factory, error)
- func (m *MockManager) ListFactories() ([]ids.ID, error)
- func (m *MockManager) Lookup(arg0 string) (ids.ID, error)
- func (m *MockManager) PrimaryAlias(arg0 ids.ID) (string, error)
- func (m *MockManager) PrimaryAliasOrDefault(arg0 ids.ID) string
- func (m *MockManager) RegisterFactory(arg0 context.Context, arg1 ids.ID, arg2 Factory) error
- func (m *MockManager) RemoveAliases(arg0 ids.ID)
- func (m *MockManager) Versions() (map[string]string, error)
- type MockManagerMockRecorder
- func (mr *MockManagerMockRecorder) Alias(arg0, arg1 any) *gomock.Call
- func (mr *MockManagerMockRecorder) Aliases(arg0 any) *gomock.Call
- func (mr *MockManagerMockRecorder) GetFactory(arg0 any) *gomock.Call
- func (mr *MockManagerMockRecorder) ListFactories() *gomock.Call
- func (mr *MockManagerMockRecorder) Lookup(arg0 any) *gomock.Call
- func (mr *MockManagerMockRecorder) PrimaryAlias(arg0 any) *gomock.Call
- func (mr *MockManagerMockRecorder) PrimaryAliasOrDefault(arg0 any) *gomock.Call
- func (mr *MockManagerMockRecorder) RegisterFactory(arg0, arg1, arg2 any) *gomock.Call
- func (mr *MockManagerMockRecorder) RemoveAliases(arg0 any) *gomock.Call
- func (mr *MockManagerMockRecorder) Versions() *gomock.Call
- type StaticHandlerProvider
Constants ¶
This section is empty.
Variables ¶
var (
ErrNotFound = errors.New("not found")
)
Functions ¶
func DelegateHandlers ¶ added in v1.17.2
DelegateHandlers is a helper function that checks if a VM implements HandlerProvider and calls CreateHandlers if it does. This is for when you don't need a full delegator, just a one-off check.
func DelegateStaticHandlers ¶ added in v1.17.2
DelegateStaticHandlers is a helper function that checks if a VM implements StaticHandlerProvider and calls CreateStaticHandlers if it does.
func ExampleUsage ¶ added in v1.17.2
func ExampleUsage()
ExampleUsage demonstrates the pattern in action
Types ¶
type ExampleCChainVM ¶ added in v1.17.2
type ExampleCChainVM struct {
// contains filtered or unexported fields
}
ExampleCChainVM represents a C-Chain VM that provides RPC handlers
func (*ExampleCChainVM) CreateHandlers ¶ added in v1.17.2
CreateHandlers returns the C-Chain's RPC handlers
type ExampleVMWrapper ¶ added in v1.17.2
type ExampleVMWrapper struct {
*HandlerDelegator[interface{}]
// contains filtered or unexported fields
}
ExampleVMWrapper demonstrates how any wrapper can use HandlerDelegator This could be metervm, proposervm, or any custom wrapper.
func NewExampleVMWrapper ¶ added in v1.17.2
func NewExampleVMWrapper(innerVM interface{}) *ExampleVMWrapper
NewExampleVMWrapper shows the clean factory pattern
func (*ExampleVMWrapper) BuildBlock ¶ added in v1.17.2
func (w *ExampleVMWrapper) BuildBlock(ctx context.Context) error
BuildBlock shows wrapper can focus on its core responsibility
type HandlerDelegator ¶ added in v1.17.2
type HandlerDelegator[T any] struct { // contains filtered or unexported fields }
HandlerDelegator provides a generic way to delegate handler creation to an underlying VM if it supports the HandlerProvider interface. This eliminates duplicate type checking code across VM wrappers.
func NewHandlerDelegator ¶ added in v1.17.2
func NewHandlerDelegator[T any](vm T) *HandlerDelegator[T]
NewHandlerDelegator creates a new handler delegator for any VM type. Simple factory pattern - no complexity, just wrap and go.
func (*HandlerDelegator[T]) CreateHandlers ¶ added in v1.17.2
CreateHandlers delegates to the underlying VM if it implements HandlerProvider. Returns empty map if not supported - fail gracefully, never panic.
func (*HandlerDelegator[T]) CreateStaticHandlers ¶ added in v1.17.2
func (d *HandlerDelegator[T]) CreateStaticHandlers(ctx context.Context) (map[string]http.Handler, error)
CreateStaticHandlers delegates to the underlying VM if it implements StaticHandlerProvider. Returns empty map if not supported - consistent with CreateHandlers behavior.
func (*HandlerDelegator[T]) VM ¶ added in v1.17.2
func (d *HandlerDelegator[T]) VM() T
VM returns the underlying VM for direct access when needed. No hiding - transparency is a virtue.
type HandlerProvider ¶ added in v1.17.2
HandlerProvider defines the interface for VMs that can provide HTTP handlers. This is the single source of truth for handler-providing VMs.
type Manager ¶
type Manager interface {
ids.Aliaser
// Return a factory that can create new instances of the vm whose ID is
// [vmID]
GetFactory(vmID ids.ID) (Factory, error)
// Map [vmID] to [factory]. [factory] creates new instances of the vm whose
// ID is [vmID]
RegisterFactory(ctx context.Context, vmID ids.ID, factory Factory) error
// ListFactories returns all the IDs that have had factories registered.
ListFactories() ([]ids.ID, error)
// Versions returns the primary alias of the VM mapped to the reported
// version of the VM for all the registered VMs that reported versions.
Versions() (map[string]string, error)
}
Manager tracks a collection of VM factories, their aliases, and their versions. It has the following functionality:
- Register a VM factory. To register a VM is to associate its ID with a VMFactory which, when New() is called upon it, creates a new instance of that VM.
- Get a VM factory. Given the ID of a VM that has been registered, return the factory that the ID is associated with.
- Manage the aliases of VMs
- Manage the versions of VMs
type MockFactory ¶ added in v1.1.11
type MockFactory struct {
// contains filtered or unexported fields
}
MockFactory is a mock of Factory interface.
func NewMockFactory ¶ added in v1.1.11
func NewMockFactory(ctrl *gomock.Controller) *MockFactory
NewMockFactory creates a new mock instance.
func (*MockFactory) EXPECT ¶ added in v1.1.11
func (m *MockFactory) EXPECT() *MockFactoryMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockFactoryMockRecorder ¶ added in v1.1.11
type MockFactoryMockRecorder struct {
// contains filtered or unexported fields
}
MockFactoryMockRecorder is the mock recorder for MockFactory.
type MockManager ¶ added in v1.1.11
type MockManager struct {
// contains filtered or unexported fields
}
MockManager is a mock of Manager interface.
func NewMockManager ¶ added in v1.1.11
func NewMockManager(ctrl *gomock.Controller) *MockManager
NewMockManager creates a new mock instance.
func (*MockManager) Alias ¶ added in v1.1.11
func (m *MockManager) Alias(arg0 ids.ID, arg1 string) error
Alias mocks base method.
func (*MockManager) Aliases ¶ added in v1.1.11
func (m *MockManager) Aliases(arg0 ids.ID) ([]string, error)
Aliases mocks base method.
func (*MockManager) EXPECT ¶ added in v1.1.11
func (m *MockManager) EXPECT() *MockManagerMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockManager) GetFactory ¶ added in v1.1.11
func (m *MockManager) GetFactory(arg0 ids.ID) (Factory, error)
GetFactory mocks base method.
func (*MockManager) ListFactories ¶ added in v1.1.11
func (m *MockManager) ListFactories() ([]ids.ID, error)
ListFactories mocks base method.
func (*MockManager) Lookup ¶ added in v1.1.11
func (m *MockManager) Lookup(arg0 string) (ids.ID, error)
Lookup mocks base method.
func (*MockManager) PrimaryAlias ¶ added in v1.1.11
func (m *MockManager) PrimaryAlias(arg0 ids.ID) (string, error)
PrimaryAlias mocks base method.
func (*MockManager) PrimaryAliasOrDefault ¶ added in v1.1.11
func (m *MockManager) PrimaryAliasOrDefault(arg0 ids.ID) string
PrimaryAliasOrDefault mocks base method.
func (*MockManager) RegisterFactory ¶ added in v1.1.11
RegisterFactory mocks base method.
func (*MockManager) RemoveAliases ¶ added in v1.1.11
func (m *MockManager) RemoveAliases(arg0 ids.ID)
RemoveAliases mocks base method.
type MockManagerMockRecorder ¶ added in v1.1.11
type MockManagerMockRecorder struct {
// contains filtered or unexported fields
}
MockManagerMockRecorder is the mock recorder for MockManager.
func (*MockManagerMockRecorder) Alias ¶ added in v1.1.11
func (mr *MockManagerMockRecorder) Alias(arg0, arg1 any) *gomock.Call
Alias indicates an expected call of Alias.
func (*MockManagerMockRecorder) Aliases ¶ added in v1.1.11
func (mr *MockManagerMockRecorder) Aliases(arg0 any) *gomock.Call
Aliases indicates an expected call of Aliases.
func (*MockManagerMockRecorder) GetFactory ¶ added in v1.1.11
func (mr *MockManagerMockRecorder) GetFactory(arg0 any) *gomock.Call
GetFactory indicates an expected call of GetFactory.
func (*MockManagerMockRecorder) ListFactories ¶ added in v1.1.11
func (mr *MockManagerMockRecorder) ListFactories() *gomock.Call
ListFactories indicates an expected call of ListFactories.
func (*MockManagerMockRecorder) Lookup ¶ added in v1.1.11
func (mr *MockManagerMockRecorder) Lookup(arg0 any) *gomock.Call
Lookup indicates an expected call of Lookup.
func (*MockManagerMockRecorder) PrimaryAlias ¶ added in v1.1.11
func (mr *MockManagerMockRecorder) PrimaryAlias(arg0 any) *gomock.Call
PrimaryAlias indicates an expected call of PrimaryAlias.
func (*MockManagerMockRecorder) PrimaryAliasOrDefault ¶ added in v1.1.11
func (mr *MockManagerMockRecorder) PrimaryAliasOrDefault(arg0 any) *gomock.Call
PrimaryAliasOrDefault indicates an expected call of PrimaryAliasOrDefault.
func (*MockManagerMockRecorder) RegisterFactory ¶ added in v1.1.11
func (mr *MockManagerMockRecorder) RegisterFactory(arg0, arg1, arg2 any) *gomock.Call
RegisterFactory indicates an expected call of RegisterFactory.
func (*MockManagerMockRecorder) RemoveAliases ¶ added in v1.1.11
func (mr *MockManagerMockRecorder) RemoveAliases(arg0 any) *gomock.Call
RemoveAliases indicates an expected call of RemoveAliases.
func (*MockManagerMockRecorder) Versions ¶ added in v1.1.11
func (mr *MockManagerMockRecorder) Versions() *gomock.Call
Versions indicates an expected call of Versions.
type StaticHandlerProvider ¶ added in v1.17.2
type StaticHandlerProvider interface {
HandlerProvider
CreateStaticHandlers(context.Context) (map[string]http.Handler, error)
}
StaticHandlerProvider extends HandlerProvider with static handlers.
Directories
¶
| Path | Synopsis |
|---|---|
|
block
Package block is a generated GoMock package.
|
Package block is a generated GoMock package. |
|
block/executor/executormock
Package executormock is a generated GoMock package.
|
Package executormock is a generated GoMock package. |
|
metrics/metricsmock
Package metricsmock is a generated GoMock package.
|
Package metricsmock is a generated GoMock package. |
|
state/statemock
Package statemock is a generated GoMock package.
|
Package statemock is a generated GoMock package. |
|
txs/txsmock
Package txsmock is a generated GoMock package.
|
Package txsmock is a generated GoMock package. |
|
Database key format helpers for both SubnetEVM and geth formats
|
Database key format helpers for both SubnetEVM and geth formats |
|
components
|
|
|
avax/avaxmock
Package avaxmock is a generated GoMock package.
|
Package avaxmock is a generated GoMock package. |
|
gas
The gas package implements dynamic gas pricing specified in LP-103: https://github.com/luxfi/LPs/tree/main/LPs/103-dynamic-fees
|
The gas package implements dynamic gas pricing specified in LP-103: https://github.com/luxfi/LPs/tree/main/LPs/103-dynamic-fees |
|
lux
Package lux is a generated GoMock package.
|
Package lux is a generated GoMock package. |
|
luxmock
Package luxmock is a generated GoMock package.
|
Package luxmock is a generated GoMock package. |
|
verify
Package verify is a generated GoMock package.
|
Package verify is a generated GoMock package. |
|
verify/verifymock
Package verifymock is a generated GoMock package.
|
Package verifymock is a generated GoMock package. |
|
evm
|
|
|
acp176
ACP176 implements the fee logic specified here: https://github.com/avalanche-foundation/ACPs/blob/main/ACPs/176-dynamic-evm-gas-limit-and-price-discovery-updates/README.md
|
ACP176 implements the fee logic specified here: https://github.com/avalanche-foundation/ACPs/blob/main/ACPs/176-dynamic-evm-gas-limit-and-price-discovery-updates/README.md |
|
acp226
ACP-226 implements the dynamic minimum block delay mechanism specified here: https://github.com/avalanche-foundation/ACPs/blob/main/ACPs/226-dynamic-minimum-block-times/README.md
|
ACP-226 implements the dynamic minimum block delay mechanism specified here: https://github.com/avalanche-foundation/ACPs/blob/main/ACPs/226-dynamic-minimum-block-times/README.md |
|
lp176
LP176 implements the fee logic specified here: https://github.com/luxfi/lps/blob/main/LPs/176-dynamic-evm-gas-limit-and-price-discovery-updates/README.md
|
LP176 implements the fee logic specified here: https://github.com/luxfi/lps/blob/main/LPs/176-dynamic-evm-gas-limit-and-price-discovery-updates/README.md |
|
lp226
LP-226 implements the dynamic minimum block delay mechanism specified here: https://github.com/luxfi/lps/blob/main/LPs/226-dynamic-minimum-block-times/README.md
|
LP-226 implements the dynamic minimum block delay mechanism specified here: https://github.com/luxfi/lps/blob/main/LPs/226-dynamic-minimum-block-times/README.md |
|
example
|
|
|
xsvm/cmd/xsvm
command
|
|
|
block
Package block is a generated GoMock package.
|
Package block is a generated GoMock package. |
|
block/executor
Package executor is a generated GoMock package.
|
Package executor is a generated GoMock package. |
|
block/executor/executormock
Package executormock is a generated GoMock package.
|
Package executormock is a generated GoMock package. |
|
fx
Package fx is a generated GoMock package.
|
Package fx is a generated GoMock package. |
|
fx/fxmock
Package fxmock is a generated GoMock package.
|
Package fxmock is a generated GoMock package. |
|
signer/signermock
Package signermock is a generated GoMock package.
|
Package signermock is a generated GoMock package. |
|
state
Package state is a generated GoMock package.
|
Package state is a generated GoMock package. |
|
testcontext
Package testcontext provides a test context for platformvm tests
|
Package testcontext provides a test context for platformvm tests |
|
txs
Package txs is a generated GoMock package.
|
Package txs is a generated GoMock package. |
|
txs/builder
Package builder is a generated GoMock package.
|
Package builder is a generated GoMock package. |
|
txs/fee
compliance.
|
compliance. |
|
txs/mempool
Package mempool is a generated GoMock package.
|
Package mempool is a generated GoMock package. |
|
utxo
Package utxo is a generated GoMock package.
|
Package utxo is a generated GoMock package. |
|
utxo/utxomock
Package utxomock is a generated GoMock package.
|
Package utxomock is a generated GoMock package. |
|
Package proposervm is a generated GoMock package.
|
Package proposervm is a generated GoMock package. |
|
proposer
Package proposer is a generated GoMock package.
|
Package proposer is a generated GoMock package. |
|
proposer/proposermock
Package proposermock is a generated GoMock package.
|
Package proposermock is a generated GoMock package. |
|
scheduler
Package scheduler is a generated GoMock package.
|
Package scheduler is a generated GoMock package. |
|
state
Package state is a generated GoMock package.
|
Package state is a generated GoMock package. |
|
Package registry is a generated GoMock package.
|
Package registry is a generated GoMock package. |
|
registrymock
Package registrymock is a generated GoMock package.
|
Package registrymock is a generated GoMock package. |
|
txs
|
|
|
Package vmsmock is a generated GoMock package.
|
Package vmsmock is a generated GoMock package. |
|
block
Package block is a generated GoMock package.
|
Package block is a generated GoMock package. |
|
block/executor
Package executor is a generated GoMock package.
|
Package executor is a generated GoMock package. |
|
block/executor/executormock
Package executormock is a generated GoMock package.
|
Package executormock is a generated GoMock package. |
|
metrics
Package metrics is a generated GoMock package.
|
Package metrics is a generated GoMock package. |
|
metrics/metricsmock
Package metricsmock is a generated GoMock package.
|
Package metricsmock is a generated GoMock package. |
|
state
Package state is a generated GoMock package.
|
Package state is a generated GoMock package. |
|
state/statemock
Package statemock is a generated GoMock package.
|
Package statemock is a generated GoMock package. |
|
txs
Package txs is a generated GoMock package.
|
Package txs is a generated GoMock package. |
|
txs/mempool
Package mempool is a generated GoMock package.
|
Package mempool is a generated GoMock package. |
|
txs/txsmock
Package txsmock is a generated GoMock package.
|
Package txsmock is a generated GoMock package. |