network

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProtocolMessenger

type ProtocolMessenger struct {
	SelfAddrInfo       address.PeerAddressInfo // The self Address Information.
	SelfAddrSerialized string                  // The Self Address, serialized in serialized address format.
	RequestDeadline    time.Duration           // The request deadline
	Context            context.Context         // The context of the messenger.
	CancelFunc         context.CancelFunc      // The cancel func
}

func NewProtocolMessenger

func NewProtocolMessenger(addr address.PeerAddressInfo, deadline time.Duration) (*ProtocolMessenger, error)

NewProtocolMessenger returns a ProtocolMessenger Ready for use. Currently there is no dependency on Kad host. Can be directly used as client as well.

func (*ProtocolMessenger) FindNodes

func (p *ProtocolMessenger) FindNodes(info address.PeerAddressInfo, target []byte, k int) (*messaging.FindNodesResponse, error)

func (*ProtocolMessenger) FindProvider

func (*ProtocolMessenger) Get

func (*ProtocolMessenger) Ping

func (*ProtocolMessenger) Provide

func (*ProtocolMessenger) Put

func (p *ProtocolMessenger) Put(info address.PeerAddressInfo, key []byte, value []byte) (*messaging.PutResponse, error)

func (*ProtocolMessenger) Stop

func (p *ProtocolMessenger) Stop()

type Server

type Server struct {
	messaging.UnimplementedKademliaMessengerServer                        // Embedding for "Unimplemented" forward compatibility
	RoutingController                              *routing.Controller    // The Controller for peer routing
	ProviderStore                                  *prstore.ProviderStore // The controller for content routing
	ValueStore                                     *vstore.ValueStore     // the controller for decentralized KV store
	Port                                           int32                  // port of  service
	RPCCoreServer                                  *grpc.Server           // the RPC server
}

Server handles the wire communication. TODO: Add request validation stream interpreter may be

func NewServer

func NewServer(prController *routing.Controller, crController *prstore.ProviderStore,
	vsController *vstore.ValueStore, port int32) *Server

func (*Server) FindNodes

func (*Server) FindProvider

func (*Server) Get

func (*Server) MaybeAddToPeerStore

func (s *Server) MaybeAddToPeerStore(node string)

MaybeAddToPeerStore When a request is received, maybe add it to the peer store

func (*Server) Ping

func (*Server) Provide

func (*Server) Put

func (*Server) StartServing

func (s *Server) StartServing()

func (*Server) StopServing

func (s *Server) StopServing()

Jump to

Keyboard shortcuts

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