Documentation ¶
Index ¶
- Constants
- type BodyDownload
- func (bd *BodyDownload) AddToPrefetch(block *types.Block)
- func (bd *BodyDownload) DeliverBodies(txs [][][]byte, uncles [][]*types.Header, lenOfP2PMsg uint64, peerID string)
- func (bd *BodyDownload) DeliveryCounts() (float64, float64)
- func (bd *BodyDownload) DeliverySize(delivered float64, wasted float64)
- func (bd *BodyDownload) GetDeliveries(verifyUnclesFunc VerifyUnclesFunc) ([]*types.Header, []*types.RawBody, error)
- func (bd *BodyDownload) GetPenaltyPeers() [][]byte
- func (bd *BodyDownload) PrintPeerMap()
- func (bd *BodyDownload) RequestMoreBodies(db ethdb.Tx, blockNum uint64, currentTime uint64, ...) (*BodyRequest, uint64, error)
- func (bd *BodyDownload) RequestSent(bodyReq *BodyRequest, timeWithTimeout uint64, peer []byte)
- func (bd *BodyDownload) UpdateFromDb(db ethdb.RwTx) (headHeight uint64, headHash common.Hash, headTd256 *uint256.Int, err error)
- func (bd *BodyDownload) VerifyUncles(header *types.Header, uncles []*types.Header, r consensus.ChainReader) (headerdownload.Penalty, error)
- type BodyRequest
- type Delivery
- type DoubleHash
- type PrefetchedBlocks
- type RawTransactions
- type VerifyUnclesFunc
Constants ¶
const BlockBufferSize = 128
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(outstandingLimit int, engine consensus.Engine) *BodyDownload
NewBodyDownload create a new body download state object
func (*BodyDownload) AddToPrefetch ¶
func (bd *BodyDownload) AddToPrefetch(block *types.Block)
func (*BodyDownload) DeliverBodies ¶
func (bd *BodyDownload) DeliverBodies(txs [][][]byte, uncles [][]*types.Header, lenOfP2PMsg uint64, peerID string)
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) GetDeliveries ¶
func (bd *BodyDownload) GetDeliveries(verifyUnclesFunc VerifyUnclesFunc) ([]*types.Header, []*types.RawBody, error)
func (*BodyDownload) GetPenaltyPeers ¶
func (bd *BodyDownload) GetPenaltyPeers() [][]byte
func (*BodyDownload) PrintPeerMap ¶
func (bd *BodyDownload) PrintPeerMap()
func (*BodyDownload) RequestMoreBodies ¶
func (bd *BodyDownload) RequestMoreBodies(db ethdb.Tx, blockNum uint64, currentTime uint64, blockPropagator adapter.BlockPropagator) (*BodyRequest, uint64, error)
RequestMoreBodies - returns nil if nothing to request
func (*BodyDownload) RequestSent ¶
func (bd *BodyDownload) RequestSent(bodyReq *BodyRequest, timeWithTimeout uint64, peer []byte)
func (*BodyDownload) UpdateFromDb ¶
func (bd *BodyDownload) UpdateFromDb(db ethdb.RwTx) (headHeight uint64, headHash common.Hash, headTd256 *uint256.Int, err error)
UpdateFromDb reads the state of the database and refreshes the state of the body download
func (*BodyDownload) VerifyUncles ¶
func (bd *BodyDownload) VerifyUncles(header *types.Header, uncles []*types.Header, r consensus.ChainReader) (headerdownload.Penalty, error)
ValidateBody validates the given block's uncles and verifies the block header's transaction and uncle roots. The headers are assumed to be already validated at this point. It returns 2 errors - first is Validation error (reason to penalize peer and continue processing other bodies), second is internal runtime error (like network error or db error)
type BodyRequest ¶
type BodyRequest struct { BlockNums []uint64 Hashes []common.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 DoubleHash ¶
type DoubleHash [2 * common.HashLength]byte
DoubleHash is type to be used for the mapping between TxHash and UncleHash to the block header
type PrefetchedBlocks ¶
type PrefetchedBlocks struct {
// contains filtered or unexported fields
}
func NewPrefetchedBlocks ¶
func NewPrefetchedBlocks() *PrefetchedBlocks
func (*PrefetchedBlocks) Add ¶
func (pb *PrefetchedBlocks) Add(b *types.Block)
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 VerifyUnclesFunc ¶
VerifyUnclesFunc validates the given block's uncles and verifies the block header's transaction and uncle roots. The headers are assumed to be already validated at this point. It returns 2 errors - first is Validation error (reason to penalize peer and continue processing other bodies), second is internal runtime error (like network error or db error)