routedhost

package
Version: v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2020 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const AddressTTL = time.Second * 10

AddressTTL is the expiry time for our addresses. We expire them quickly.

Variables

This section is empty.

Functions

This section is empty.

Types

type RoutedHost

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

RoutedHost is a p2p Host that includes a routing system. This allows the Host to find the addresses for peers when it does not have them.

func Wrap

func Wrap(h host.Host, r Routing, logger *zap.Logger) *RoutedHost

Wrap is used to wrap a non-routed libp2px host, and leverage the content routing system to find peers if we do not alreayd know them

func (*RoutedHost) Addrs

func (rh *RoutedHost) Addrs() []ma.Multiaddr

Addrs returns all multiaddresses of the routed host

func (*RoutedHost) Close

func (rh *RoutedHost) Close() error

Close returns the routed host's libp2px host object

func (*RoutedHost) ConnManager

func (rh *RoutedHost) ConnManager() connmgr.ConnManager

ConnManager returns the underlying connection manager

func (*RoutedHost) Connect

func (rh *RoutedHost) Connect(ctx context.Context, pi peer.AddrInfo) error

Connect ensures there is a connection between this host and the peer with given peer.ID. See (host.Host).Connect for more information.

RoutedHost's Connect differs in that if the host has no addresses for a given peer, it will use its routing system to try to find some.

func (*RoutedHost) EventBus

func (rh *RoutedHost) EventBus() event.Bus

EventBus returns the routed host's event bus

func (*RoutedHost) ID

func (rh *RoutedHost) ID() peer.ID

ID returns the ID of the routed host

func (*RoutedHost) Mux

func (rh *RoutedHost) Mux() protocol.Switch

Mux returns the routed hosts's protocol muxer

func (*RoutedHost) Network

func (rh *RoutedHost) Network() network.Network

Network returns the network object of the routed host

func (*RoutedHost) NewStream

func (rh *RoutedHost) NewStream(ctx context.Context, p peer.ID, pids ...protocol.ID) (network.Stream, error)

NewStream is used to create a new stream

func (*RoutedHost) Peerstore

func (rh *RoutedHost) Peerstore() peerstore.Peerstore

Peerstore returns the routed host's underlying peerstore

func (*RoutedHost) RemoveStreamHandler

func (rh *RoutedHost) RemoveStreamHandler(pid protocol.ID)

RemoveStreamHandler is used to remove all stream handlers for the given protocol

func (*RoutedHost) SetStreamHandler

func (rh *RoutedHost) SetStreamHandler(pid protocol.ID, handler network.StreamHandler)

SetStreamHandler is used to add a supported protocol, and a handler for the protocol streams

func (*RoutedHost) SetStreamHandlerMatch

func (rh *RoutedHost) SetStreamHandlerMatch(pid protocol.ID, m func(string) bool, handler network.StreamHandler)

SetStreamHandlerMatch is used to set a match func for protocol stream handlers

type Routing

type Routing interface {
	FindPeer(context.Context, peer.ID) (peer.AddrInfo, error)
}

Routing is an interface that indicates we can find peers

Source Files

Jump to

Keyboard shortcuts

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