protocols

package
v0.38.0-preview.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 5, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FlowLibP2PProtocolCommonPrefix is the common prefix for all Libp2p protocol IDs used for Flow
	// ALL Flow libp2p protocols must start with this prefix.
	FlowLibP2PProtocolCommonPrefix = "/flow"

	FlowDHTProtocolIDPrefix = FlowLibP2PProtocolCommonPrefix + "/dht/"

	// FlowLibP2POneToOneProtocolIDPrefix is a unique Libp2p protocol ID prefix for Flow (https://docs.libp2p.io/concepts/protocols/)
	// All nodes communicate with each other using this protocol id suffixed with the id of the root block
	FlowLibP2POneToOneProtocolIDPrefix = FlowLibP2PProtocolCommonPrefix + "/push/"

	// FlowLibP2PPingProtocolPrefix is the Flow Ping protocol prefix
	FlowLibP2PPingProtocolPrefix = FlowLibP2PProtocolCommonPrefix + "/ping/"

	// FlowLibP2PProtocolGzipCompressedOneToOne represents the protocol id for compressed streams under gzip compressor.
	FlowLibP2PProtocolGzipCompressedOneToOne = FlowLibP2POneToOneProtocolIDPrefix + "/gzip/"
)

Flow Libp2p protocols

View Source
const GzipCompressionUnicast = ProtocolName("gzip-compression")

Variables

This section is empty.

Functions

func FlowDHTProtocolID

func FlowDHTProtocolID(sporkId flow.Identifier) protocol.ID

func FlowGzipProtocolId

func FlowGzipProtocolId(sporkId flow.Identifier) protocol.ID

func FlowProtocolID

func FlowProtocolID(sporkId flow.Identifier) protocol.ID

func FlowPublicDHTProtocolID

func FlowPublicDHTProtocolID(sporkId flow.Identifier) protocol.ID

func IsFlowProtocolStream

func IsFlowProtocolStream(s libp2pnet.Stream) bool

IsFlowProtocolStream returns true if the libp2p stream is for a Flow protocol

func PingProtocolId

func PingProtocolId(sporkId flow.Identifier) protocol.ID

Types

type GzipStream

type GzipStream struct {
	// contains filtered or unexported fields
}

GzipStream is a stream compression creates and returns a gzip-compressed stream out of input stream.

func NewGzipCompressedUnicast

func NewGzipCompressedUnicast(logger zerolog.Logger, sporkId flow.Identifier, defaultHandler libp2pnet.StreamHandler) *GzipStream

func (GzipStream) Handler

func (g GzipStream) Handler(s libp2pnet.Stream)

func (GzipStream) ProtocolId

func (g GzipStream) ProtocolId() protocol.ID

func (GzipStream) UpgradeRawStream

func (g GzipStream) UpgradeRawStream(s libp2pnet.Stream) (libp2pnet.Stream, error)

UpgradeRawStream wraps gzip compression and decompression around the plain libp2p stream.

type Protocol

type Protocol interface {
	// UpgradeRawStream wraps a specific unicast protocol implementation around
	// the plain libp2p stream.
	UpgradeRawStream(s libp2pnet.Stream) (libp2pnet.Stream, error)
	// Handler is a libp2p stream handler that implements the logic of handling
	// an established incoming stream to this node.
	Handler(stream libp2pnet.Stream)
	// ProtocolId returns the libp2p protocol id associated to this protocol. In libp2p
	// streams running with the same protocol are identified with the same  protocol id.
	ProtocolId() protocol.ID
}

Protocol represents a unicast protocol.

type ProtocolFactory

func ToProtocolFactory

func ToProtocolFactory(name ProtocolName) (ProtocolFactory, error)

type ProtocolName

type ProtocolName string

func ToProtocolNames

func ToProtocolNames(names []string) []ProtocolName

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL