service

package
v0.1.13-rc8 Latest Latest
Warning

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

Go to latest
Published: May 10, 2019 License: MIT Imports: 27 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrReadTimeout = fmt.Errorf("timed out reading response")

Functions

This section is empty.

Types

type Handler

type Handler interface {
	Protocol() protocol.ID
	Start()
	Ping(pid peer.ID) (PeerStatus, error)
	Handle(pid peer.ID, env *pb.Envelope) (*pb.Envelope, error)
	HandleStream(pid peer.ID, env *pb.Envelope) (chan *pb.Envelope, chan error, chan interface{})
}

Handler is used to handle messages for a specific protocol

type PeerStatus

type PeerStatus string

PeerStatus is the possible results from pinging another peer

const (
	PeerOnline  PeerStatus = "online"
	PeerOffline PeerStatus = "offline"
)

type Service

type Service struct {
	Account *keypair.Full
	Node    func() *core.IpfsNode
	// contains filtered or unexported fields
}

service represents a libp2p service

func NewService

func NewService(account *keypair.Full, handler Handler, node func() *core.IpfsNode) *Service

NewService returns a service for the given config

func (*Service) NewEnvelope

func (srv *Service) NewEnvelope(mtype pb.Message_Type, msg proto.Message, id *int32, response bool) (*pb.Envelope, error)

NewEnvelope returns a signed pb message for transport

func (*Service) NewError

func (srv *Service) NewError(code int, msg string, id int32) (*pb.Envelope, error)

NewError returns a signed pb error message

func (*Service) Ping

func (srv *Service) Ping(p peer.ID) (PeerStatus, error)

Ping pings another peer and returns status

func (*Service) SendHTTPMessage

func (srv *Service) SendHTTPMessage(addr string, pmes *pb.Envelope) error

SendHTTPMessage sends a message over HTTP

func (*Service) SendHTTPRequest

func (srv *Service) SendHTTPRequest(addr string, pmes *pb.Envelope) (*pb.Envelope, error)

SendHTTPRequest sends a request over HTTP

func (*Service) SendHTTPStreamRequest

func (srv *Service) SendHTTPStreamRequest(addr string, pmes *pb.Envelope) (chan *pb.Envelope, chan error, *func())

SendHTTPStreamRequest sends a request over HTTP

func (*Service) SendMessage

func (srv *Service) SendMessage(ctx context.Context, p peer.ID, pmes *pb.Envelope) error

SendMessage sends out a message

func (*Service) SendRequest

func (srv *Service) SendRequest(p peer.ID, pmes *pb.Envelope) (*pb.Envelope, error)

SendRequest sends out a request

func (*Service) Start

func (srv *Service) Start()

Start sets the peer host stream handler

func (*Service) VerifyEnvelope

func (srv *Service) VerifyEnvelope(env *pb.Envelope, pid peer.ID) error

VerifyEnvelope verifies the authenticity of an envelope

Jump to

Keyboard shortcuts

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