Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	NodeURL      string
	NodeURLWS    string
	PollInterval time.Duration
}

type Tracker

type Tracker struct {

	// contains filtered or unexported fields

}

func NewTracker

func NewTracker(config Config) (*Tracker, error)

NewTracker instantiates a new best block tracker with the config provided by the user You should call `Run()` to actually start the process

func (*Tracker) BestBlock

func (b *Tracker) BestBlock() int64

BestBlock returns the current best block known to the tracker

func (*Tracker) Close

func (b *Tracker) Close()

Close stops the tracker

func (*Tracker) Err

func (b *Tracker) Err() chan error

Err returns a channel of errors that should be consumed to avoid the tracker getting stuck

func (*Tracker) Run

func (b *Tracker) Run()

Run starts the tracker either on websockets (with subscription) or on http (with polling), depending on the type of url provided via config It takes care of restarting the websocket connection automatically if it crashes

func (*Tracker) Subscribe

func (b *Tracker) Subscribe() chan int64

Subscribe creates a new channel to send blocks and registers the client on the instance returns the channel a client should be consuming from