provider

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: Apache-2.0, MIT Imports: 38 Imported by: 0

Documentation

Overview

Package provider defines the basic provider subsystems for observing our networks of interest

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBlockFromDatastoreBlock

func NewBlockFromDatastoreBlock(b *database.DatastoreBlock) (*types.Block, error)

func NewLogger

func NewLogger(n network.Network, provider string) zerolog.Logger

Types

type CoinbaseExchangeRates

type CoinbaseExchangeRates struct {
	Data struct {
		Currency string            `json:"currency"`
		Rates    map[string]string `json:"rates"`
	} `json:"data"`
}

type ExchangeRatesProvider

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

func NewExchangeRatesProvider

func NewExchangeRatesProvider(coinbaseURL string, tokens map[string][]string, eb *observer.EventBus, interval uint) *ExchangeRatesProvider

func (*ExchangeRatesProvider) PollingInterval

func (e *ExchangeRatesProvider) PollingInterval() uint

func (*ExchangeRatesProvider) PublishEvents

func (e *ExchangeRatesProvider) PublishEvents(ctx context.Context) error

func (*ExchangeRatesProvider) RefreshState

func (e *ExchangeRatesProvider) RefreshState(ctx context.Context) error

func (*ExchangeRatesProvider) SetEventBus

func (e *ExchangeRatesProvider) SetEventBus(bus *observer.EventBus)

type HashDivergenceProvider

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

HashDivergenceProvider is a special type of provider because it's a provider of providers, or a meta-provider. This providers store RPCProviders and queries their blockbuffers to determine hash divergence.

See ../runner/runner.go to see how this provider is initialized.

func NewHashDivergenceProvider

func NewHashDivergenceProvider(rpcProviders []*RPCProvider, eb *observer.EventBus, interval uint) *HashDivergenceProvider

func (*HashDivergenceProvider) PollingInterval

func (h *HashDivergenceProvider) PollingInterval() uint

func (*HashDivergenceProvider) PublishEvents

func (h *HashDivergenceProvider) PublishEvents(ctx context.Context) error

func (*HashDivergenceProvider) RefreshState

func (h *HashDivergenceProvider) RefreshState(context.Context) error

func (*HashDivergenceProvider) SetEventBus

func (h *HashDivergenceProvider) SetEventBus(bus *observer.EventBus)

type HeimdallProvider

type HeimdallProvider struct {
	TendermintURL string
	HeimdallURL   string
	Network       network.Network
	Label         string

	BlockNumber uint64
	// contains filtered or unexported fields
}

func NewHeimdallProvider

func NewHeimdallProvider(n network.Network, tendermintURL, heimdallURL, label string, eb *observer.EventBus, interval uint) *HeimdallProvider

func (*HeimdallProvider) PollingInterval

func (h *HeimdallProvider) PollingInterval() uint

func (*HeimdallProvider) PublishEvents

func (h *HeimdallProvider) PublishEvents(ctx context.Context) error

func (*HeimdallProvider) RefreshState

func (h *HeimdallProvider) RefreshState(ctx context.Context) error

func (*HeimdallProvider) SetEventBus

func (h *HeimdallProvider) SetEventBus(bus *observer.EventBus)

type Provider

type Provider interface {
	// Refresh state is responsible for updating the provider state. All state
	// updates should happen in this method of the provider. There should not be
	// event publishing done is this method. The Start function in runner.go will
	// call RefreshState of every provider before PublishEvents.
	RefreshState(context.Context) error

	// PublishEvents should given the current state of the provider, publish those
	// messages to the corresponding event bus. PublishEvents should not modify
	// state at all. The Start function in runner.go will call PublishEvents of
	// every provider after RefreshState.
	PublishEvents(context.Context) error

	// SetEventBus is used to configure the providers currently used message bus.
	SetEventBus(*observer.EventBus)

	// PollingInterval returns how often the provider should refresh it state and
	// publish events in seconds.
	PollingInterval() uint
}

Provider must be implemented by any system that's monitoring the state of a network.

type RPCProvider

type RPCProvider struct {
	URL     string
	Network network.Network
	Label   string

	BlockNumber uint64
	// contains filtered or unexported fields
}

RPCProvider is the generic struct for all EVM style JSON RPC services.

func NewRPCProvider

func NewRPCProvider(opts RPCProviderOpts) *RPCProvider

NewRPCProvider will create a new RPC provider and configure it's event bus.

func (*RPCProvider) PollingInterval

func (r *RPCProvider) PollingInterval() uint

func (*RPCProvider) PublishEvents

func (r *RPCProvider) PublishEvents(ctx context.Context) error

func (*RPCProvider) RefreshState

func (r *RPCProvider) RefreshState(ctx context.Context) error

RefreshState is going to get the current head block and request all of the blocks between the current head and the last head. All of those blocks will be pushed into the buffer.

func (*RPCProvider) SetEventBus

func (r *RPCProvider) SetEventBus(bus *observer.EventBus)

type RPCProviderOpts

type RPCProviderOpts struct {
	Network    network.Network
	URL        string
	Label      string
	EventBus   *observer.EventBus
	Interval   uint
	Contracts  config.ContractAddresses
	TimeToMine *config.TimeToMine
	Accounts   []string
}

type RollupData added in v1.1.0

type RollupData struct {
	RollupContract                 common.Address
	ChainID                        uint64
	Verifier                       common.Address
	ForkID                         uint64
	LastLocalExitRoot              [32]byte
	LastBatchSequenced             uint64
	LastVerifiedBatch              uint64
	LastPendingState               uint64
	LastPendingStateConsolidated   uint64
	LastVerifiedBatchBeforeUpgrade uint64
	RollupTypeID                   uint64
	RollupCompatibilityID          uint8
}

RollupData is the struct returned by the RollupIDToRollupData method. This is here because the abigen tool doesn't generate a named struct for this data. Update this value if the response ever changes.

type SensorNetworkProvider

type SensorNetworkProvider struct {
	Network network.Network
	Label   string

	BlockNumber uint64
	// contains filtered or unexported fields
}

func NewSensorNetworkProvider

func NewSensorNetworkProvider(ctx context.Context, n network.Network, project, database, label string, eb *observer.EventBus, interval uint) *SensorNetworkProvider

func (*SensorNetworkProvider) PollingInterval

func (s *SensorNetworkProvider) PollingInterval() uint

func (*SensorNetworkProvider) PublishEvents

func (s *SensorNetworkProvider) PublishEvents(ctx context.Context) error

func (*SensorNetworkProvider) RefreshState

func (s *SensorNetworkProvider) RefreshState(ctx context.Context) error

func (*SensorNetworkProvider) SetEventBus

func (s *SensorNetworkProvider) SetEventBus(bus *observer.EventBus)

type SignerInfo

type SignerInfo struct {
	Difficulty int    `json:"Difficulty"`
	Signer     string `json:"Signer"`
}

type SnapshotProposerSequence

type SnapshotProposerSequence struct {
	Author  string       `json:"Author"`
	Diff    int          `json:"Diff"`
	Signers []SignerInfo `json:"Signers"`
}

type SystemProvider

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

func NewSystemProvider

func NewSystemProvider(eb *observer.EventBus, interval uint) *SystemProvider

func (*SystemProvider) PollingInterval

func (s *SystemProvider) PollingInterval() uint

func (*SystemProvider) PublishEvents

func (s *SystemProvider) PublishEvents(ctx context.Context) error

func (*SystemProvider) RefreshState

func (s *SystemProvider) RefreshState(context.Context) error

func (*SystemProvider) SetEventBus

func (s *SystemProvider) SetEventBus(bus *observer.EventBus)

type TxPoolStatus

type TxPoolStatus struct {
	Pending string `json:"pending"`
	Queued  string `json:"queued"`
}

Jump to

Keyboard shortcuts

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