blocksync

package
v1.8.1-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2022 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockByHeight added in v1.2.0

type BlockByHeight func(uint64) (*block.Block, error)

BlockByHeight returns the block of a given height

type BlockSync

type BlockSync interface {
	lifecycle.StartStopper

	// TargetHeight returns the target height to sync to
	TargetHeight() uint64
	// ProcessSyncRequest processes a block sync request
	ProcessSyncRequest(context.Context, uint64, uint64, func(context.Context, *block.Block) error) error
	// ProcessBlock processes an incoming block
	ProcessBlock(context.Context, string, *block.Block) error
	// SyncStatus report block sync status
	SyncStatus() (startingHeight uint64, currentHeight uint64, targetHeight uint64, syncSpeedDesc string)
}

BlockSync defines the interface of blocksyncer

func NewBlockSyncer

func NewBlockSyncer(
	cfg config.BlockSync,
	tipHeightHandler TipHeight,
	blockByHeightHandler BlockByHeight,
	commitBlockHandler CommitBlock,
	requestBlocksHandler RequestBlocks,
) (BlockSync, error)

NewBlockSyncer returns a new block syncer instance

func NewDummyBlockSyncer added in v1.6.3

func NewDummyBlockSyncer() BlockSync

NewDummyBlockSyncer creates a dummy BlockSync

type CommitBlock added in v1.2.0

type CommitBlock func(*block.Block) error

CommitBlock commits a block to blockchain

type RequestBlocks added in v1.2.0

type RequestBlocks func(ctx context.Context, start uint64, end uint64, repeat int)

RequestBlocks send a block request to peers

type TipHeight added in v1.2.0

type TipHeight func() uint64

TipHeight returns the tip height of blockchain

Jump to

Keyboard shortcuts

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