Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyRuntimeCode = errors.New("new :code is empty")
ErrEmptyRuntimeCode is returned when the storage :code is empty
var ErrInvalidBlock = errors.New("could not verify block")
ErrInvalidBlock is returned when a block cannot be verified
var ErrInvalidBlockRequest = errors.New("invalid block request")
ErrInvalidBlockRequest is returned when an invalid block request is received
var ErrNilBlockData = errors.New("got nil BlockData")
ErrNilBlockData is returned when trying to process a BlockResponseMessage with nil BlockData
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 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 ¶
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`).
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 ¶
TransactionState is the interface for transaction queue methods