Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrClosed is returned from Next and Direct when the Received is closed. ErrClosed = errors.New("closed") )
Functions ¶
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
Option is a function that sets a value in a config.
func WithAllowPeer ¶
func WithAllowPeer(allowPeer AllowPeerFunc) Option
WithAllowPeer sets the function that determines whether to allow or reject messages from a peer. When not set or nil, allows messages from all peers.
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 ¶
Direct handles a direct announce message, that was not received over pubsub. The message is resent over pubsub with the original peerID encoded into the message extra data. The peerID and addrs are those of the advertisement publisher, since an announce message announces the availability of an advertisement and where to retrieve it from.
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) UncacheCid ¶
func (r *Receiver) UncacheCid(adCid cid.Cid)
UncacheCid removes a CID from the announce cache.