Documentation ¶
Index ¶
- Constants
- Variables
- type Head
- type MultiNode
- type Node
- type NodeClient
- type NodeConfig
- type NodeSelector
- func NewHighestHeadNodeSelector[CHAIN_ID types.ID, HEAD Head, RPC NodeClient[CHAIN_ID, HEAD]](nodes []Node[CHAIN_ID, HEAD, RPC]) NodeSelector[CHAIN_ID, HEAD, RPC]
- func NewPriorityLevelNodeSelector[CHAIN_ID types.ID, HEAD Head, RPC NodeClient[CHAIN_ID, HEAD]](nodes []Node[CHAIN_ID, HEAD, RPC]) NodeSelector[CHAIN_ID, HEAD, RPC]
- func NewRoundRobinSelector[CHAIN_ID types.ID, HEAD Head, RPC NodeClient[CHAIN_ID, HEAD]](nodes []Node[CHAIN_ID, HEAD, RPC]) NodeSelector[CHAIN_ID, HEAD, RPC]
- func NewTotalDifficultyNodeSelector[CHAIN_ID types.ID, HEAD Head, RPC NodeClient[CHAIN_ID, HEAD]](nodes []Node[CHAIN_ID, HEAD, RPC]) NodeSelector[CHAIN_ID, HEAD, RPC]
- type RPC
- type SendOnlyNode
Constants ¶
View Source
const ( NodeSelectionModeHighestHead = "HighestHead" NodeSelectionModeRoundRobin = "RoundRobin" NodeSelectionModeTotalDifficulty = "TotalDifficulty" NodeSelectionModePriorityLevel = "PriorityLevel" )
View Source
const QueryTimeout = 10 * time.Second
Variables ¶
View Source
var ( // PromMultiNodeRPCNodeStates reports current RPC node state PromMultiNodeRPCNodeStates = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "multi_node_states", Help: "The number of RPC nodes currently in the given state for the given chain", }, []string{"network", "chainId", "state"}) ErroringNodeError = fmt.Errorf("no live nodes available") )
Functions ¶
This section is empty.
Types ¶
type MultiNode ¶
type MultiNode[ CHAIN_ID types.ID, SEQ types.Sequence, ADDR types.Hashable, BLOCK_HASH types.Hashable, TX any, TX_HASH types.Hashable, EVENT any, EVENT_OPS any, TX_RECEIPT types.Receipt[TX_HASH, BLOCK_HASH], FEE feetypes.Fee, HEAD types.Head[BLOCK_HASH], RPC_CLIENT RPC[CHAIN_ID, SEQ, ADDR, BLOCK_HASH, TX, TX_HASH, EVENT, EVENT_OPS, TX_RECEIPT, FEE, HEAD], ] interface { Close() error NodeStates() map[string]string SelectNodeRPC() (RPC_CLIENT, error) BatchCallContextAll(ctx context.Context, b []any) error ConfiguredChainID() CHAIN_ID IsL2() bool // contains filtered or unexported methods }
MultiNode is a generalized multi node client interface that includes methods to interact with different chains. It also handles multiple node RPC connections simultaneously.
func NewMultiNode ¶
func NewMultiNode[ CHAIN_ID types.ID, SEQ types.Sequence, ADDR types.Hashable, BLOCK_HASH types.Hashable, TX any, TX_HASH types.Hashable, EVENT any, EVENT_OPS any, TX_RECEIPT types.Receipt[TX_HASH, BLOCK_HASH], FEE feetypes.Fee, HEAD types.Head[BLOCK_HASH], RPC_CLIENT RPC[CHAIN_ID, SEQ, ADDR, BLOCK_HASH, TX, TX_HASH, EVENT, EVENT_OPS, TX_RECEIPT, FEE, HEAD], ]( logger logger.Logger, selectionMode string, leaseDuration time.Duration, noNewHeadsThreshold time.Duration, nodes []Node[CHAIN_ID, HEAD, RPC_CLIENT], sendonlys []SendOnlyNode[CHAIN_ID, RPC_CLIENT], chainID CHAIN_ID, chainType config.ChainType, chainFamily string, sendOnlyErrorParser func(err error) client.SendTxReturnCode, ) MultiNode[CHAIN_ID, SEQ, ADDR, BLOCK_HASH, TX, TX_HASH, EVENT, EVENT_OPS, TX_RECEIPT, FEE, HEAD, RPC_CLIENT]
type Node ¶
type Node[ CHAIN_ID types.ID, HEAD Head, RPC NodeClient[CHAIN_ID, HEAD], ] interface { // State returns nodeState State() nodeState // StateAndLatest returns nodeState with the latest received block number & total difficulty. StateAndLatest() (nodeState, int64, *utils.Big) // Name is a unique identifier for this node. Name() string String() string RPC() RPC SubscribersCount() int32 UnsubscribeAllExceptAliveLoop() ConfiguredChainID() CHAIN_ID Order() int32 Start(context.Context) error Close() error }
func NewNode ¶
func NewNode[ CHAIN_ID types.ID, HEAD Head, RPC NodeClient[CHAIN_ID, HEAD], ]( nodeCfg NodeConfig, noNewHeadsThreshold time.Duration, lggr logger.Logger, wsuri url.URL, httpuri *url.URL, name string, id int32, chainID CHAIN_ID, nodeOrder int32, rpc RPC, chainFamily string, ) Node[CHAIN_ID, HEAD, RPC]
type NodeClient ¶
type NodeClient[ CHAIN_ID types.ID, HEAD Head, ] interface { DialHTTP() error DisconnectAll() Close() ClientVersion(context.Context) (string, error) SubscribersCount() int32 SetAliveLoopSub(types.Subscription) UnsubscribeAllExceptAliveLoop() // contains filtered or unexported methods }
NodeClient includes all the necessary RPC methods required by a node.
type NodeConfig ¶
type NodeSelector ¶
type NodeSelector[ CHAIN_ID types.ID, HEAD Head, RPC NodeClient[CHAIN_ID, HEAD], ] interface { // Select returns a Node, or nil if none can be selected. // Implementation must be thread-safe. Select() Node[CHAIN_ID, HEAD, RPC] // Name returns the strategy name, e.g. "HighestHead" or "RoundRobin" Name() string }
func NewHighestHeadNodeSelector ¶
func NewHighestHeadNodeSelector[ CHAIN_ID types.ID, HEAD Head, RPC NodeClient[CHAIN_ID, HEAD], ](nodes []Node[CHAIN_ID, HEAD, RPC]) NodeSelector[CHAIN_ID, HEAD, RPC]
func NewPriorityLevelNodeSelector ¶
func NewPriorityLevelNodeSelector[ CHAIN_ID types.ID, HEAD Head, RPC NodeClient[CHAIN_ID, HEAD], ](nodes []Node[CHAIN_ID, HEAD, RPC]) NodeSelector[CHAIN_ID, HEAD, RPC]
func NewRoundRobinSelector ¶
func NewRoundRobinSelector[ CHAIN_ID types.ID, HEAD Head, RPC NodeClient[CHAIN_ID, HEAD], ](nodes []Node[CHAIN_ID, HEAD, RPC]) NodeSelector[CHAIN_ID, HEAD, RPC]
func NewTotalDifficultyNodeSelector ¶
func NewTotalDifficultyNodeSelector[ CHAIN_ID types.ID, HEAD Head, RPC NodeClient[CHAIN_ID, HEAD], ](nodes []Node[CHAIN_ID, HEAD, RPC]) NodeSelector[CHAIN_ID, HEAD, RPC]
type RPC ¶
type RPC[ CHAIN_ID types.ID, SEQ types.Sequence, ADDR types.Hashable, BLOCK_HASH types.Hashable, TX any, TX_HASH types.Hashable, EVENT any, EVENT_OPS any, TX_RECEIPT types.Receipt[TX_HASH, BLOCK_HASH], FEE feetypes.Fee, HEAD types.Head[BLOCK_HASH], ] interface { NodeClient[ CHAIN_ID, HEAD, ] // contains filtered or unexported methods }
RPC includes all the necessary methods for a multi-node client to interact directly with any RPC endpoint.
type SendOnlyNode ¶
type SendOnlyNode[ CHAIN_ID types.ID, RPC sendOnlyClient[CHAIN_ID], ] interface { // Start may attempt to connect to the node, but should only return error for misconfiguration - never for temporary errors. Start(context.Context) error Close() error ConfiguredChainID() CHAIN_ID RPC() RPC String() string // State returns nodeState State() nodeState // Name is a unique identifier for this node. Name() string }
SendOnlyNode represents one node used as a sendonly
func NewSendOnlyNode ¶
func NewSendOnlyNode[ CHAIN_ID types.ID, RPC sendOnlyClient[CHAIN_ID], ]( lggr logger.Logger, httpuri url.URL, name string, chainID CHAIN_ID, rpc RPC, ) SendOnlyNode[CHAIN_ID, RPC]
NewSendOnlyNode returns a new sendonly node
Click to show internal directories.
Click to hide internal directories.