libp2p

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: BSD-3-Clause Imports: 59 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStream

func NewStream(s network.Stream) p2p.Stream

Types

type Options

type Options struct {
	PrivateKey     *ecdsa.PrivateKey
	NATAddr        string
	EnableWS       bool
	EnableQUIC     bool
	NodeMode       aurora.Model
	LightNodeLimit int
	KadBinMaxPeers int
	WelcomeMessage string
	Transaction    []byte
	// contains filtered or unexported fields
}

type Service

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

func New

func New(ctx context.Context, signer beecrypto.Signer, networkID uint64, overlay boson.Address, addr string, ab addressbook.Putter, storer storage.StateStorer, lightNodes *lightnode.Container, bootNodes *bootnode.Container, logger logging.Logger, tracer *tracing.Tracer, o Options) (*Service, error)

func (*Service) AddProtocol

func (s *Service) AddProtocol(p p2p.ProtocolSpec) (err error)

func (*Service) Addresses

func (s *Service) Addresses() (addreses []ma.Multiaddr, err error)

func (*Service) ApplyRoute added in v1.2.0

func (s *Service) ApplyRoute(self boson.Address, rt routetab.RelayStream, mode aurora.Model)

func (*Service) Blocklist

func (s *Service) Blocklist(overlay boson.Address, duration time.Duration, reason string) error

func (*Service) BlocklistRemove added in v1.3.2

func (s *Service) BlocklistRemove(overlay boson.Address) error

func (*Service) BlocklistedPeers

func (s *Service) BlocklistedPeers() ([]p2p.BlockPeers, error)

func (*Service) CallHandler added in v1.2.0

func (s *Service) CallHandler(ctx context.Context, last p2p.Peer, stream p2p.Stream) (relayData *pb.RouteRelayReq, w *p2p.WriterChan, r *p2p.ReaderChan, forward bool, err error)

func (*Service) CallHandlerWithConnChain added in v1.3.5

func (s *Service) CallHandlerWithConnChain(ctx context.Context, last, src p2p.Peer, stream p2p.Stream, protocolName, protocolVersion, streamName string) (err error)

func (*Service) Close

func (s *Service) Close() error

func (*Service) Connect

func (s *Service) Connect(ctx context.Context, addr ma.Multiaddr) (peer *p2p.Peer, err error)

func (*Service) Disconnect

func (s *Service) Disconnect(overlay boson.Address, reason string) error

func (*Service) GetWelcomeMessage

func (s *Service) GetWelcomeMessage() string

GetWelcomeMessage returns the value of the welcome message.

func (*Service) Halt

func (s *Service) Halt()

func (*Service) Metrics

func (s *Service) Metrics() []prometheus.Collector

func (*Service) NATAddresses added in v1.1.6

func (s *Service) NATAddresses() (addresses []net.Addr, err error)

func (*Service) NATManager

func (s *Service) NATManager() basichost.NATManager

func (*Service) NetworkStatus added in v1.3.4

func (s *Service) NetworkStatus() p2p.NetworkStatus

NetworkStatus implements the p2p.NetworkStatus interface.

func (*Service) NewConnChainRelayStream added in v1.3.5

func (s *Service) NewConnChainRelayStream(ctx context.Context, target boson.Address, headers p2p.Headers, protocolName, protocolVersion, streamName string) (p2p.Stream, error)

func (*Service) NewRelayStream added in v1.2.0

func (s *Service) NewRelayStream(ctx context.Context, target boson.Address, headers p2p.Headers, protocolName, protocolVersion, streamName string, midCall bool) (p2p.Stream, error)

func (*Service) NewStream

func (s *Service) NewStream(ctx context.Context, overlay boson.Address, headers p2p.Headers, protocolName, protocolVersion, streamName string) (p2p.Stream, error)

func (*Service) PeerID added in v1.3.3

func (s *Service) PeerID(overlay boson.Address) (id libp2ppeer.ID, found bool)

func (*Service) Peers

func (s *Service) Peers() []p2p.Peer

func (*Service) Ping

func (s *Service) Ping(ctx context.Context, addr ma.Multiaddr) (rtt time.Duration, err error)

func (*Service) Ready

func (s *Service) Ready() error

func (*Service) ResourceManager added in v1.3.3

func (s *Service) ResourceManager() network.ResourceManager

func (*Service) SetPickyNotifier

func (s *Service) SetPickyNotifier(n p2p.PickyNotifier)

func (*Service) SetWelcomeMessage

func (s *Service) SetWelcomeMessage(val string) error

SetWelcomeMessage sets the welcome message for the handshake protocol.

type UpnpAddressResolver

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

func (*UpnpAddressResolver) Resolve

func (r *UpnpAddressResolver) Resolve(observedAddress ma.Multiaddr) (ma.Multiaddr, error)

Resolve checks if there is a possible better advertisable underlay then the provided observed address. In some NAT situations, for example in the case when nodes are behind upnp, observer might send the observed address with a wrong port. In this case, observed address is compared to addresses provided by host, and if there is a same address but with different port, that one is used as advertisable address instead of provided observed one. TODO: this is a quickfix and it will be improved in the future

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.
headers/pb
Package pb holds only Protocol Buffer definitions and generated code.
Package pb holds only Protocol Buffer definitions and generated code.
reacher
Package reacher runs a background worker that will ping peers from an internal queue and report back the reachability to the notifier.
Package reacher runs a background worker that will ping peers from an internal queue and report back the reachability to the notifier.

Jump to

Keyboard shortcuts

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