synchronizer

package
v1.2.14 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FullSync int = iota
	FastSync
	LightSync
)
View Source
const (
	HandshakeCode int = 100
	SyncTxnsCode      = 101
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BlocksRange

type BlocksRange struct {
	StartHeight BlockNum
	EndHeight   BlockNum
}

type HandShakeInfo

type HandShakeInfo struct {
	GenesisBlockHash Hash

	// when chain is finlaized chain, end block is the finalized block
	EndHeight    BlockNum
	EndBlockHash Hash
}

func (*HandShakeInfo) Compare

func (hs *HandShakeInfo) Compare(other *HandShakeInfo) (*BlocksRange, error)

Compare return a BlocksRange if other node's height is lower

type HandShakeRequest

type HandShakeRequest struct {
	FetchRange *BlocksRange
	Info       *HandShakeInfo
}

func DecodeHsRequest

func DecodeHsRequest(data []byte) (*HandShakeRequest, error)

func (*HandShakeRequest) Encode

func (hs *HandShakeRequest) Encode() ([]byte, error)

type HandShakeResp

type HandShakeResp struct {
	// missing blocks range
	MissingRange *BlocksRange
	// blocks bytes
	BlocksByt []byte
	Err       error
}

func DecodeHsResp

func DecodeHsResp(data []byte) (*HandShakeResp, error)

func (*HandShakeResp) Encode

func (hs *HandShakeResp) Encode() ([]byte, error)

type Synchronizer

type Synchronizer struct {
	*Tripod
	// contains filtered or unexported fields
}

func NewSynchronizer

func NewSynchronizer(syncMode int) *Synchronizer

func (*Synchronizer) InitChain

func (b *Synchronizer) InitChain(block *Block)

func (*Synchronizer) NewHsInfo

func (b *Synchronizer) NewHsInfo() (*HandShakeInfo, error)

func (*Synchronizer) NewHsReq

func (b *Synchronizer) NewHsReq(fetchRange *BlocksRange) (*HandShakeRequest, error)

type TxnsRequest

type TxnsRequest struct {
	Hashes        []Hash
	BlockProducer peer.ID
}

func DecodeTxnsRequest

func DecodeTxnsRequest(data []byte) (tr TxnsRequest, err error)

func (TxnsRequest) Encode

func (tr TxnsRequest) Encode() ([]byte, error)

Jump to

Keyboard shortcuts

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