Documentation ¶
Index ¶
- Constants
- Variables
- func Discover(ctx context.Context, addr ma.Multiaddr, f func(ma.Multiaddr) (bool, error)) (bool, error)
- func NewConnectionBackoffError(err error, tryAfter time.Time) error
- func NewDisconnectError(err error) error
- func NewSwarmStreamName(protocol, version, stream string) string
- type ConnectionBackoffError
- type DebugService
- type DisconnectError
- type HandlerFunc
- type HandlerMiddleware
- type Headers
- type HeadlerFunc
- type IncompatibleStreamError
- type Peer
- type ProtocolSpec
- type Service
- type Stream
- type StreamSpec
- type Streamer
Constants ¶
const (
HeaderNameTracingSpanContext = "tracing-span-context"
)
Common header names.
Variables ¶
var ( // ErrPeerNotFound should be returned by p2p service methods when the requested // peer is not found. ErrPeerNotFound = errors.New("peer not found") // ErrAlreadyConnected is returned if connect was called for already connected node. ErrAlreadyConnected = errors.New("already connected") )
Functions ¶
func NewConnectionBackoffError ¶
NewConnectionBackoffError creates new `ConnectionBackoffError` with provided underlying error and `tryAfter` timestamp.
func NewDisconnectError ¶
NewDisconnectError wraps error and creates a special error that is treated specially by p2p. It causes peer to disconnect.
func NewSwarmStreamName ¶
NewSwarmStreamName constructs a libp2p compatible stream name out of protocol name and version and stream name.
Types ¶
type ConnectionBackoffError ¶
type ConnectionBackoffError struct {
// contains filtered or unexported fields
}
ConnectionBackoffError indicates that connection calls will not be executed until `tryAfter` timetamp. The reason is provided in the wrappped error.
func (*ConnectionBackoffError) Error ¶
func (e *ConnectionBackoffError) Error() string
Error implements function of the standard go error interface.
func (*ConnectionBackoffError) TryAfter ¶
func (e *ConnectionBackoffError) TryAfter() time.Time
TryAfter returns a tryAfter timetamp.
func (*ConnectionBackoffError) Unwrap ¶
func (e *ConnectionBackoffError) Unwrap() error
Unwrap returns an underlying error.
type DebugService ¶ added in v0.2.0
type DebugService interface { Service SetWelcomeMessage(val string) error GetWelcomeMessage() string }
DebugService extends the Service with method used for debugging.
type DisconnectError ¶
type DisconnectError struct {
// contains filtered or unexported fields
}
DisconnectError is an error that is specifically handled inside p2p. If returned by specific protocol handler it causes peer disconnect.
func (*DisconnectError) Error ¶
func (e *DisconnectError) Error() string
Error implements function of the standard go error interface.
func (*DisconnectError) Unwrap ¶
func (e *DisconnectError) Unwrap() error
Unwrap returns an underlying error.
type HandlerFunc ¶
HandlerFunc handles a received Stream from a Peer.
type HandlerMiddleware ¶
type HandlerMiddleware func(HandlerFunc) HandlerFunc
HandlerMiddleware decorates a HandlerFunc by returning a new one.
type HeadlerFunc ¶
HeadlerFunc is returning response headers based on the received request headers.
type IncompatibleStreamError ¶
type IncompatibleStreamError struct {
// contains filtered or unexported fields
}
IncompatibleStreamError is the error that should be returned by p2p service NewStream method when the stream or its version is not supported.
func NewIncompatibleStreamError ¶
func NewIncompatibleStreamError(err error) *IncompatibleStreamError
NewIncompatibleStreamError wraps the error that is the cause of stream incompatibility with IncompatibleStreamError that it can be detected and returns it.
func (*IncompatibleStreamError) Error ¶
func (e *IncompatibleStreamError) Error() string
Error implements function of the standard go error interface.
func (*IncompatibleStreamError) Unwrap ¶
func (e *IncompatibleStreamError) Unwrap() error
Unwrap returns an underlying error.
type ProtocolSpec ¶
type ProtocolSpec struct { Name string Version string StreamSpecs []StreamSpec }
ProtocolSpec defines a collection of Stream specifications with handlers.
type Service ¶
type Service interface { AddProtocol(ProtocolSpec) error // ConnectNotify connects to the given multiaddress and notifies the topology once the // peer has been successfully connected. ConnectNotify(ctx context.Context, addr ma.Multiaddr) (address *bzz.Address, err error) // Connect to a peer but do not notify topology about the established connection. Connect(ctx context.Context, addr ma.Multiaddr) (address *bzz.Address, err error) Disconnect(overlay swarm.Address) error Peers() []Peer AddNotifier(topology.Notifier) Addresses() ([]ma.Multiaddr, error) }
Service provides methods to handle p2p Peers and Protocols.
type StreamSpec ¶
type StreamSpec struct { Name string Handler HandlerFunc Headler HeadlerFunc }
StreamSpec defines a Stream handling within the protocol.
Directories ¶
Path | Synopsis |
---|---|
internal/handshake/pb
Package pb holds only Protocol Buffer definitions and generated code.
|
Package pb holds only Protocol Buffer definitions and generated code. |
internal/headers/pb
Package pb holds only Protocol Buffer definitions and generated code.
|
Package pb holds only Protocol Buffer definitions and generated code. |
internal/pb
Package pb holds only Protocol Buffer definitions and generated code for testing purposes.
|
Package pb holds only Protocol Buffer definitions and generated code for testing purposes. |