syncer

package
v0.0.0-...-8201b66 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2021 License: LGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultHeaderLoader

type DefaultHeaderLoader struct {
	// contains filtered or unexported fields
}

func NewHeaderLoader

func NewHeaderLoader(client *ethclient.Client) *DefaultHeaderLoader

func (*DefaultHeaderLoader) HeaderByHash

func (d *DefaultHeaderLoader) HeaderByHash(ctx context.Context, hash gethCommon.Hash) (*gethTypes.Header, error)

func (*DefaultHeaderLoader) HeaderByNumber

func (d *DefaultHeaderLoader) HeaderByNumber(ctx context.Context, number *big.Int) (*gethTypes.Header, error)

func (*DefaultHeaderLoader) SubscribeNewHead

func (d *DefaultHeaderLoader) SubscribeNewHead(ctx context.Context, ch chan<- *gethTypes.Header) (ethereum.Subscription, error)

type HeaderCache

type HeaderCache struct {
	// contains filtered or unexported fields
}

This is used to store the latest headers as they are published. Up to `numHeightsToTrack` heights are stored. Once this number is reached, an old height is pruned each time a new height is added. The current stored height range is given by [minHeight, maxHeight].

func NewHeaderCache

func NewHeaderCache(numHeightsToTrack uint64) *HeaderCache

func (*HeaderCache) Get

func (hc *HeaderCache) Get(hash gethCommon.Hash) (*HeaderCacheItem, bool)

func (*HeaderCache) Insert

func (hc *HeaderCache) Insert(header *gethTypes.Header) bool

Returns true if insertion was successful. Insertion will only fail if a header is too old, i.e. we've seen at least `numHeightsToTrack` newer heights

type HeaderCacheItem

type HeaderCacheItem struct {
	Header    *gethTypes.Header
	Forwarded bool
}

type HeaderLoader

type HeaderLoader interface {
	HeaderByHash(ctx context.Context, hash gethCommon.Hash) (*gethTypes.Header, error)
	HeaderByNumber(ctx context.Context, number *big.Int) (*gethTypes.Header, error)
	SubscribeNewHead(ctx context.Context, ch chan<- *gethTypes.Header) (ethereum.Subscription, error)
}

type Syncer

type Syncer struct {
	// contains filtered or unexported fields
}

Syncer retrieves headers starting at a given initial height up to the latest. Headers are sent to the channel `headers` in order. If the initial height is old, (finalized) headers in the canonical chain will be forwarded in quick succession until we catch up with the unfinalized headers. From that point onwards, headers on all forks are forwarded. A header is considered final if it has at least `descendantsUntilFinal` descendants.

func NewSyncer

func NewSyncer(descendantsUntilFinal uint64, loader HeaderLoader, headers chan<- *gethTypes.Header, log *logrus.Entry) *Syncer

func (*Syncer) StartSync

func (s *Syncer) StartSync(ctx context.Context, eg *errgroup.Group, initBlockHeight uint64) error

Jump to

Keyboard shortcuts

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