addrproto

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: Apache-2.0, MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryAddrProtocol = "/fcr-calibr/peernet/addr/query"
	ProtocolVersion   = "/0.0.1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddrProtocol

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

AddrProtocol manages addr protocol. It handles resolving peer addr.

func NewAddrProtocol

func NewAddrProtocol(
	h host.Host,
	dht *dual.DHT,
	signer crypto.Signer,
	peerMgr peermgr.PeerManager,
	opts Opts,
) *AddrProtocol

NewAddrProtocol creates a new addr protocol.

@input - host, dht, signer, peer manager.

func (*AddrProtocol) ConnectToPeer

func (p *AddrProtocol) ConnectToPeer(ctx context.Context, currencyID byte, toAddr string) (peer.ID, error)

ConnectToPeer attempts to establish a connection to peer with given currency id and recipient address pair.

@input - context, operation timeout, io timeout, currency id, to addr.

@output - peer addr id, error.

func (*AddrProtocol) Publish

func (p *AddrProtocol) Publish(ctx context.Context) error

Publish the presence to the network immediately.

@input - context.

@output - error.

func (*AddrProtocol) QueryAddr

func (proto *AddrProtocol) QueryAddr(ctx context.Context, currencyID byte, pi peer.AddrInfo) (string, error)

QueryAddr is used to query the recipient address of given currency id for a given peer address.

@input - context, currency id, peer address.

@output - recipient address, error.

func (*AddrProtocol) Shutdown

func (p *AddrProtocol) Shutdown()

Shutdown safely shuts down the component.

type Opts

type Opts struct {
	// The timeout for every network io operation.
	IOTimeout time.Duration

	// The timeout for every internal operation.
	OpTimeout time.Duration

	// The publish frequency.
	PublishFreq time.Duration
}

Opts is the options for offer protocol.

Jump to

Keyboard shortcuts

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