network

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GET   = "GET"
	POST  = "POST"
	PUT   = "PUT"
	PATCH = "PATCH"
)
View Source
const (
	PeerAdded   = "PeerAdded"
	PeerRemoved = "PeerRemoved"
)
View Source
const PeerFound = "PeerFound"

Variables

This section is empty.

Functions

func Discover

func Discover(ctx context.Context, host host.Host, dht *dht.IpfsDHT, protocol protocol.ID)

Discover searches for and connects to peers that support the given protocol ID. It initializes discovery via the DHT and advertises this node. It runs discovery in a loop with a ticker, re-advertising and finding new peers. For each discovered peer, it checks if already connected, and if not, dials them.

func Get added in v0.7.0

func Get(url string, headers map[string]string) ([]byte, error)

func GetBootNodesMultiAddress

func GetBootNodesMultiAddress(bootstrapNodes []string) ([]multiaddr.Multiaddr, error)

GetBootNodesMultiAddress returns the multiaddresses for the bootstrap nodes

func GetMultiAddressesForHost

func GetMultiAddressesForHost(host host.Host) ([]multiaddr.Multiaddr, error)

GetMultiAddressesForHost returns the multiaddresses for the host

func GetMultiAddressesForHostQuiet

func GetMultiAddressesForHostQuiet(host host.Host) []multiaddr.Multiaddr

GetMultiAddressesForHostQuiet returns the multiaddresses for the host without logging

func GetPriorityAddress

func GetPriorityAddress(addrs []multiaddr.Multiaddr) multiaddr.Multiaddr

GetPriorityAddress returns the best public or private IP address

func Patch added in v0.7.0

func Patch(url string, rawJSON json.RawMessage, headers map[string]string) ([]byte, error)

func Post added in v0.7.0

func Post(url string, rawJSON json.RawMessage, headers map[string]string) ([]byte, error)

func Put added in v0.7.0

func Put(url string, rawJSON json.RawMessage, headers map[string]string) ([]byte, error)

func WithDHT added in v0.7.0

func WithDHT(ctx context.Context, host host.Host, bootstrapNodes []multiaddr.Multiaddr, protocolId, prefix protocol.ID, peerChan chan PeerEvent, nodeData *pubsub.NodeData) (*dht.IpfsDHT, error)

func WithMDNS

func WithMDNS(host host.Host, rendezvous string, peerChan chan PeerEvent) error

Types

type PeerEvent

type PeerEvent struct {
	AddrInfo   peer.AddrInfo
	Action     string
	Source     string
	Rendezvous string
}

Jump to

Keyboard shortcuts

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