Documentation
¶
Overview ¶
Package blocksub implements an Ethereum block subscriber that works with polling and/or websockets.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrStopped = errors.New("already stopped")
Functions ¶
This section is empty.
Types ¶
type BlockSub ¶
type BlockSub struct {
PollTimeout time.Duration // 10 seconds by default (8,640 requests per day)
SubTimeout time.Duration // 60 seconds by default, after this timeout the subscriber will reconnect
DebugOutput bool
EnableMetrics bool
CurrentHeader *ethtypes.Header
CurrentBlockNumber uint64
CurrentBlockHash string
// contains filtered or unexported fields
}
func NewBlockSub ¶
func NewBlockSubWithTimeout ¶ added in v0.11.0
type BlockSubscriber ¶ added in v0.4.1
type BlockSubscriber interface {
IsRunning() bool
Subscribe(ctx context.Context) Subscription
Start() (err error)
Stop()
}
type Subscription ¶
type Subscription struct {
C chan *ethtypes.Header // Channel to receive the headers on.
// contains filtered or unexported fields
}
Subscription will push new headers to a subscriber until the context is done or Unsubscribe() is called, at which point the subscription is stopped and the header channel closed.
func NewSubscription ¶
func NewSubscription(ctx context.Context) Subscription
func (*Subscription) Done ¶
func (sub *Subscription) Done() <-chan struct{}
func (*Subscription) Unsubscribe ¶
func (sub *Subscription) Unsubscribe()
Unsubscribe unsubscribes the notification and closes the header channel. It can safely be called more than once.
Click to show internal directories.
Click to hide internal directories.