Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // EventSyncer is the singleton that is responsible for syncing events from Ethereum. EventSyncer = &globalListenerManager{ listeners: make(map[string]*listenerInfo), } )
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 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 (*EthLog) UnmarshalBinary ¶
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
}