Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BroadcastFn ¶
type BroadcastFn func(context.Context, Notification) error
BroadcastFn aliases the function that broadcasts the DataHash.
type Notification ¶ added in v0.8.0
Notification is the format of message sent by Broadcaster
type PubSub ¶
type PubSub struct {
// contains filtered or unexported fields
}
PubSub manages receiving and propagating the EDS from/to the network over "eds-sub" subscription.
func (*PubSub) AddValidator ¶
func (s *PubSub) AddValidator(v ValidatorFn) error
AddValidator registers given ValidatorFn for EDS notifications. Any amount of Validators can be registered.
func (*PubSub) Broadcast ¶
func (s *PubSub) Broadcast(ctx context.Context, notification Notification) error
Broadcast sends the EDS notification (DataHash) to every connected peer.
func (*PubSub) Stop ¶
Stop completely stops the PubSub: * Unregisters all the added Validators * Closes the `ShrEx/Sub` topic
func (*PubSub) Subscribe ¶
func (s *PubSub) Subscribe() (*Subscription, error)
Subscribe provides a new Subscription for EDS notifications.
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
Subscription is a wrapper over pubsub.Subscription that handles receiving an EDS DataHash from other peers.
func (*Subscription) Next ¶
func (subs *Subscription) Next(ctx context.Context) (Notification, error)
Next blocks the caller until any new EDS DataHash notification arrives. Returns only notifications which successfully pass validation.
type ValidatorFn ¶ added in v0.8.0
type ValidatorFn func(context.Context, peer.ID, Notification) pubsub.ValidationResult
ValidatorFn is an injectable func and governs EDS notification msg validity. It receives the notification and sender peer and expects the validation result. ValidatorFn is allowed to be blocking for an indefinite time or until the context is canceled.