import "github.com/perlin-network/noise/gossip"
Package gossip is a simple implementation of a gossip protocol for noise. It keeps track of a cache of messages sent/received to/from peers to avoid re-gossiping particular messages to specific peers.
type Events struct { // OnGossipReceived is called whenever new gossip is received from the network. An error may be return to // disconnect the sender sending you data; indicating that the gossip received is invalid. OnGossipReceived func(sender noise.ID, data []byte) error }
Events comprise of callbacks that may be hooked against by a user to handle inbound gossip messages/events that occur throughout the lifecycle of this gossip protocol.
Message is a message that is being pushed to nodes.
UnmarshalMessage deserializes data into a Message. It never throws an error.
Marshal implements noise.Serializable and serializes Message into a slice of bytes.
Option is a functional option that may be configured when instantiating a new instance of this gossip protocol.
WithEvents registers a batch of callbacks onto a single gossip protocol instance.
type Protocol struct {
// contains filtered or unexported fields
}
Protocol implements a simple gossiping protocol that avoids resending messages to peers that it already believes is aware of particular messages that are being gossiped.
New returns a new instance of a gossip protocol with 32MB of in-memory cache instantiated.
Bind registers a single message gossip.Message, and handles them by registering the (*Protocol).Handle Handler.
func (p *Protocol) Handle(ctx noise.HandlerContext) error
Handle implements noise.Protocol and handles gossip.Message messages.
Protocol returns a noise.Protocol that may registered to a node via (*noise.Node).Bind.
Push gossips a single message concurrently to all peers this node is aware of, on the condition that this node believes that the aforementioned peer has not received data before. A context may be provided to cancel Push, as it blocks the current goroutine until the gossiping of a single message is done. Any errors pushing a message to a particular peer is ignored.
Package gossip imports 5 packages (graph). Updated 2020-06-10. Refresh now. Tools for package owners.