Documentation
¶
Index ¶
- Constants
- Variables
- type HostOption
- type SNRHost
- func (h *SNRHost) AuthenticateId(id *wallet.UUID) (bool, error)
- func (n *SNRHost) AuthenticateMessage(msg proto.Message, metadata *common.Metadata) bool
- func (hn *SNRHost) Close() error
- func (hn *SNRHost) Connect(pi peer.AddrInfo) error
- func (hn *SNRHost) HandlePeerFound(pi peer.AddrInfo)
- func (h *SNRHost) HasRouting() error
- func (hn *SNRHost) Join(topic string, opts ...ps.TopicOpt) (*ps.Topic, error)
- func (hn *SNRHost) Router(h host.Host) (routing.PeerRouting, error)
- func (h *SNRHost) SendMessage(id peer.ID, p protocol.ID, data proto.Message) error
- func (hn *SNRHost) Serve()
- func (h *SNRHost) SetStatus(s SNRHostStatus)
- func (n *SNRHost) SignData(data []byte) ([]byte, error)
- func (n *SNRHost) SignMessage(message proto.Message) ([]byte, error)
- func (hn *SNRHost) Stat() (map[string]string, error)
- func (n *SNRHost) VerifyData(data []byte, signature []byte, peerId peer.ID, pubKeyData []byte) bool
- type SNRHostStatus
- func (s SNRHostStatus) Equals(other SNRHostStatus) bool
- func (s SNRHostStatus) IsClosed() bool
- func (s SNRHostStatus) IsConnecting() bool
- func (s SNRHostStatus) IsFail() bool
- func (s SNRHostStatus) IsNotIdle() bool
- func (s SNRHostStatus) IsReady() bool
- func (s SNRHostStatus) IsStandby() bool
- func (s SNRHostStatus) String() string
- type SockManager
Constants ¶
const (
Event_STATUS = "host-status"
)
Transfer Emission Events
const UDSDir = "sock"
Variables ¶
var ( ErrRoutingNotSet = errors.New("DHT and Host have not been set by Routing Function") ErrListenerRequired = errors.New("Listener was not Provided") ErrMDNSInvalidConn = errors.New("Invalid Connection, cannot begin MDNS Service") )
Error Definitions
Functions ¶
This section is empty.
Types ¶
type HostOption ¶
type HostOption func(hostOptions)
HostOption is a function that modifies the node options.
func WithConnOptions ¶
func WithConnOptions(low int, hi int, grace time.Duration) HostOption
WithConnOptions sets the connection manager options. Defaults are (lowWater: 15, highWater: 40, gracePeriod: 5m)
func WithConnection ¶
func WithConnection(c common.Connection) HostOption
WithConnection sets the connection to the host. Default is WIFI.
func WithInterval ¶
func WithInterval(interval time.Duration) HostOption
WithInterval sets the interval for the host. Default is 5 seconds.
func WithTTL ¶
func WithTTL(ttl time.Duration) HostOption
WithTTL sets the ttl for the host. Default is 2 minutes.
type SNRHost ¶
type SNRHost struct { host.Host // Discovery *dht.IpfsDHT *ps.PubSub // contains filtered or unexported fields }
SNRHost is the host wrapper for the Sonr Network
func NewHost ¶
func NewHost(ctx context.Context, options ...HostOption) (*SNRHost, error)
NewHost creates a new host
func (*SNRHost) AuthenticateId ¶
AuthenticateId verifies UUID value and signature
func (*SNRHost) AuthenticateMessage ¶
AuthenticateMessage Authenticates incoming p2p message
func (*SNRHost) HandlePeerFound ¶
HandlePeerFound is to be called when new peer is found
func (*SNRHost) HasRouting ¶
HasRouting returns no-error if the host is ready for connect
func (*SNRHost) Join ¶
Join wraps around PubSub.Join and returns topic. Checks wether the host is ready before joining.
func (*SNRHost) SendMessage ¶
SendMessage writes a protobuf go data object to a network stream
func (*SNRHost) SetStatus ¶
func (h *SNRHost) SetStatus(s SNRHostStatus)
SetStatus sets the host status and emits the event
func (*SNRHost) SignMessage ¶
SignMessage signs an outgoing p2p message payload
type SNRHostStatus ¶
type SNRHostStatus int
SNRHostStatus is the status of the host
const ( Status_IDLE SNRHostStatus = 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 (SNRHostStatus) Equals ¶
func (s SNRHostStatus) Equals(other SNRHostStatus) bool
Equals returns true if given SNRHostStatus matches this one
func (SNRHostStatus) IsClosed ¶
func (s SNRHostStatus) IsClosed() bool
IsClosed returns true if the SNRHostStatus == Status_CLOSED
func (SNRHostStatus) IsConnecting ¶
func (s SNRHostStatus) IsConnecting() bool
IsConnecting returns true if the SNRHostStatus == Status_CONNECTING
func (SNRHostStatus) IsFail ¶
func (s SNRHostStatus) IsFail() bool
IsFail returns true if the SNRHostStatus == Status_FAIL
func (SNRHostStatus) IsNotIdle ¶
func (s SNRHostStatus) IsNotIdle() bool
IsNotIdle returns true if the SNRHostStatus != Status_IDLE
func (SNRHostStatus) IsReady ¶
func (s SNRHostStatus) IsReady() bool
IsReady returns true if the SNRHostStatus == Status_READY
func (SNRHostStatus) IsStandby ¶
func (s SNRHostStatus) IsStandby() bool
IsStandby returns true if the SNRHostStatus == Status_STANDBY
func (SNRHostStatus) String ¶
func (s SNRHostStatus) 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)