Documentation
¶
Index ¶
- Constants
- type Exchange
- func (ex *Exchange) Get(ctx context.Context, hash tmbytes.HexBytes) (*header.ExtendedHeader, error)
- func (ex *Exchange) GetByHeight(ctx context.Context, height uint64) (*header.ExtendedHeader, error)
- func (ex *Exchange) GetRangeByHeight(ctx context.Context, from, amount uint64) ([]*header.ExtendedHeader, error)
- func (ex *Exchange) Head(ctx context.Context) (*header.ExtendedHeader, error)
- type ExchangeServer
- type Subscriber
- func (p *Subscriber) AddValidator(val header.Validator) error
- func (p *Subscriber) Broadcast(ctx context.Context, header *header.ExtendedHeader, opts ...pubsub.PubOpt) error
- func (p *Subscriber) Start(context.Context) (err error)
- func (p *Subscriber) Stop(context.Context) error
- func (p *Subscriber) Subscribe() (header.Subscription, error)
Constants ¶
const PubSubTopic = "header-sub"
PubSubTopic hardcodes the name of the ExtendedHeader gossipsub topic.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Exchange ¶
type Exchange struct {
// contains filtered or unexported fields
}
Exchange enables sending outbound ExtendedHeaderRequests to the network as well as handling inbound ExtendedHeaderRequests from the network.
func NewExchange ¶
func (*Exchange) Get ¶
Get performs a request for the ExtendedHeader by the given hash corresponding to the RawHeader. Note that the ExtendedHeader must be verified thereafter.
func (*Exchange) GetByHeight ¶
GetByHeight performs a request for the ExtendedHeader at the given height to the network. Note that the ExtendedHeader must be verified thereafter.
func (*Exchange) GetRangeByHeight ¶
func (ex *Exchange) GetRangeByHeight(ctx context.Context, from, amount uint64) ([]*header.ExtendedHeader, error)
GetRangeByHeight performs a request for the given range of ExtendedHeaders to the network. Note that the ExtendedHeaders must be verified thereafter.
func (*Exchange) Head ¶
Head requests the latest ExtendedHeader. Note that the ExtendedHeader must be verified thereafter. NOTE: It is fine to continue handling head request if the timeout will be reached. As we are requesting head from multiple trusted peers, we may already have some headers when the timeout will be reached.
type ExchangeServer ¶
type ExchangeServer struct {
// contains filtered or unexported fields
}
ExchangeServer represents the server-side component for responding to inbound header-related requests.
func NewExchangeServer ¶
NewExchangeServer returns a new P2P server that handles inbound header-related requests.
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber manages the lifecycle and relationship of header Module with the "header-sub" gossipsub topic.
func NewSubscriber ¶
func NewSubscriber(ps *pubsub.PubSub) *Subscriber
NewSubscriber returns a Subscriber that manages the header Module's relationship with the "header-sub" gossipsub topic.
func (*Subscriber) AddValidator ¶
func (p *Subscriber) AddValidator(val header.Validator) error
AddValidator applies basic pubsub validator for the topic.
func (*Subscriber) Broadcast ¶
func (p *Subscriber) Broadcast(ctx context.Context, header *header.ExtendedHeader, opts ...pubsub.PubOpt) error
Broadcast broadcasts the given ExtendedHeader to the topic.
func (*Subscriber) Start ¶
func (p *Subscriber) Start(context.Context) (err error)
Start starts the Subscriber, registering a topic validator for the "header-sub" topic and joining it.
func (*Subscriber) Stop ¶
func (p *Subscriber) Stop(context.Context) error
Stop closes the topic and unregisters its validator.
func (*Subscriber) Subscribe ¶
func (p *Subscriber) Subscribe() (header.Subscription, error)
Subscribe returns a new subscription to the Subscriber's topic.