Documentation ¶
Overview ¶
Package fetcher contains the block announcement based synchronisation.
How fetcher works ¶
If the node receives a whole block, fetcher inserts the block into the chain and broadcast it to its peers. If a block hash is received instead of a block, node requests and reflects the header and body from the peer who sent the block hash.
Source Files ¶
Functions and variables related to fetcher are defined in the files listed below.
- fetcher.go : It includes functions for fetching the received block, header, body, and a queue data structure for the fetch operation.
- fetcher_test.go : Functions for testing the fetcher's functions.
- metrics.go : Metric variables for packet header, body and blocks.
Index ¶
- type BodyRequesterFn
- type FakeFetcher
- func (*FakeFetcher) Enqueue(peer string, block *types.Block) error
- func (*FakeFetcher) FilterBodies(peer string, transactions [][]*types.Transaction, time time.Time) [][]*types.Transaction
- func (*FakeFetcher) FilterHeaders(peer string, headers []*types.Header, time time.Time) []*types.Header
- func (*FakeFetcher) Notify(peer string, hash common.Hash, number uint64, time time.Time, ...) error
- func (*FakeFetcher) Start()
- func (*FakeFetcher) Stop()
- type Fetcher
- func (f *Fetcher) Enqueue(peer string, block *types.Block) error
- func (f *Fetcher) FilterBodies(peer string, transactions [][]*types.Transaction, time time.Time) [][]*types.Transaction
- func (f *Fetcher) FilterHeaders(peer string, headers []*types.Header, time time.Time) []*types.Header
- func (f *Fetcher) Notify(peer string, hash common.Hash, number uint64, time time.Time, ...) error
- func (f *Fetcher) Start()
- func (f *Fetcher) Stop()
- type HeaderRequesterFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BodyRequesterFn ¶ added in v1.1.0
BodyRequesterFn is a callback type for sending a body retrieval request.
type FakeFetcher ¶ added in v1.5.3
type FakeFetcher struct{}
func NewFakeFetcher ¶ added in v1.5.3
func NewFakeFetcher() *FakeFetcher
func (*FakeFetcher) Enqueue ¶ added in v1.5.3
func (*FakeFetcher) Enqueue(peer string, block *types.Block) error
func (*FakeFetcher) FilterBodies ¶ added in v1.5.3
func (*FakeFetcher) FilterBodies(peer string, transactions [][]*types.Transaction, time time.Time) [][]*types.Transaction
func (*FakeFetcher) FilterHeaders ¶ added in v1.5.3
func (*FakeFetcher) Notify ¶ added in v1.5.3
func (*FakeFetcher) Notify(peer string, hash common.Hash, number uint64, time time.Time, headerFetcher HeaderRequesterFn, bodyFetcher BodyRequesterFn) error
func (*FakeFetcher) Start ¶ added in v1.5.3
func (*FakeFetcher) Start()
func (*FakeFetcher) Stop ¶ added in v1.5.3
func (*FakeFetcher) Stop()
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
Fetcher is responsible for accumulating block announcements from various peers and scheduling them for retrieval.
func New ¶
func New(getBlock blockRetrievalFn, verifyHeader headerVerifierFn, broadcastBlock blockBroadcasterFn, broadcastBlockHash blockHashBroadcasterFn, chainHeight chainHeightFn, insertChain chainInsertFn, dropPeer peerDropFn) *Fetcher
New creates a block fetcher to retrieve blocks based on hash announcements.
func (*Fetcher) FilterBodies ¶
func (f *Fetcher) FilterBodies(peer string, transactions [][]*types.Transaction, time time.Time) [][]*types.Transaction
FilterBodies extracts all the block bodies that were explicitly requested by the fetcher, returning those that should be handled differently.
func (*Fetcher) FilterHeaders ¶
func (f *Fetcher) 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 (*Fetcher) Notify ¶
func (f *Fetcher) 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.
type HeaderRequesterFn ¶ added in v1.1.0
HeaderRequesterFn is a callback type for sending a header retrieval request.