minipool

package
v2.0.0-prerelease3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2024 License: GPL-3.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterMinipoolRoute

func RegisterMinipoolRoute[ContextType IMinipoolCallContext[DataType], DataType any](
	router *mux.Router,
	functionName string,
	factory IMinipoolCallContextFactory[ContextType, DataType],
	ctx context.Context,
	logger *log.Logger,
	serviceProvider *services.ServiceProvider,
)

Registers a new route with the router, which will invoke the provided factory to create and execute the context for the route when it's called; use this for complex calls that will iterate over and query each minipool in the node

Types

type IMinipoolCallContext

type IMinipoolCallContext[DataType any] interface {
	// Initialize the context with any bootstrapping, requirements checks, or bindings it needs to set up
	Initialize() (types.ResponseStatus, error)

	// Used to get any supplemental state required during initialization - anything in here will be fed into an rp.Query() multicall
	GetState(node *node.Node, mc *batch.MultiCaller)

	// Check the initialized state after being queried to see if the response needs to be updated and the query can be ended prematurely
	// Return true if the function should continue, or false if it needs to end and just return the response as-is
	CheckState(node *node.Node, data *DataType) bool

	// Get whatever details of the given minipool are necessary; this will be passed into an rp.BatchQuery call, one run per minipool
	// belonging to the node
	GetMinipoolDetails(mc *batch.MultiCaller, mp minipool.IMinipool, index int)

	// Prepare the response data using all of the provided artifacts
	PrepareData(addresses []common.Address, mps []minipool.IMinipool, data *DataType) (types.ResponseStatus, error)
}

Wrapper for callbacks used by functions that will query all of the node's minipools - they follow this pattern: Create bindings, query the chain, return prematurely if some state isn't correct, query all of the minipools, and process them to populate a response. Structs implementing this will handle the caller-specific functionality.

type IMinipoolCallContextFactory

type IMinipoolCallContextFactory[ContextType IMinipoolCallContext[DataType], DataType any] interface {
	// Create the context for the route
	Create(args url.Values) (ContextType, error)
}

Interface for minipool call context factories - these will be invoked during route handling to create the unique context for the route

type MinipoolHandler

type MinipoolHandler struct {
	// contains filtered or unexported fields
}

func NewMinipoolHandler

func NewMinipoolHandler(logger *log.Logger, ctx context.Context, serviceProvider *services.ServiceProvider) *MinipoolHandler

func (*MinipoolHandler) RegisterRoutes

func (h *MinipoolHandler) RegisterRoutes(router *mux.Router)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL