sync

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: LGPL-3.0 Imports: 32 Imported by: 0

Documentation

Overview

Package sync is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrServiceStopped is returned when the service has been stopped
	ErrServiceStopped = errors.New("service has been stopped")

	// ErrInvalidBlock is returned when a block cannot be verified
	ErrInvalidBlock = errors.New("could not verify block")

	// ErrInvalidBlockRequest is returned when an invalid block request is received
	ErrInvalidBlockRequest = errors.New("invalid block request")
)
View Source
var ErrStopTimeout = errors.New("stop timeout")

Functions

func BuildBlock added in v0.7.0

func BuildBlock(t *testing.T, instance BuildBlockRuntime, parent *types.Header, ext types.Extrinsic) *types.Block

BuildBlock ...

Types

type BabeVerifier added in v0.7.0

type BabeVerifier interface {
	VerifyBlock(header *types.Header) error
}

BabeVerifier deals with BABE block verification

type BlockImportHandler added in v0.7.0

type BlockImportHandler interface {
	HandleBlockImport(block *types.Block, state *rtstorage.TrieState, announce bool) error
}

BlockImportHandler is the interface for the handler of newly imported blocks

type BlockState

type BlockState interface {
	BestBlockHeader() (*types.Header, error)
	BestBlockNumber() (number uint, err error)
	CompareAndSetBlockData(bd *types.BlockData) error
	GetBlockBody(common.Hash) (*types.Body, error)
	GetHeader(common.Hash) (*types.Header, error)
	HasHeader(hash common.Hash) (bool, error)
	Range(startHash, endHash common.Hash) (hashes []common.Hash, err error)
	RangeInMemory(start, end common.Hash) ([]common.Hash, error)
	GetReceipt(common.Hash) ([]byte, error)
	GetMessageQueue(common.Hash) ([]byte, error)
	GetJustification(common.Hash) ([]byte, error)
	SetJustification(hash common.Hash, data []byte) error
	GetHashByNumber(blockNumber uint) (common.Hash, error)
	GetBlockByHash(common.Hash) (*types.Block, error)
	GetRuntime(blockHash common.Hash) (runtime runtime.Instance, err error)
	StoreRuntime(blockHash common.Hash, runtime runtime.Instance)
	GetHighestFinalisedHeader() (*types.Header, error)
	GetFinalisedNotifierChannel() chan *types.FinalisationInfo
	GetHeaderByNumber(num uint) (*types.Header, error)
	GetAllBlocksAtNumber(num uint) ([]common.Hash, error)
	IsDescendantOf(parent, child common.Hash) (bool, error)
}

BlockState is the interface for the block state

type BuildBlockRuntime added in v0.8.0

type BuildBlockRuntime interface {
	InitializeBlock(header *types.Header) error
	FinalizeBlock() (*types.Header, error)
	InherentExtrinsics(data []byte) ([]byte, error)
	ApplyExtrinsic(data types.Extrinsic) ([]byte, error)
	ValidateTransaction(e types.Extrinsic) (*transaction.Validity, error)
}

BuildBlockRuntime is the runtime interface to interact with blocks and extrinsics.

type ChainSync added in v0.7.0

type ChainSync interface {
	// contains filtered or unexported methods
}

ChainSync contains the methods used by the high-level service into the `chainSync` module

type Config

type Config struct {
	LogLvl             log.Level
	Network            Network
	BlockState         BlockState
	StorageState       StorageState
	FinalityGadget     FinalityGadget
	TransactionState   TransactionState
	BlockImportHandler BlockImportHandler
	BabeVerifier       BabeVerifier
	MinPeers, MaxPeers int
	SlotDuration       time.Duration
	Telemetry          Telemetry
	BadBlocks          []string
	RequestMaker       network.RequestMaker
}

Config is the configuration for the sync Service.

type DisjointBlockSet added in v0.7.0

type DisjointBlockSet interface {
	// contains filtered or unexported methods
}

DisjointBlockSet represents a set of incomplete blocks, or blocks with an unknown parent. it is implemented by *disjointBlockSet

type FinalityGadget added in v0.7.0

type FinalityGadget interface {
	VerifyBlockJustification(common.Hash, []byte) error
}

FinalityGadget implements justification verification functionality

type MockRequestMaker added in v0.8.0

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

MockRequestMaker is a mock of RequestMaker interface.

func NewMockRequestMaker added in v0.8.0

func NewMockRequestMaker(ctrl *gomock.Controller) *MockRequestMaker

NewMockRequestMaker creates a new mock instance.

func (*MockRequestMaker) Do added in v0.8.0

Do mocks base method.

func (*MockRequestMaker) EXPECT added in v0.8.0

EXPECT returns an object that allows the caller to indicate expected use.

type MockRequestMakerMockRecorder added in v0.8.0

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

MockRequestMakerMockRecorder is the mock recorder for MockRequestMaker.

func (*MockRequestMakerMockRecorder) Do added in v0.8.0

func (mr *MockRequestMakerMockRecorder) Do(arg0, arg1, arg2 any) *gomock.Call

Do indicates an expected call of Do.

type Network added in v0.7.0

type Network interface {
	// Peers returns a list of currently connected peers
	Peers() []common.PeerInfo

	// ReportPeer reports peer based on the peer behaviour.
	ReportPeer(change peerset.ReputationChange, p peer.ID)

	AllConnectedPeersIDs() []peer.ID

	BlockAnnounceHandshake(*types.Header) error
}

Network is the interface for the network

type Service

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

Service deals with chain syncing by sending block request messages and watching for responses.

func NewService

func NewService(cfg *Config) (*Service, error)

NewService returns a new *sync.Service

func (*Service) CreateBlockResponse

func (s *Service) CreateBlockResponse(req *network.BlockRequestMessage) (*network.BlockResponseMessage, error)

CreateBlockResponse creates a block response message from a block request message

func (*Service) HandleBlockAnnounce

func (s *Service) HandleBlockAnnounce(from peer.ID, msg *network.BlockAnnounceMessage) error

HandleBlockAnnounce notifies the `chainSync` module that we have received a block announcement from the given peer.

func (*Service) HandleBlockAnnounceHandshake added in v0.7.0

func (s *Service) HandleBlockAnnounceHandshake(from peer.ID, msg *network.BlockAnnounceHandshake) error

HandleBlockAnnounceHandshake notifies the `chainSync` module that we have received a BlockAnnounceHandshake from the given peer.

func (*Service) HighestBlock added in v0.7.0

func (s *Service) HighestBlock() uint

HighestBlock gets the highest known block number

func (*Service) IsSynced added in v0.3.0

func (s *Service) IsSynced() bool

IsSynced exposes the synced state

func (*Service) Start added in v0.7.0

func (s *Service) Start() error

Start begins the chainSync and chainProcessor modules. It begins syncing in bootstrap mode

func (*Service) Stop added in v0.7.0

func (s *Service) Stop() error

Stop stops the chainSync and chainProcessor modules

type StorageState

type StorageState interface {
	TrieState(root *common.Hash) (*rtstorage.TrieState, error)
	sync.Locker
}

StorageState is the interface for the storage state

type Telemetry added in v0.8.0

type Telemetry interface {
	SendMessage(msg json.Marshaler)
}

Telemetry is the telemetry client to send telemetry messages.

type TransactionState

type TransactionState interface {
	RemoveExtrinsic(ext types.Extrinsic)
}

TransactionState is the interface for transaction queue methods

Jump to

Keyboard shortcuts

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