Documentation ¶
Index ¶
- Constants
- func DefaultValidators(log zerolog.Logger, flowID flow.Identifier) []network.MessageValidator
- type Middleware
- func (m *Middleware) GetIPPort() (string, string, error)
- func (m *Middleware) IsConnected(nodeID flow.Identifier) (bool, error)
- func (m *Middleware) Me() flow.Identifier
- func (m *Middleware) NewBlobService(channel channels.Channel, ds datastore.Batching, ...) network.BlobService
- func (m *Middleware) NewPingService(pingProtocol protocol.ID, provider network.PingInfoProvider) network.PingService
- func (m *Middleware) Publish(msg *message.Message, channel channels.Channel) error
- func (m *Middleware) SendDirect(msg *message.Message, targetID flow.Identifier) (err error)
- func (m *Middleware) SetOverlay(ov network.Overlay)
- func (m *Middleware) Subscribe(channel channels.Channel) error
- func (m *Middleware) Unsubscribe(channel channels.Channel) error
- func (m *Middleware) UpdateNodeAddresses()
- type MiddlewareOption
Constants ¶
const ( // DefaultMaxUnicastMsgSize defines maximum message size in unicast mode for most messages DefaultMaxUnicastMsgSize = 10 * mb // 10 mb // LargeMsgMaxUnicastMsgSize defines maximum message size in unicast mode for large messages LargeMsgMaxUnicastMsgSize = gb // 1 gb // DefaultUnicastTimeout is the default maximum time to wait for a default unicast request to complete // assuming at least a 1mb/sec connection DefaultUnicastTimeout = 5 * time.Second // LargeMsgUnicastTimeout is the maximum time to wait for a unicast request to complete for large message size LargeMsgUnicastTimeout = 1000 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func DefaultValidators ¶
func DefaultValidators(log zerolog.Logger, flowID flow.Identifier) []network.MessageValidator
Types ¶
type Middleware ¶
Middleware handles the input & output on the direct connections we have to our neighbours on the peer-to-peer network.
func NewMiddleware ¶
func NewMiddleware( log zerolog.Logger, libP2PNode *p2pnode.Node, flowID flow.Identifier, met module.NetworkMetrics, bitswapMet module.BitswapMetrics, rootBlockID flow.Identifier, unicastMessageTimeout time.Duration, idTranslator p2p.IDTranslator, codec network.Codec, slashingViolationsConsumer slashing.ViolationsConsumer, opts ...MiddlewareOption, ) *Middleware
NewMiddleware creates a new middleware instance libP2PNodeFactory is the factory used to create a LibP2PNode flowID is this node's Flow ID metrics is the interface to report network related metrics unicastMessageTimeout is the timeout used for unicast messages connectionGating if set to True, restricts this node to only talk to other nodes which are part of the identity list validators are the set of the different message validators that each inbound messages is passed through During normal operations any error returned by Middleware.start is considered to be catastrophic and will be thrown by the irrecoverable.SignalerContext causing the node to crash.
func (*Middleware) GetIPPort ¶
func (m *Middleware) GetIPPort() (string, string, error)
GetIPPort returns the ip address and port number associated with the middleware All errors returned from this function can be considered benign.
func (*Middleware) IsConnected ¶
func (m *Middleware) IsConnected(nodeID flow.Identifier) (bool, error)
IsConnected returns true if this node is connected to the node with id nodeID. All errors returned from this function can be considered benign.
func (*Middleware) Me ¶
func (m *Middleware) Me() flow.Identifier
Me returns the flow identifier of this middleware
func (*Middleware) NewBlobService ¶
func (m *Middleware) NewBlobService(channel channels.Channel, ds datastore.Batching, opts ...network.BlobServiceOption) network.BlobService
func (*Middleware) NewPingService ¶
func (m *Middleware) NewPingService(pingProtocol protocol.ID, provider network.PingInfoProvider) network.PingService
func (*Middleware) Publish ¶
Publish publishes a message on the channel. It models a distributed broadcast where the message is meant for all or a many nodes subscribing to the channel. It does not guarantee the delivery though, and operates on a best effort. The following benign errors are expected during normal operations: - the msg cannot be marshalled. - the msg size exceeds DefaultMaxPubSubMsgSize. - the libP2P node fails to publish the message.
All errors returned from this function can be considered benign.
func (*Middleware) SendDirect ¶
func (m *Middleware) SendDirect(msg *message.Message, targetID flow.Identifier) (err error)
SendDirect sends msg on a 1-1 direct connection to the target ID. It models a guaranteed delivery asynchronous direct one-to-one connection on the underlying network. No intermediate node on the overlay is utilized as the router.
Dispatch should be used whenever guaranteed delivery to a specific target is required. Otherwise, Publish is a more efficient candidate.
The following benign errors can be returned: - he peer ID for the target node ID cannot be found. - the msg size was too large. - failed to send message to peer.
All errors returned from this function can be considered benign.
func (*Middleware) SetOverlay ¶
func (m *Middleware) SetOverlay(ov network.Overlay)
func (*Middleware) Subscribe ¶
func (m *Middleware) Subscribe(channel channels.Channel) error
Subscribe subscribes the middleware to a channel. No errors are expected during normal operation.
func (*Middleware) Unsubscribe ¶
func (m *Middleware) Unsubscribe(channel channels.Channel) error
Unsubscribe unsubscribes the middleware from a channel. The following benign errors are expected during normal operations from libP2P: - the libP2P node fails to unsubscribe to the topic created from the provided channel.
All errors returned from this function can be considered benign.
func (*Middleware) UpdateNodeAddresses ¶
func (m *Middleware) UpdateNodeAddresses()
type MiddlewareOption ¶
type MiddlewareOption func(*Middleware)
func WithMessageValidators ¶
func WithMessageValidators(validators ...network.MessageValidator) MiddlewareOption
func WithPreferredUnicastProtocols ¶
func WithPreferredUnicastProtocols(unicasts []unicast.ProtocolName) MiddlewareOption