blocksync

package
v0.0.0-...-8d6f29a Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockResponseMessagePrefixSize   = 4
	BlockResponseMessageFieldKeySize = 1
	MaxMsgSize                       = types.MaxBlockSizeBytes + BlockResponseMessagePrefixSize + BlockResponseMessageFieldKeySize
)
View Source
const (
	BlocksyncChannel = byte(0x40)
)

Variables

View Source
var (
	ErrNilMessage     = errors.New("message cannot be nil")
	ErrNegativeHeight = errors.New("negative height")
	ErrNegativeBase   = errors.New("negative base")
)

Functions

func ValidateMsg

func ValidateMsg(pb proto.Message) error

Types

type BlockPool

type BlockPool struct {
	service.BaseService
	// contains filtered or unexported fields
}

func NewBlockPool

func NewBlockPool(start int64, requestsCh chan<- BlockRequest, errorsCh chan<- peerError) *BlockPool

func (*BlockPool) AddBlock

func (pool *BlockPool) AddBlock(peerID p2p.ID, block *types.Block, blockSize int)

func (*BlockPool) GetStatus

func (pool *BlockPool) GetStatus() (height int64, numPending int32, lenRequesters int)

func (*BlockPool) IsCaughtUp

func (pool *BlockPool) IsCaughtUp() bool

func (*BlockPool) MaxPeerHeight

func (pool *BlockPool) MaxPeerHeight() int64

func (*BlockPool) OnStart

func (pool *BlockPool) OnStart() error

func (*BlockPool) PeekTwoBlocks

func (pool *BlockPool) PeekTwoBlocks() (first *types.Block, second *types.Block)

func (*BlockPool) PopRequest

func (pool *BlockPool) PopRequest()

func (*BlockPool) RedoRequest

func (pool *BlockPool) RedoRequest(height int64) p2p.ID

func (*BlockPool) RemovePeer

func (pool *BlockPool) RemovePeer(peerID p2p.ID)

func (*BlockPool) SetPeerRange

func (pool *BlockPool) SetPeerRange(peerID p2p.ID, base int64, height int64)

type BlockRequest

type BlockRequest struct {
	Height int64
	PeerID p2p.ID
}

type Reactor

type Reactor struct {
	p2p.BaseReactor
	// contains filtered or unexported fields
}

func NewReactor

func NewReactor(state sm.State, blockExec *sm.BlockExecutor, store *store.BlockStore, blockSync bool) *Reactor

func (*Reactor) AddPeer

func (bcR *Reactor) AddPeer(peer p2p.Peer)

func (*Reactor) BroadcastStatusRequest

func (bcR *Reactor) BroadcastStatusRequest()

func (*Reactor) GetChannels

func (bcR *Reactor) GetChannels() []*p2p.ChannelDescriptor

func (*Reactor) OnStart

func (bcR *Reactor) OnStart() error

func (*Reactor) OnStop

func (bcR *Reactor) OnStop()

func (*Reactor) ReceiveEnvelope

func (bcR *Reactor) ReceiveEnvelope(e p2p.Envelope)

func (*Reactor) RemovePeer

func (bcR *Reactor) RemovePeer(peer p2p.Peer, reason interface{})

func (*Reactor) SetLogger

func (bcR *Reactor) SetLogger(l log.Logger)

func (*Reactor) SwitchToBlockSync

func (bcR *Reactor) SwitchToBlockSync(state sm.State) error

Jump to

Keyboard shortcuts

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