Documentation
¶
Index ¶
- Variables
- func ErrNilChannel(s string) error
- type BlockProducer
- type BlockState
- type Config
- type DigestHandler
- type Service
- func (s *Service) CreateBlockResponse(blockRequest *network.BlockRequestMessage) (*network.BlockResponseMessage, error)
- func (s *Service) HandleBlockAnnounce(msg *network.BlockAnnounceMessage) *network.BlockRequestMessage
- func (s *Service) HandleBlockResponse(msg *network.BlockResponseMessage) *network.BlockRequestMessage
- func (s *Service) HandleSeenBlocks(blockNum *big.Int) *network.BlockRequestMessage
- type StorageState
- type TransactionState
- type Verifier
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidBlock = errors.New("could not verify block")
ErrInvalidBlock is returned when a block cannot be verified
var ErrNilBlockState = errors.New("cannot have nil BlockState")
ErrNilBlockState is returned when BlockState is nil
var ErrNilRuntime = errors.New("cannot have nil runtime")
ErrNilRuntime is returned when trying to instantiate a Service or Syncer without a runtime
var ErrNilStorageState = errors.New("cannot have nil StorageState")
ErrNilStorageState is returned when StorageState is nil
var ErrNilVerifier = errors.New("cannot have nil Verifier")
ErrNilVerifier is returned when trying to instantiate a Syncer without a Verifier
var ErrServiceStopped = errors.New("service has been stopped")
ErrServiceStopped is returned when the service has been stopped
Functions ¶
func ErrNilChannel ¶
ErrNilChannel is returned if a channel is nil
Types ¶
type BlockProducer ¶
BlockProducer is the interface that a block production service must implement
type BlockState ¶
type BlockState interface {
BestBlockHash() common.Hash
BestBlockNumber() (*big.Int, error)
AddBlock(*types.Block) error
CompareAndSetBlockData(bd *types.BlockData) error
GetBlockByNumber(*big.Int) (*types.Block, 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)
}
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.LegacyInstance
Verifier Verifier
DigestHandler DigestHandler
}
Config is the configuration for the sync Service.
type DigestHandler ¶
type DigestHandler interface {
Start()
Stop()
HandleConsensusDigest(*types.ConsensusDigest) 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 ¶
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) *network.BlockRequestMessage
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) HandleBlockResponse ¶
func (s *Service) HandleBlockResponse(msg *network.BlockResponseMessage) *network.BlockRequestMessage
HandleBlockResponse handles a BlockResponseMessage by processing the blocks found in it and adding them to the BlockState if necessary. If the node is still not synced after processing, it creates and returns the next BlockRequestMessage to send.
func (*Service) HandleSeenBlocks ¶
func (s *Service) HandleSeenBlocks(blockNum *big.Int) *network.BlockRequestMessage
HandleSeenBlocks handles a block that is newly "seen" ie. a block that a peer claims to have through a StatusMessage
type StorageState ¶
type StorageState interface {
TrieState(root *common.Hash) (*state.TrieState, error)
StoreTrie(root common.Hash, ts *state.TrieState) error
}
StorageState is the interface for the storage state
type TransactionState ¶
TransactionState is the interface for transaction queue methods