bodydownload

package
v0.0.0-...-1f8a15b Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const MaxBodiesInRequest = 1024

Variables

This section is empty.

Functions

This section is empty.

Types

type BodyDownload

type BodyDownload struct {
	DeliveryNotify chan struct{}

	Engine consensus.Engine
	// contains filtered or unexported fields
}

BodyDownload represents the state of body downloading process

func NewBodyDownload

func NewBodyDownload(engine consensus.Engine, blockBufferSize, bodyCacheLimit int, br services.FullBlockReader, logger log.Logger) *BodyDownload

NewBodyDownload create a new body download state object

func (*BodyDownload) AddToPrefetch

func (bd *BodyDownload) AddToPrefetch(header *types.Header, body *types.RawBody)

func (*BodyDownload) AdvanceLow

func (bd *BodyDownload) AdvanceLow()

func (*BodyDownload) BodyCacheSize

func (bd *BodyDownload) BodyCacheSize() int

func (*BodyDownload) ClearBodyCache

func (bd *BodyDownload) ClearBodyCache()

func (*BodyDownload) DeliverBodies

func (bd *BodyDownload) DeliverBodies(txs [][][]byte, uncles [][]*types.Header, withdrawals []types.Withdrawals, lenOfP2PMsg uint64, peerID [64]byte)

DeliverBodies takes the block body received from a peer and adds it to the various data structures

func (*BodyDownload) DeliveryCounts

func (bd *BodyDownload) DeliveryCounts() (float64, float64)

func (*BodyDownload) DeliverySize

func (bd *BodyDownload) DeliverySize(delivered float64, wasted float64)

func (*BodyDownload) GetBodyFromCache

func (bd *BodyDownload) GetBodyFromCache(blockNum uint64, del bool) *types.RawBody

func (*BodyDownload) GetDeliveries

func (bd *BodyDownload) GetDeliveries(tx kv.RwTx) (uint64, uint64, error)

func (*BodyDownload) GetHeader

func (bd *BodyDownload) GetHeader(blockNum uint64, blockReader services.FullBlockReader, tx kv.Tx) (*types.Header, libcommon.Hash, error)

GetHeader returns a header by either loading from the deliveriesH slice populated when running RequestMoreBodies or if the code is continuing from a previous run and this isn't present, by reading from the DB as the RequestMoreBodies would have. as the requestedLow count is incremented before a call to this function we need the process count so that we can anticipate this, effectively reversing time a little to get the actual position we need in the slice prior to requestedLow being incremented

func (*BodyDownload) GetPenaltyPeers

func (bd *BodyDownload) GetPenaltyPeers() [][64]byte

func (*BodyDownload) NextProcessingCount

func (bd *BodyDownload) NextProcessingCount() uint64

NextProcessingCount returns the count of contiguous block numbers ready to process from the requestedLow minimum value. the requestedLow count is increased by the number returned

func (*BodyDownload) NotDelivered

func (bd *BodyDownload) NotDelivered(blockNum uint64)

func (*BodyDownload) PrintPeerMap

func (bd *BodyDownload) PrintPeerMap()

func (*BodyDownload) RequestMoreBodies

func (bd *BodyDownload) RequestMoreBodies(tx kv.RwTx, blockReader services.FullBlockReader, currentTime uint64, blockPropagator adapter.BlockPropagator) (*BodyRequest, error)

RequestMoreBodies - returns nil if nothing to request

func (*BodyDownload) RequestSent

func (bd *BodyDownload) RequestSent(bodyReq *BodyRequest, timeWithTimeout uint64, peer [64]byte)

func (*BodyDownload) UpdateFromDb

func (bd *BodyDownload) UpdateFromDb(db kv.Tx) (headHeight, headTime uint64, headHash libcommon.Hash, headTd256 *uint256.Int, err error)

UpdateFromDb reads the state of the database and refreshes the state of the body download

type BodyRequest

type BodyRequest struct {
	BlockNums []uint64
	Hashes    []libcommon.Hash
	// contains filtered or unexported fields
}

BodyRequest is a sketch of the request for block bodies, meaning that access to the database is required to convert it to the actual BlockBodies request (look up hashes of canonical blocks)

type BodyTreeItem

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

BodyQueueItem is part of the body cache kept in memory

type Delivery

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

type PrefetchedBlocks

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

func NewPrefetchedBlocks

func NewPrefetchedBlocks() *PrefetchedBlocks

func (*PrefetchedBlocks) Add

func (pb *PrefetchedBlocks) Add(h *types.Header, b *types.RawBody)

func (*PrefetchedBlocks) Get

func (pb *PrefetchedBlocks) Get(hash common.Hash) (*types.Header, *types.RawBody)

type RawTransactions

type RawTransactions [][]byte

RawTransaction implements core/types.DerivableList interface for hashing

func (RawTransactions) EncodeIndex

func (rt RawTransactions) EncodeIndex(i int, w *bytes.Buffer)

EncodeIndex is part of core/types.DerivableList It strips the transaction envelope from the transaction RLP

func (RawTransactions) Len

func (rt RawTransactions) Len() int

type TripleHash

type TripleHash [3 * length.Hash]byte

TripleHash is type to be used for the mapping between TxHash, UncleHash, and WithdrawalsHash to the block header

Jump to

Keyboard shortcuts

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