Documentation ¶
Index ¶
- Variables
- type AllowPeerFunc
- type Announce
- type Option
- type Receiver
- func (r *Receiver) Close() error
- func (r *Receiver) Direct(ctx context.Context, nextCid cid.Cid, peerID peer.ID, ...) error
- func (r *Receiver) Next(ctx context.Context) (Announce, error)
- func (r *Receiver) SetAllowPeer(allowPeer AllowPeerFunc)
- func (r *Receiver) TopicName() string
- func (r *Receiver) UncacheCid(adCid cid.Cid)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrClosed is returned from Next and Direct when the Received is closed. ErrClosed = errors.New("closed") )
Functions ¶
This section is empty.
Types ¶
type AllowPeerFunc ¶
AllowPeerFunc is the signature of a function given to Subscriber that determines whether to allow or reject messages originating from a peer passed into the function. Returning true or false indicates that messages from that peer are allowed rejected, respectively.
type Announce ¶
type Announce struct { // Cid is the advertisement content identifier to announce. Cid cid.Cid // PeerID is the p2p peer ID hosting the announced advertisement. PeerID peer.ID // Addrs is the network location(s) hosting the announced advertisement. Addrs []multiaddr.Multiaddr }
Announce contains information about the announcement of an index advertisement.
type Option ¶
type Option func(*config) error
func WithAllowPeer ¶
func WithAllowPeer(allowPeer AllowPeerFunc) Option
WithAllowPeer sets the function that determines whether to allow or reject messages from a peer.
func WithFilterIPs ¶
WithFilterIPs sets whether or not IP filtering is enabled. When enabled it removes any private, loopback, or unspecified IP multiaddrs from addresses supplied in announce messages.
func WithResend ¶
WithResend determines whether to resend direct announce mesages (those that are not received via pubsub) over pubsub.
type Receiver ¶
type Receiver struct {
// contains filtered or unexported fields
}
Receiver receives announce messages via gossip pubsub and HTTP. Receiver creates a single pubsub subscriber that receives messages from a gossip pubsub topic. Direct messages are received when the Receiver's Direct method is called.
func NewReceiver ¶
NewReceiver creates a new Receiver that subscribes to the named pubsub topic and is listening for announce messages.
func (*Receiver) Direct ¶
func (r *Receiver) Direct(ctx context.Context, nextCid cid.Cid, peerID peer.ID, addrs []multiaddr.Multiaddr) error
Direct handles a direct announce message, that was not arrived over pubsub. The message is resent over pubsub with the original peerID encoded into the message extra data.
func (*Receiver) Next ¶
Next waits for and returns the next announce message that has passed filtering checks. Next also returns ErrClosed if the receiver is closed, or the context error if the given context is canceled.
func (*Receiver) SetAllowPeer ¶
func (r *Receiver) SetAllowPeer(allowPeer AllowPeerFunc)
SetAllowPeer configures Subscriber with a function to evaluate whether to allow or reject messages from a peer. Setting nil removes any filtering and allows messages from all peers. Calling SetAllowPeer replaces any previously configured AllowPeerFunc.
func (*Receiver) UncacheCid ¶
func (r *Receiver) UncacheCid(adCid cid.Cid)
UncacheCid removes a CID from the announce cache.