dht

package
v0.0.0-...-cc45bd3 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Content

type Content struct {
	CID cid.Cid
	// contains filtered or unexported fields
}

Content encapsulates multiple representations of the same data.

func NewRandomContent

func NewRandomContent() (*Content, error)

NewRandomContent reads 1024 bytes from crypto/rand and builds a content struct.

func (*Content) DistanceTo

func (c *Content) DistanceTo(peerID peer.ID) []byte

DistanceTo returns the XOR distance of the content to the provided peer ID as it is used in the libp2p Kademlia DHT.

type Host

type Host struct {
	host.Host

	DBHost       *models.Host
	DHT          *kaddht.IpfsDHT
	Bootstrapped *time.Time
	StartedAt    *time.Time
	Transports   []*wrap.Notifier
	MsgSender    *wrap.MessageSenderImpl
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, key crypto.PrivKey, network types.NetworkType) (*Host, error)

func (*Host) Bootstrap

func (h *Host) Bootstrap(ctx context.Context, network types.NetworkType) error

func (*Host) Close

func (h *Host) Close() error

func (*Host) IsRoutingTableListenerRegistered

func (h *Host) IsRoutingTableListenerRegistered(listener RoutingTableListener) bool

func (*Host) PeerID

func (h *Host) PeerID() string

func (*Host) RegisterRoutingTableListener

func (h *Host) RegisterRoutingTableListener(listener RoutingTableListener)

func (*Host) SaveNetworkSizeEstimate

func (h *Host) SaveNetworkSizeEstimate(avg float64, std float64, r2 float64, sampleCount int, cpl int, distances []float64, key string)

func (*Host) UnregisterRoutingTableListener

func (h *Host) UnregisterRoutingTableListener(listener RoutingTableListener)

type RoutingTableListener

type RoutingTableListener interface {
	PeerAdded(p peer.ID)
	PeerRemoved(p peer.ID)
	OnClose()
}

Jump to

Keyboard shortcuts

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