sync

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2021 License: LGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyRuntimeCode = errors.New("new :code is empty")

ErrEmptyRuntimeCode is returned when the storage :code is empty

View Source
var ErrInvalidBlock = errors.New("could not verify block")

ErrInvalidBlock is returned when a block cannot be verified

View Source
var ErrInvalidBlockRequest = errors.New("invalid block request")

ErrInvalidBlockRequest is returned when an invalid block request is received

View Source
var ErrNilBlockData = errors.New("got nil BlockData")

ErrNilBlockData is returned when trying to process a BlockResponseMessage with nil BlockData

View Source
var ErrNilBlockState = errors.New("cannot have nil BlockState")

ErrNilBlockState is returned when BlockState is nil

View Source
var ErrNilRuntime = errors.New("cannot have nil runtime")

ErrNilRuntime is returned when trying to instantiate a Service or Syncer without a runtime

View Source
var ErrNilStorageState = errors.New("cannot have nil StorageState")

ErrNilStorageState is returned when StorageState is nil

View Source
var ErrNilVerifier = errors.New("cannot have nil Verifier")

ErrNilVerifier is returned when trying to instantiate a Syncer without a Verifier

View Source
var ErrServiceStopped = errors.New("service has been stopped")

ErrServiceStopped is returned when the service has been stopped

Functions

func ErrNilChannel

func ErrNilChannel(s string) error

ErrNilChannel is returned if a channel is nil

Types

type BlockProducer

type BlockProducer interface {
	Pause() error
	Resume() error
	SetRuntime(rt runtime.Instance)
}

BlockProducer is the interface that a block production service must implement

type BlockState

type BlockState interface {
	BestBlockHash() common.Hash
	BestBlockHeader() (*types.Header, error)
	BestBlockNumber() (*big.Int, error)
	AddBlock(*types.Block) error
	CompareAndSetBlockData(bd *types.BlockData) error
	GetBlockByNumber(*big.Int) (*types.Block, error)
	HasBlockBody(hash common.Hash) (bool, error)
	GetBlockBody(common.Hash) (*types.Body, error)
	SetHeader(*types.Header) error
	GetHeader(common.Hash) (*types.Header, error)
	HasHeader(hash common.Hash) (bool, error)
	SubChain(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
	SetFinalizedHash(hash common.Hash, round, setID uint64) error
}

BlockState is the interface for the block state

type Config

type Config struct {
	LogLvl           log.Lvl
	BlockState       BlockState
	StorageState     StorageState
	BlockProducer    BlockProducer
	TransactionState TransactionState
	Runtime          runtime.Instance
	Verifier         Verifier
	DigestHandler    DigestHandler
}

Config is the configuration for the sync Service.

type DigestHandler

type DigestHandler interface {
	Start()
	Stop()
	HandleConsensusDigest(*types.ConsensusDigest, *types.Header) error
}

DigestHandler is the interface for the consensus digest handler

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(blockRequest *network.BlockRequestMessage) (*network.BlockResponseMessage, error)

CreateBlockResponse creates a block response message from a block request message

func (*Service) HandleBlockAnnounce

func (s *Service) HandleBlockAnnounce(msg *network.BlockAnnounceMessage) error

HandleBlockAnnounce creates a block request message from the block announce messages (block announce messages include the header but the full block is required to execute `core_execute_block`).

func (*Service) IsSynced added in v0.3.0

func (s *Service) IsSynced() bool

IsSynced exposes the synced state

func (*Service) ProcessBlockData added in v0.3.0

func (s *Service) ProcessBlockData(data []*types.BlockData) error

ProcessBlockData processes the BlockData from a BlockResponse and returns the index of the last BlockData it successfully handled.

type StorageState

type StorageState interface {
	TrieState(root *common.Hash) (*rtstorage.TrieState, error)
	StoreTrie(ts *rtstorage.TrieState) error
	LoadCodeHash(*common.Hash) (common.Hash, error)
}

StorageState is the interface for the storage state

type TransactionState

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

TransactionState is the interface for transaction queue methods

type Verifier

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

Verifier deals with block verification

Jump to

Keyboard shortcuts

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