Help us shape the future of Go! Take the 2026 Go Developer Survey

server

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ProtocolPrefix        = kaddht.ProtocolPrefix("/mos-dht")
	ConnectTickerInterval = 5 * time.Second
)

Functions

This section is empty.

Types

type Server

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

Server provides distributed hash table functionalities.

func New

func New(ctx context.Context, host kitnet.Host, keepers core.Keepers, cfg *config.AppConfig) (*Server, error)

New creates a new Server

func (*Server) Addr

func (dht *Server) Addr() string

Addr returns the p2p multiaddr of the dht host

func (*Server) Announce

func (dht *Server) Announce(objType int, repo string, key []byte, doneCB func(error)) bool

Announce a repository object

func (*Server) Bootstrap

func (dht *Server) Bootstrap() (err error)

Bootstrap attempts to connect to peers from the list of bootstrap peers

func (*Server) DHT

func (dht *Server) DHT() *kaddht.IpfsDHT

DHT returns the wrapped IPFS dht

func (*Server) GetProviders

func (dht *Server) GetProviders(ctx context.Context, key []byte) ([]peer.AddrInfo, error)

GetRepoObjectProviders finds peers that have announced their readiness to provide a value for the given key.

func (*Server) Host

func (dht *Server) Host() host.Host

Host returns the wrapped IPFS host

func (*Server) Lookup

func (dht *Server) Lookup(ctx context.Context, key string) ([]byte, error)

Lookup searches for a value corresponding to the given key

func (*Server) NewAnnouncerSession

func (dht *Server) NewAnnouncerSession() dht3.Session

NewAnnouncerSession creates an announcer session

func (*Server) ObjectStreamer

func (dht *Server) ObjectStreamer() dht3.Streamer

ObjectStreamer returns the commit streamer

func (*Server) Peers

func (dht *Server) Peers() (peers []string)

Peers returns a list of all peers

func (*Server) RegisterChecker

func (dht *Server) RegisterChecker(objType int, f dht3.CheckFunc)

RegisterChecker registers an object checker to the announcer.

func (*Server) Start

func (dht *Server) Start() error

Start starts the DHT

func (*Server) Stop

func (dht *Server) Stop() (err error)

Stop stops the server

func (*Server) Store

func (dht *Server) Store(ctx context.Context, key string, value []byte) error

Store adds a value corresponding to the given key. It will store the value locally even when an error occurred due to a lack of peer in the routing table.

Jump to

Keyboard shortcuts

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