Documentation ¶
Index ¶
Constants ¶
const LoggerTag = "STARKNET_TELEPORT"
const TeleportEventType = "teleport_starknet"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶ added in v0.7.1
type Config struct { // Sequencer is an instance of Ethereum RPC sequencer. Sequencer Sequencer // Addresses is a list of contracts from which events will be fetched. Addresses []*starknet.Felt // Interval specifies how often provider should check for new events. Interval time.Duration // PrefetchPeriod specifies how far back in time provider should prefetch // events. It is used only during the initial start of the provider. PrefetchPeriod time.Duration // Logger is an instance of a logger. Logger is used mostly to report // recoverable errors. Logger log.Logger }
Config contains a configuration options for New.
type EventProvider ¶ added in v0.7.1
type EventProvider struct {
// contains filtered or unexported fields
}
EventProvider listens for TeleportGUID events on Starknet.
https://github.com/makerdao/dss-teleport https://github.com/makerdao/starknet-dai-bridge
It periodically fetches pending block, looks for TeleportGUID events, converts them into messages.Event and sends them to the channel provided by Events method.
During the initial start of the provider it also fetches older blocks until it reaches the block that is older than the prefetch period. This is done to fetch events that were emitted before the provider was started.
Finally, it also listens for newly accepted blocks. This is done to make sure that provider does not miss any events from the pending block. This can happen if the Starknet node becomes unavailable, so it cannot fetch the pending block. If at that time the pending block become accepted, the events that would have been added since the time the node became unavailable would be lost.
In the event of an error in communication with a Starknet node, whether related to network errors or the node itself, the provider will try to repeat requests to the node indefinitely.
func New ¶
func New(cfg Config) (*EventProvider, error)
New creates a new instance of EventProvider.
func (*EventProvider) Events ¶ added in v0.7.1
func (ep *EventProvider) Events() chan *messages.Event
Events implements the publisher.EventPublisher interface.