Documentation ¶
Index ¶
- Constants
- func MarshalExtendedHeaderRequest(in *ExtendedHeaderRequest) ([]byte, error)
- type Exchange
- func (ex *Exchange) RequestByHash(ctx context.Context, hash tmbytes.HexBytes) (*header.ExtendedHeader, error)
- func (ex *Exchange) RequestHead(ctx context.Context) (*header.ExtendedHeader, error)
- func (ex *Exchange) RequestHeader(ctx context.Context, height uint64) (*header.ExtendedHeader, error)
- func (ex *Exchange) RequestHeaders(ctx context.Context, from, amount uint64) ([]*header.ExtendedHeader, error)
- type ExchangeServer
- type ExtendedHeaderRequest
- 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 ¶
func MarshalExtendedHeaderRequest ¶
func MarshalExtendedHeaderRequest(in *ExtendedHeaderRequest) ([]byte, error)
MarshalExtendedHeaderRequest serializes the given ExtendedHeaderRequest to bytes using protobuf. Paired with UnmarshalExtendedHeaderRequest.
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 (*Exchange) RequestByHash ¶
func (*Exchange) RequestHead ¶
func (*Exchange) RequestHeader ¶
func (*Exchange) RequestHeaders ¶
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 ¶
func NewExchangeServer(host host.Host, store header.Store) *ExchangeServer
NewExchangeServer returns a new P2P server that handles inbound header-related requests.
type ExtendedHeaderRequest ¶
type ExtendedHeaderRequest struct { Origin uint64 // block height from which to request ExtendedHeaders Amount uint64 // amount of desired ExtendedHeaders starting from Origin, syncing in ascending order }
ExtendedHeaderRequest is the packet format for nodes to request ExtendedHeaders from the network.
func UnmarshalExtendedHeaderRequest ¶
func UnmarshalExtendedHeaderRequest(data []byte) (*ExtendedHeaderRequest, error)
UnmarshalExtendedHeaderRequest deserializes given data into a new ExtendedHeader using protobuf. Paired with MarshalExtendedHeaderRequest.
func (*ExtendedHeaderRequest) MarshalBinary ¶
func (ehr *ExtendedHeaderRequest) MarshalBinary() ([]byte, error)
MarshalBinary marshals ExtendedHeaderRequest to binary.
func (*ExtendedHeaderRequest) ToProto ¶
func (ehr *ExtendedHeaderRequest) ToProto() *p2p_pb.ExtendedHeaderRequest
func (*ExtendedHeaderRequest) UnmarshalBinary ¶
func (ehr *ExtendedHeaderRequest) UnmarshalBinary(data []byte) error
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber manages the lifecycle and relationship of header Service with the "header-sub" gossipsub topic.
func NewSubscriber ¶
func NewSubscriber(ps *pubsub.PubSub) *Subscriber
NewSubscriber returns a Subscriber that manages the header Service'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.