sync

package
v0.0.0-...-77dcbbd Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package sync provides block synchronization mechanism following the BFT protocol.

Index

Constants

View Source
const (
	RPCEndpointGetLastBlock          = "getLastBlock"
	RPCEndpointGetHighestCommonBlock = "getHighestCommonBlock"
	RPCEndpointGetBlocksFromID       = "getBlocksFromId"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Downloader

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

func NewDownloader

func NewDownloader(
	ctx context.Context,
	logger log.Logger,
	conn *p2p.Connection,
	chain *blockchain.Chain,
	peerID p2p.PeerID,
	startID []byte,
	startHeight uint32,
	endID []byte,
	endHeight uint32,
) *Downloader

func (*Downloader) Downloaded

func (d *Downloader) Downloaded() <-chan *downloadedContent

func (*Downloader) Start

func (d *Downloader) Start()

func (*Downloader) Stop

func (d *Downloader) Stop()

type GetBlocksFromIDRequest

type GetBlocksFromIDRequest struct {
	ID codec.Hex `json:"id" fieldNumber:"1"`
}

func (*GetBlocksFromIDRequest) Decode

func (e *GetBlocksFromIDRequest) Decode(data []byte) error

func (*GetBlocksFromIDRequest) DecodeFromReader

func (e *GetBlocksFromIDRequest) DecodeFromReader(reader *codec.Reader) error

func (*GetBlocksFromIDRequest) DecodeStrict

func (e *GetBlocksFromIDRequest) DecodeStrict(data []byte) error

func (*GetBlocksFromIDRequest) DecodeStrictFromReader

func (e *GetBlocksFromIDRequest) DecodeStrictFromReader(reader *codec.Reader) error

func (*GetBlocksFromIDRequest) Encode

func (e *GetBlocksFromIDRequest) Encode() []byte

func (*GetBlocksFromIDRequest) MustDecode

func (e *GetBlocksFromIDRequest) MustDecode(data []byte)

type GetBlocksFromIDResponse

type GetBlocksFromIDResponse struct {
	Blocks []*blockchain.Block `json:"blocks" fieldNumber:"1"`
}

func (*GetBlocksFromIDResponse) Decode

func (e *GetBlocksFromIDResponse) Decode(data []byte) error

func (*GetBlocksFromIDResponse) DecodeFromReader

func (e *GetBlocksFromIDResponse) DecodeFromReader(reader *codec.Reader) error

func (*GetBlocksFromIDResponse) DecodeStrict

func (e *GetBlocksFromIDResponse) DecodeStrict(data []byte) error

func (*GetBlocksFromIDResponse) DecodeStrictFromReader

func (e *GetBlocksFromIDResponse) DecodeStrictFromReader(reader *codec.Reader) error

func (*GetBlocksFromIDResponse) Encode

func (e *GetBlocksFromIDResponse) Encode() []byte

func (*GetBlocksFromIDResponse) MustDecode

func (e *GetBlocksFromIDResponse) MustDecode(data []byte)

type GetHighestCommonBlockRequest

type GetHighestCommonBlockRequest struct {
	IDs [][]byte `json:"ids" fieldNumber:"1"`
}

func (*GetHighestCommonBlockRequest) Decode

func (e *GetHighestCommonBlockRequest) Decode(data []byte) error

func (*GetHighestCommonBlockRequest) DecodeFromReader

func (e *GetHighestCommonBlockRequest) DecodeFromReader(reader *codec.Reader) error

func (*GetHighestCommonBlockRequest) DecodeStrict

func (e *GetHighestCommonBlockRequest) DecodeStrict(data []byte) error

func (*GetHighestCommonBlockRequest) DecodeStrictFromReader

func (e *GetHighestCommonBlockRequest) DecodeStrictFromReader(reader *codec.Reader) error

func (*GetHighestCommonBlockRequest) Encode

func (e *GetHighestCommonBlockRequest) Encode() []byte

func (*GetHighestCommonBlockRequest) MustDecode

func (e *GetHighestCommonBlockRequest) MustDecode(data []byte)

type GetHighestCommonBlockResponse

type GetHighestCommonBlockResponse struct {
	ID []byte `json:"id" fieldNumber:"1"`
}

func (*GetHighestCommonBlockResponse) Decode

func (e *GetHighestCommonBlockResponse) Decode(data []byte) error

func (*GetHighestCommonBlockResponse) DecodeFromReader

func (e *GetHighestCommonBlockResponse) DecodeFromReader(reader *codec.Reader) error

func (*GetHighestCommonBlockResponse) DecodeStrict

func (e *GetHighestCommonBlockResponse) DecodeStrict(data []byte) error

func (*GetHighestCommonBlockResponse) DecodeStrictFromReader

func (e *GetHighestCommonBlockResponse) DecodeStrictFromReader(reader *codec.Reader) error

func (*GetHighestCommonBlockResponse) Encode

func (e *GetHighestCommonBlockResponse) Encode() []byte

func (*GetHighestCommonBlockResponse) MustDecode

func (e *GetHighestCommonBlockResponse) MustDecode(data []byte)

type NodeInfo

type NodeInfo struct {
	PeerID p2p.PeerID
	// contains filtered or unexported fields
}

func NewNodeInfo

func NewNodeInfo(
	height uint32,
	maxHeightPrevoted uint32,
	blockVersion uint32,
	lastBlockID []byte,
) *NodeInfo

func (*NodeInfo) Decode

func (e *NodeInfo) Decode(data []byte) error

func (*NodeInfo) DecodeFromReader

func (e *NodeInfo) DecodeFromReader(reader *codec.Reader) error

func (*NodeInfo) DecodeStrict

func (e *NodeInfo) DecodeStrict(data []byte) error

func (*NodeInfo) DecodeStrictFromReader

func (e *NodeInfo) DecodeStrictFromReader(reader *codec.Reader) error

func (*NodeInfo) Encode

func (e *NodeInfo) Encode() []byte

func (*NodeInfo) MustDecode

func (e *NodeInfo) MustDecode(data []byte)

type SyncContext

type SyncContext struct {
	Ctx                  context.Context
	Block                *blockchain.Block
	FinalizedBlockHeader *blockchain.BlockHeader
	PeerID               p2p.PeerID
	CurrentValidators    []codec.Lisk32
}

type Syncer

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

Syncer sync the block with network.

func NewSyncer

func NewSyncer(
	chain *blockchain.Chain,
	blockslot *validator.BlockSlot,
	conn *p2p.Connection,
	logger log.Logger,
	processor processFn,
	reverter revertFn,
) *Syncer

func (*Syncer) HandleRPCEndpointGetBlocksFromID

func (s *Syncer) HandleRPCEndpointGetBlocksFromID() p2p.RPCHandler

func (*Syncer) HandleRPCEndpointGetHighestCommonBlock

func (s *Syncer) HandleRPCEndpointGetHighestCommonBlock() p2p.RPCHandler

func (*Syncer) HandleRPCEndpointGetLastBlock

func (s *Syncer) HandleRPCEndpointGetLastBlock() p2p.RPCHandler

func (*Syncer) Sync

func (s *Syncer) Sync(ctx *SyncContext) error

Sync with network.

Jump to

Keyboard shortcuts

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