Documentation
¶
Index ¶
- func ConstructModule(tp node.Type, cfg *Config) fx.Option
- func Flags() *flag.FlagSet
- func ParseFlags(cmd *cobra.Command, cfg *Config) error
- func ParseTrustedHashFlags(cmd *cobra.Command, cfg *Config) error
- func ParseTrustedPeerFlags(cmd *cobra.Command, cfg *Config) error
- func TrustedHashFlags() *flag.FlagSet
- func TrustedPeersFlags() *flag.FlagSet
- func WithMetrics(store libhead.Store[*header.ExtendedHeader], ...) error
- type API
- func (api *API) GetByHash(ctx context.Context, hash libhead.Hash) (*header.ExtendedHeader, error)
- func (api *API) GetByHeight(ctx context.Context, u uint64) (*header.ExtendedHeader, error)
- func (api *API) GetVerifiedRangeByHeight(ctx context.Context, from *header.ExtendedHeader, to uint64) ([]*header.ExtendedHeader, error)
- func (api *API) LocalHead(ctx context.Context) (*header.ExtendedHeader, error)
- func (api *API) NetworkHead(ctx context.Context) (*header.ExtendedHeader, error)
- func (api *API) SyncState(ctx context.Context) (sync.State, error)
- func (api *API) SyncWait(ctx context.Context) error
- type Config
- type InitStore
- type Module
- type Service
- func (s *Service) GetByHash(ctx context.Context, hash libhead.Hash) (*header.ExtendedHeader, error)
- func (s *Service) GetByHeight(ctx context.Context, height uint64) (*header.ExtendedHeader, error)
- func (s *Service) GetVerifiedRangeByHeight(ctx context.Context, from *header.ExtendedHeader, to uint64) ([]*header.ExtendedHeader, error)
- func (s *Service) LocalHead(ctx context.Context) (*header.ExtendedHeader, error)
- func (s *Service) NetworkHead(ctx context.Context) (*header.ExtendedHeader, error)
- func (s *Service) SyncState(context.Context) (sync.State, error)
- func (s *Service) SyncWait(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseFlags ¶
ParseFlags parses Header package flags from the given cmd and applies them to the passed config.
func ParseTrustedHashFlags ¶
ParseTrustedHashFlags parses Header package flags from the given cmd and saves them to the passed config.
func ParseTrustedPeerFlags ¶
ParseTrustedPeerFlags parses Header package flags from the given cmd and applies them to the passed config.
func TrustedHashFlags ¶
TrustedHashFlags returns a set of flags related to configuring a `TrustedHash`.
func TrustedPeersFlags ¶
TrustedPeersFlags returns a set of flags.
func WithMetrics ¶ added in v0.7.0
func WithMetrics( store libhead.Store[*header.ExtendedHeader], ex libhead.Exchange[*header.ExtendedHeader], sync *sync.Syncer[*header.ExtendedHeader], ) error
WithMetrics provides sets `MetricsEnabled` to true on ClientParameters for the header exchange
Types ¶
type API ¶ added in v0.5.0
type API struct {
Internal struct {
LocalHead func(context.Context) (*header.ExtendedHeader, error) `perm:"read"`
GetByHash func(
ctx context.Context,
hash libhead.Hash,
) (*header.ExtendedHeader, error) `perm:"public"`
GetVerifiedRangeByHeight func(
context.Context,
*header.ExtendedHeader,
uint64,
) ([]*header.ExtendedHeader, error) `perm:"public"`
GetByHeight func(context.Context, uint64) (*header.ExtendedHeader, error) `perm:"public"`
SyncState func(ctx context.Context) (sync.State, error) `perm:"read"`
SyncWait func(ctx context.Context) error `perm:"read"`
NetworkHead func(ctx context.Context) (*header.ExtendedHeader, error) `perm:"public"`
}
}
API is a wrapper around Module for the RPC. TODO(@distractedm1nd): These structs need to be autogenerated.
func (*API) GetByHeight ¶ added in v0.5.0
func (*API) GetVerifiedRangeByHeight ¶ added in v0.7.0
func (api *API) GetVerifiedRangeByHeight( ctx context.Context, from *header.ExtendedHeader, to uint64, ) ([]*header.ExtendedHeader, error)
func (*API) NetworkHead ¶ added in v0.7.0
type Config ¶
type Config struct {
// TrustedHash is the Block/Header hash that Nodes use as starting point for header synchronization.
// Only affects the node once on initial sync.
TrustedHash string
// TrustedPeers are the peers we trust to fetch headers from.
// Note: The trusted does *not* imply Headers are not verified, but trusted as reliable to fetch
// headers at any moment.
TrustedPeers []string
Store store.Parameters
Syncer sync.Parameters
Server p2p_exchange.ServerParameters
Client p2p_exchange.ClientParameters `toml:",omitempty"`
}
Config contains configuration parameters for header retrieval and management.
func DefaultConfig ¶
type InitStore ¶ added in v0.6.2
type InitStore libhead.Store[*header.ExtendedHeader]
InitStore is a type representing initialized header store. NOTE: It is needed to ensure that Store is always initialized before Syncer is started.
type Module ¶
type Module interface {
// LocalHead returns the ExtendedHeader of the chain head.
LocalHead(context.Context) (*header.ExtendedHeader, error)
// GetByHash returns the header of the given hash from the node's header store.
GetByHash(ctx context.Context, hash libhead.Hash) (*header.ExtendedHeader, error)
// GetVerifiedRangeByHeight returns the given range [from:to) of ExtendedHeaders
// from the node's header store and verifies that the returned headers are
// adjacent to each other.
GetVerifiedRangeByHeight(
ctx context.Context,
from *header.ExtendedHeader,
to uint64,
) ([]*header.ExtendedHeader, error)
// GetByHeight returns the ExtendedHeader at the given height, blocking
// until header has been processed by the store or context deadline is exceeded.
GetByHeight(context.Context, uint64) (*header.ExtendedHeader, error)
// SyncState returns the current state of the header Syncer.
SyncState(context.Context) (sync.State, error)
// SyncWait blocks until the header Syncer is synced to network head.
SyncWait(ctx context.Context) error
// NetworkHead provides the Syncer's view of the current network head.
NetworkHead(ctx context.Context) (*header.ExtendedHeader, error)
}
Module exposes the functionality needed for querying headers from the network. Any method signature changed here needs to also be changed in the API struct.
type Service ¶ added in v0.5.0
type Service struct {
// contains filtered or unexported fields
}
Service represents the header Service that can be started / stopped on a node. Service's main function is to manage its sub-services. Service can contain several sub-services, such as Exchange, ExchangeServer, Syncer, and so forth.
func (*Service) GetByHeight ¶ added in v0.5.0
func (*Service) GetVerifiedRangeByHeight ¶ added in v0.7.0
func (s *Service) GetVerifiedRangeByHeight( ctx context.Context, from *header.ExtendedHeader, to uint64, ) ([]*header.ExtendedHeader, error)