libp2p

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package libp2p implements the Mir transport interface using libp2p.

Index

Constants

View Source
const (
	DefaultPermanentAddrTTL = time.Duration(math.MaxInt64 - iota)
)

Variables

View Source
var ErrNilStream = errors.New("stream has not been opened")
View Source
var ErrUnknownNode = errors.New("unknown node")

Functions

This section is empty.

Types

type Params

type Params struct {
	ProtocolID             protocol.ID
	MaxConnectingTimeout   time.Duration
	MaxRetryTimeout        time.Duration
	MaxRetries             int
	NoLoggingErrorAttempts int
	PermanentAddrTTL       time.Duration
	ConnWaitPollInterval   time.Duration
}

func DefaultParams

func DefaultParams() Params

type Transport

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

func NewTransport

func NewTransport(params Params, h host.Host, ownID types.NodeID, logger logging.Logger) (*Transport, error)

func (*Transport) ApplyEvents

func (t *Transport) ApplyEvents(ctx context.Context, eventList *events.EventList) error

func (*Transport) CloseOldConnections

func (t *Transport) CloseOldConnections(newNodes map[types.NodeID]types.NodeAddress)

func (*Transport) Connect

func (t *Transport) Connect(nodes map[types.NodeID]types.NodeAddress)

func (*Transport) ConnectSync

func (t *Transport) ConnectSync(nodes map[types.NodeID]types.NodeAddress, n int)

ConnectSync is a convenience method that triggers the connection process and waits for n connections to be established before returning. Equivalent to calling Connect and WaitFor.

func (*Transport) EventsOut

func (t *Transport) EventsOut() <-chan *events.EventList

func (*Transport) ImplementsModule

func (t *Transport) ImplementsModule()

func (*Transport) Send

func (t *Transport) Send(dest types.NodeID, msg *messagepb.Message) error

func (*Transport) Start

func (t *Transport) Start() error

func (*Transport) Stop

func (t *Transport) Stop()

func (*Transport) WaitFor

func (t *Transport) WaitFor(n int)

WaitFor polls the current connection state and returns when at least n connections have been established.

type TransportMessage

type TransportMessage struct {
	Sender  string
	Payload []byte
}

func (*TransportMessage) MarshalCBOR

func (t *TransportMessage) MarshalCBOR(w io.Writer) error

func (*TransportMessage) UnmarshalCBOR

func (t *TransportMessage) UnmarshalCBOR(r io.Reader) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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