Documentation ¶
Index ¶
- Constants
- Variables
- type Handler
- type PeerStatus
- type Service
- func (srv *Service) NewEnvelope(mtype pb.Message_Type, msg proto.Message, id *int32, response bool) (*pb.Envelope, error)
- func (srv *Service) NewError(code int, msg string, id int32) (*pb.Envelope, error)
- func (srv *Service) Ping(p string) (PeerStatus, error)
- func (srv *Service) SendHTTPStreamRequest(addr string, pmes *pb.Envelope, access string) (chan *pb.Envelope, chan error, *func())
- func (srv *Service) SendMessage(ctx context.Context, p string, pmes *pb.Envelope) error
- func (srv *Service) SendRequest(p string, pmes *pb.Envelope) (*pb.Envelope, error)
- func (srv *Service) Start()
- func (srv *Service) VerifyEnvelope(env *pb.Envelope, pid peer.ID) error
Constants ¶
View Source
const DefaultTimeout = time.Second * 30
DefaultTimeout is the context timeout for sending / requesting messages
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(env *pb.Envelope, pid peer.ID) (*pb.Envelope, error) HandleStream(env *pb.Envelope, pid peer.ID) (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 ¶
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) Ping ¶
func (srv *Service) Ping(p string) (PeerStatus, error)
Ping pings another peer and returns status
func (*Service) SendHTTPStreamRequest ¶
func (srv *Service) SendHTTPStreamRequest(addr string, pmes *pb.Envelope, access string) (chan *pb.Envelope, chan error, *func())
SendHTTPStreamRequest sends a request over HTTP
func (*Service) SendMessage ¶
SendMessage sends out a message
func (*Service) SendRequest ¶
SendRequest sends out a request
Click to show internal directories.
Click to hide internal directories.