evmsync

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// EventSyncer is the singleton that is responsible for syncing events from Ethereum.
	EventSyncer = &globalListenerManager{
		listeners: make(map[string]*listenerInfo),
	}
)
View Source
var StatePoller = &statePoller{
	pollers: make(map[string]*PollConfig),
	clients: make(map[chains.Chain]*ethclient.Client),
}

StatePoller is the global instance of the state poller extension, which allows polling for state on Ethereum. Unlike normal listeners (which are registered in init), StatePoller allows registration to be performed on-demand as part of the consensus process. It also provides access to an EVM client for the target chain, accessed via the local node's configuration.

Functions

func RegisterEventResolution

func RegisterEventResolution(name string, resolve ResolveFunc)

RegisterEventResolution registers a resolution function for the EVM event listener. It should be called in an init function.

func RegisterStatePollResolution

func RegisterStatePollResolution(name string, resolve EVMPollResolveFunc)

RegisterEventResolution registers a resolution function for the EVM event listener. It should be called in an init function.

Types

type EVMEventListenerConfig

type EVMEventListenerConfig struct {
	// UniqueName is a unique name for the listener.
	// It MUST be unique from all other listeners.
	UniqueName string
	// Chain is the chain that the listener is listening to.
	Chain chains.Chain
	// GetLogs is a function that queries logs to be synced from the chain.
	GetLogs GetBlockLogsFunc
}

EVMEventListenerConfig is the configuration for an EVM event listener.

type EVMPollFunc

type EVMPollFunc func(ctx context.Context, service *common.Service, eventstore listeners.EventKV, broadcast func(context.Context, []byte) error, client *ethclient.Client)

type EVMPollResolveFunc

type EVMPollResolveFunc func(ctx context.Context, app *common.App, resolution *resolutions.Resolution, block *common.BlockContext, uniqueName string, decodedData []byte) error

type EthLog

type EthLog struct {
	// Metadata is arbitrary metadata that can be set by the extension.
	Metadata []byte
	// Log is the go-ethereum log.
	Log *ethtypes.Log
}

EthLog holds information about an Ethereum log.

func (*EthLog) MarshalBinary

func (e *EthLog) MarshalBinary() ([]byte, error)

func (*EthLog) UnmarshalBinary

func (e *EthLog) UnmarshalBinary(data []byte) error

type GetBlockLogsFunc

type GetBlockLogsFunc func(ctx context.Context, client *ethclient.Client, startBlock, endBlock uint64, logger log.Logger) ([]*EthLog, error)

GetBlockLogsFunc is a function that provides an ethereum client and a range of blocks and returns the logs for that range.

type PollConfig

type PollConfig struct {
	// Chain is the chain to poll
	Chain chains.Chain
	// PollFunc is the function to call to poll the chain
	PollFunc EVMPollFunc
	// UniqueName is a unique name for the poller
	UniqueName string
	// ResolutionName is the name of the registered resolution function
	ResolutionName string
}

type ResolveFunc

type ResolveFunc func(ctx context.Context, app *common.App, block *common.BlockContext, uniqueName string, logs []*EthLog) error

Directories

Path Synopsis
package chains tracks the EVM chains that are supported by the node.
package chains tracks the EVM chains that are supported by the node.

Jump to

Keyboard shortcuts

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