host

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: GPL-3.0 Imports: 30 Imported by: 1

Documentation

Index

Constants

View Source
const UDSDir = "sock"

Variables

This section is empty.

Functions

This section is empty.

Types

type HostImpl added in v0.15.2

type HostImpl interface {
	// AuthenticateMessage authenticates a message
	AuthenticateMessage(msg proto.Message, metadata *types.Metadata) bool

	// Close closes the node
	Close()

	// Connect to a peer
	Connect(pi peer.AddrInfo) error

	// HasRouting returns true if the node has routing
	HasRouting() error

	// Host returns the Host
	Host() host.Host

	// HostID returns the ID of the Host
	HostID() peer.ID

	// Join subsrcibes to a topic
	Join(topic string, opts ...ps.TopicOpt) (*ps.Topic, error)

	// NewStream opens a new stream to a peer
	NewStream(ctx context.Context, pid peer.ID, pids ...protocol.ID) (network.Stream, error)

	// NewTopic creates a new pubsub topic with event handler and subscription
	NewTopic(topic string, opts ...ps.TopicOpt) (*ps.Topic, *ps.TopicEventHandler, *ps.Subscription, error)

	// NeedsWait checks if state is Resumed or Paused and blocks channel if needed
	NeedsWait()

	// Pause tells all of goroutines to pause execution
	Pause()

	// Ping sends a ping to a peer to check if it is alive
	Ping(id string) error

	// Peer returns the peer of the node
	Peer() (*types.Peer, error)

	// Pubsub returns the pubsub of the node
	Pubsub() *ps.PubSub

	// Resume tells all of goroutines to resume execution
	Resume()

	// Role returns the role of the node
	Role() device.Role

	// Router returns the routing.Router
	Router(h host.Host) (routing.PeerRouting, error)

	// Routing returns the routing.Routing
	Routing() routing.Routing

	// PrivateKey returns the ed25519 private key instance of the libp2p host
	PrivateKey() (ed25519.PrivateKey, error)

	// SendMessage sends a message to a peer
	SendMessage(id peer.ID, p protocol.ID, data proto.Message) error

	// SetStreamHandler sets the handler for a protocol
	SetStreamHandler(protocol protocol.ID, handler network.StreamHandler)

	// SignData signs the data with the private key
	SignData(data []byte) ([]byte, error)

	// SignMessage signs a message with the node's private key
	SignMessage(message proto.Message) ([]byte, error)

	// VerifyData verifies the data signature
	VerifyData(data []byte, signature []byte, peerId peer.ID, pubKeyData []byte) bool
}

HostImpl returns the HostImpl for the Main Node

func NewHost

func NewHost(ctx context.Context, r device.Role, config *config.Config) (HostImpl, error)

NewHost Creates a Sonr libp2p Host with the given config

type HostStatus added in v0.15.2

type HostStatus int

HostStatus is the status of the host

const (
	Status_IDLE       HostStatus = iota // Host is idle, default state
	Status_STANDBY                      // Host is standby, waiting for connection
	Status_CONNECTING                   // Host is connecting
	Status_READY                        // Host is ready
	Status_FAIL                         // Host failed to connect
	Status_CLOSED                       // Host is closed
)

SNRHostStatus Definitions

func (HostStatus) Equals added in v0.15.2

func (s HostStatus) Equals(other HostStatus) bool

Equals returns true if given SNRHostStatus matches this one

func (HostStatus) IsClosed added in v0.15.2

func (s HostStatus) IsClosed() bool

IsClosed returns true if the SNRHostStatus == Status_CLOSED

func (HostStatus) IsConnecting added in v0.15.2

func (s HostStatus) IsConnecting() bool

IsConnecting returns true if the SNRHostStatus == Status_CONNECTING

func (HostStatus) IsFail added in v0.15.2

func (s HostStatus) IsFail() bool

IsFail returns true if the SNRHostStatus == Status_FAIL

func (HostStatus) IsNotIdle added in v0.15.2

func (s HostStatus) IsNotIdle() bool

IsNotIdle returns true if the SNRHostStatus != Status_IDLE

func (HostStatus) IsReady added in v0.15.2

func (s HostStatus) IsReady() bool

IsReady returns true if the SNRHostStatus == Status_READY

func (HostStatus) IsStandby added in v0.15.2

func (s HostStatus) IsStandby() bool

IsStandby returns true if the SNRHostStatus == Status_STANDBY

func (HostStatus) String added in v0.15.2

func (s HostStatus) String() string

String returns the string representation of the SNRHostStatus

type SockManager

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

func NewSockManager

func NewSockManager(path string) (*SockManager, error)

func (*SockManager) NewSockPath

func (sm *SockManager) NewSockPath() (string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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