upstreams

package
v0.0.0-...-da4b772 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareAggregatedLabels

func CompareAggregatedLabels(a, b []AggregatedLabels) bool

func CreateBlockEventProcessor

func CreateBlockEventProcessor(
	ctx context.Context,
	conf *config.Upstream,
	requestConnector connectors.ApiConnector,
	chainSpecific specific.ChainSpecific,
	configuredChain *chains.ConfiguredChain,
) event_processors.UpstreamStateEventProcessor

func CreateHeadEventProcessor

func CreateHeadEventProcessor(
	ctx context.Context,
	conf *config.Upstream,
	headConnector connectors.ApiConnector,
	chainSpecific specific.ChainSpecific,
	chain chains.Chain,
) event_processors.UpstreamStateEventProcessor

Types

type AddChainSupervisorEvent

type AddChainSupervisorEvent struct {
	ChainSupervisor ChainSupervisor
}

type AggregatedLabels

type AggregatedLabels struct {
	Amount int
	Labels map[string]string
}

func NewAggregatedLabels

func NewAggregatedLabels(amount int, labels map[string]string) AggregatedLabels

func (AggregatedLabels) Equals

func (a AggregatedLabels) Equals(other AggregatedLabels) bool

type BaseChainSupervisor

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

func (*BaseChainSupervisor) GetChain

func (b *BaseChainSupervisor) GetChain() chains.Chain

func (*BaseChainSupervisor) GetChainState

func (b *BaseChainSupervisor) GetChainState() ChainSupervisorState

func (*BaseChainSupervisor) GetMethod

func (b *BaseChainSupervisor) GetMethod(methodName string) *specs.Method

func (*BaseChainSupervisor) GetMethods

func (b *BaseChainSupervisor) GetMethods() []string

func (*BaseChainSupervisor) GetSortedUpstreamIds

func (b *BaseChainSupervisor) GetSortedUpstreamIds(filterFunc FilterUpstream, sortFunc SortUpstream) []string

func (*BaseChainSupervisor) GetUpstreamIds

func (b *BaseChainSupervisor) GetUpstreamIds() []string

func (*BaseChainSupervisor) GetUpstreamState

func (b *BaseChainSupervisor) GetUpstreamState(upstreamId string) *protocol.UpstreamState

func (*BaseChainSupervisor) PublishUpstreamEvent

func (b *BaseChainSupervisor) PublishUpstreamEvent(event protocol.UpstreamEvent)

func (*BaseChainSupervisor) Start

func (b *BaseChainSupervisor) Start()

func (*BaseChainSupervisor) SubscribeState

type BaseUpstream

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

func NewBaseUpstream

func NewBaseUpstream(
	ctx context.Context,
	cancelFunc context.CancelFunc,
	conf *config.Upstream,
	configuredChain *chains.ConfiguredChain,
	upstreamIndex int,
	creationData *upstreamCreationData,
	processorAggregator *event_processors.UpstreamProcessorAggregator,
) (*BaseUpstream, error)

func NewBaseUpstreamWithParams

func NewBaseUpstreamWithParams(
	id string,
	chain chains.Chain,
	apiConnectors []connectors.ApiConnector,
	upConfig *config.Upstream,
	index string,
	upState *utils.Atomic[protocol.UpstreamState],
	processorAggregator *event_processors.UpstreamProcessorAggregator,
	stateChan *chan protocol.AbstractUpstreamStateEvent,
	emitter *event_processors.Emitter,
) *BaseUpstream

func (*BaseUpstream) BanMethod

func (u *BaseUpstream) BanMethod(method string)

func (*BaseUpstream) GetChain

func (u *BaseUpstream) GetChain() chains.Chain

func (*BaseUpstream) GetConnector

func (u *BaseUpstream) GetConnector(connectorType protocol.ApiConnectorType) connectors.ApiConnector

func (*BaseUpstream) GetHashIndex

func (u *BaseUpstream) GetHashIndex() string

func (*BaseUpstream) GetId

func (u *BaseUpstream) GetId() string

func (*BaseUpstream) GetUpstreamState

func (u *BaseUpstream) GetUpstreamState() protocol.UpstreamState

func (*BaseUpstream) GetVendorType

func (u *BaseUpstream) GetVendorType() UpstreamVendor

func (*BaseUpstream) PartialStop

func (u *BaseUpstream) PartialStop()

func (*BaseUpstream) Resume

func (u *BaseUpstream) Resume()

func (*BaseUpstream) Running

func (u *BaseUpstream) Running() bool

func (*BaseUpstream) Start

func (u *BaseUpstream) Start()

func (*BaseUpstream) Stop

func (u *BaseUpstream) Stop()

func (*BaseUpstream) Subscribe

func (*BaseUpstream) UpdateBlock

func (u *BaseUpstream) UpdateBlock(block protocol.Block, blockType protocol.BlockType)

func (*BaseUpstream) UpdateHead

func (u *BaseUpstream) UpdateHead(height, slot uint64)

type BaseUpstreamSupervisor

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

func (*BaseUpstreamSupervisor) GetChainSupervisor

func (b *BaseUpstreamSupervisor) GetChainSupervisor(chain chains.Chain) ChainSupervisor

func (*BaseUpstreamSupervisor) GetChainSupervisors

func (b *BaseUpstreamSupervisor) GetChainSupervisors() []ChainSupervisor

func (*BaseUpstreamSupervisor) GetExecutor

func (*BaseUpstreamSupervisor) GetUpstream

func (b *BaseUpstreamSupervisor) GetUpstream(upstreamId string) Upstream

func (*BaseUpstreamSupervisor) StartUpstreams

func (b *BaseUpstreamSupervisor) StartUpstreams()

func (*BaseUpstreamSupervisor) SubscribeChainSupervisor

func (b *BaseUpstreamSupervisor) SubscribeChainSupervisor(name string) *utils.Subscription[ChainSupervisorEvent]

type BlocksWrapper

type BlocksWrapper struct {
	Blocks map[protocol.BlockType]protocol.Block
}

func NewBlocksWrapper

func NewBlocksWrapper(blocks map[protocol.BlockType]protocol.Block) *BlocksWrapper

type ChainHeadData

type ChainHeadData struct {
	Head       protocol.Block
	UpstreamId string
}

func NewChainHeadData

func NewChainHeadData(head protocol.Block, upstreamId string) ChainHeadData

func (ChainHeadData) IsEmpty

func (c ChainHeadData) IsEmpty() bool

type ChainSupervisor

type ChainSupervisor interface {
	Start()

	GetChain() chains.Chain
	GetChainState() ChainSupervisorState
	GetMethod(methodName string) *specs.Method
	GetMethods() []string
	GetUpstreamState(upstreamId string) *protocol.UpstreamState
	GetSortedUpstreamIds(filterFunc FilterUpstream, sortFunc SortUpstream) []string
	GetUpstreamIds() []string

	PublishUpstreamEvent(event protocol.UpstreamEvent)
	SubscribeState(name string) *utils.Subscription[*ChainSupervisorStateWrapperEvent]
}

type ChainSupervisorEvent

type ChainSupervisorEvent interface {
	// contains filtered or unexported methods
}

type ChainSupervisorState

type ChainSupervisorState struct {
	Status      protocol.AvailabilityStatus
	HeadData    ChainHeadData
	Methods     methods.Methods
	Blocks      map[protocol.BlockType]protocol.Block
	LowerBounds map[protocol.LowerBoundType]protocol.LowerBoundData
	ChainLabels []AggregatedLabels
	SubMethods  mapset.Set[string]
}

func (ChainSupervisorState) Compare

type ChainSupervisorStateWrapper

type ChainSupervisorStateWrapper interface {
	// contains filtered or unexported methods
}

type ChainSupervisorStateWrapperEvent

type ChainSupervisorStateWrapperEvent struct {
	Wrappers []ChainSupervisorStateWrapper
}

type FilterUpstream

type FilterUpstream func(id string, state *protocol.UpstreamState) bool

type HeadWrapper

type HeadWrapper struct {
	Head protocol.Block
}

func NewHeadWrapper

func NewHeadWrapper(head protocol.Block) *HeadWrapper

type LabelsWrapper

type LabelsWrapper struct {
	Labels []AggregatedLabels
}

func NewLabelsWrapper

func NewLabelsWrapper(labels []AggregatedLabels) *LabelsWrapper

type LowerBoundsWrapper

type LowerBoundsWrapper struct {
	LowerBounds []protocol.LowerBoundData
}

func NewLowerBoundsWrapper

func NewLowerBoundsWrapper(lowerBounds []protocol.LowerBoundData) *LowerBoundsWrapper

type MethodsWrapper

type MethodsWrapper struct {
	Methods []string
}

func NewMethodsWrapper

func NewMethodsWrapper(methods []string) *MethodsWrapper

type SortUpstream

type SortUpstream func(entry1, entry2 lo.Tuple2[string, *protocol.UpstreamState]) int

type StatusWrapper

type StatusWrapper struct {
	Status protocol.AvailabilityStatus
}

func NewStatusWrapper

func NewStatusWrapper(status protocol.AvailabilityStatus) *StatusWrapper

type SubMethodsWrapper

type SubMethodsWrapper struct {
	SubMethods []string
}

func NewSubMethodsWrapper

func NewSubMethodsWrapper(subMethods []string) *SubMethodsWrapper

type Upstream

type Upstream interface {
	Start()
	Resume()
	PartialStop()
	Stop()
	Running() bool

	Subscribe(name string) *utils.Subscription[protocol.UpstreamEvent]

	GetId() string
	GetChain() chains.Chain
	GetVendorType() UpstreamVendor
	GetUpstreamState() protocol.UpstreamState
	GetConnector(connectorType protocol.ApiConnectorType) connectors.ApiConnector
	GetHashIndex() string

	UpdateHead(height, slot uint64)
	UpdateBlock(block protocol.Block, blockType protocol.BlockType)
	BanMethod(method string)
}

func CreateUpstream

func CreateUpstream(
	ctx context.Context,
	conf *config.Upstream,
	tracker dimensions.DimensionTracker,
	statsService UpstreamStatsService,
	executor failsafe.Executor[protocol.ResponseHolder],
	upstreamIndex int,
	rateLimitBudgetRegistry *ratelimiter.RateLimitBudgetRegistry,
	torProxyUrl string,
) (Upstream, error)

type UpstreamStatsService

type UpstreamStatsService interface {
	AddRequestResults(requestResults []protocol.RequestResult)
}

type UpstreamSupervisor

type UpstreamSupervisor interface {
	GetChainSupervisor(chain chains.Chain) ChainSupervisor
	GetChainSupervisors() []ChainSupervisor
	GetUpstream(string) Upstream
	GetExecutor() failsafe.Executor[*protocol.ResponseHolderWrapper]
	StartUpstreams()

	SubscribeChainSupervisor(name string) *utils.Subscription[ChainSupervisorEvent]
}

func NewBaseUpstreamSupervisor

func NewBaseUpstreamSupervisor(
	ctx context.Context,
	upstreamsConfig *config.UpstreamConfig,
	tracker dimensions.DimensionTracker,
	statsService UpstreamStatsService,
	rateLimitBudgetRegistry *ratelimiter.RateLimitBudgetRegistry,
	torProxyUrl string,
) UpstreamSupervisor

type UpstreamVendor

type UpstreamVendor int
const (
	Unknown UpstreamVendor = iota
	QuickNode
	DRPC
	Alchemy
	Infura
)

func DetectUpstreamVendor

func DetectUpstreamVendor(urls []string) UpstreamVendor

Jump to

Keyboard shortcuts

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