fetcher

package
v0.0.0-...-656df06 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

This is a temporary package whilst working on the eth/66 blocking refactors. After that work is done, les needs to be refactored to use the new package, or alternatively use a stripped down version of it. Either way, we need to keep the changes scoped so duplicating temporarily seems the sanest.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockFetcher

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

BlockFetcher is responsible for accumulating block announcements from various peers and scheduling them for retrieval.

func NewBlockFetcher

func NewBlockFetcher(light bool, getHeader HeaderRetrievalFn, getBlock blockRetrievalFn, verifyHeader headerVerifierFn, broadcastBlock blockBroadcasterFn, chainHeight chainHeightFn, insertHeaders headersInsertFn, insertChain chainInsertFn, dropPeer peerDropFn) *BlockFetcher

NewBlockFetcher creates a block fetcher to retrieve blocks based on hash announcements.

func (*BlockFetcher) Enqueue

func (f *BlockFetcher) Enqueue(peer string, block *types.Block) error

Enqueue tries to fill gaps the fetcher's future import queue.

func (*BlockFetcher) FilterBodies

func (f *BlockFetcher) FilterBodies(peer string, transactions [][]*types.Transaction, uncles [][]*types.Header, time time.Time) ([][]*types.Transaction, [][]*types.Header)

FilterBodies extracts all the block bodies that were explicitly requested by the fetcher, returning those that should be handled differently.

func (*BlockFetcher) FilterHeaders

func (f *BlockFetcher) FilterHeaders(peer string, headers []*types.Header, time time.Time) []*types.Header

FilterHeaders extracts all the headers that were explicitly requested by the fetcher, returning those that should be handled differently.

func (*BlockFetcher) Notify

func (f *BlockFetcher) Notify(peer string, hash common.Hash, number uint64, time time.Time,
	headerFetcher headerRequesterFn, bodyFetcher bodyRequesterFn) error

Notify announces the fetcher of the potential availability of a new block in the network.

func (*BlockFetcher) Start

func (f *BlockFetcher) Start()

Start boots up the announcement based synchroniser, accepting and processing hash notifications and block fetches until termination requested.

func (*BlockFetcher) Stop

func (f *BlockFetcher) Stop()

Stop terminates the announcement based synchroniser, canceling all pending operations.

type HeaderRetrievalFn

type HeaderRetrievalFn func(common.Hash) *types.Header

HeaderRetrievalFn is a callback type for retrieving a header from the local chain.

Jump to

Keyboard shortcuts

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