hyperspace

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CosineSimilarity

func CosineSimilarity(a, b mat.Vector) float64

CosineSimilarity of two sparse vectors

func Hash

func Hash(b []byte) int32

Hash finds the bucket of a given byte slice between scaleMin and scaleMax TODO(geoah) Rewrite, most likely wrong

func HashChunked

func HashChunked(prefix string, o []byte) []int

HashChunked spilts input in chunks and hashes them individually TODO(geoah) Rewrite, most likely wrong as well

func SimpleSimilarity

func SimpleSimilarity(a, b *sparse.Vector) float64

SimpleSimilarity of two sparse vectors

func Vectorise

func Vectorise(q *peer.PeerInfoRequest) *sparse.Vector

Vectorise returns a sparse vector from a PeerInfoRequest

Types

type Discoverer

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

Discoverer hyperspace

func NewDiscoverer

func NewDiscoverer(
	ctx context.Context,
	network net.Network,
	exc exchange.Exchange,
	local *net.LocalInfo,
	bootstrapAddresses []string,
) (*Discoverer, error)

NewDiscoverer returns a new hyperspace discoverer

func (*Discoverer) FindByContent

func (r *Discoverer) FindByContent(
	ctx context.Context,
	contentHash string,
	opts ...discovery.Option,
) ([]*peer.PeerInfo, error)

FindByContent finds and returns peer infos from a content hash

func (*Discoverer) FindByFingerprint

func (r *Discoverer) FindByFingerprint(
	ctx context.Context,
	fingerprint string,
	opts ...discovery.Option,
) ([]*peer.PeerInfo, error)

FindByFingerprint finds and returns peer infos from a fingerprint

func (*Discoverer) LookupPeerInfo

func (r *Discoverer) LookupPeerInfo(
	ctx context.Context,
	q *peer.PeerInfoRequest,
) ([]*peer.PeerInfo, error)

LookupPeerInfo does a network lookup given a query

type Distance

type Distance interface {
	Compare()
}

type Store

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

Store holds peer capabilities with their vectors

func NewStore

func NewStore() *Store

NewStore retuns empty store

func (*Store) Add

func (s *Store) Add(cs ...*peer.PeerInfo)

Add peer capabilities to store

func (*Store) FindByContent

func (s *Store) FindByContent(contentHash string) []*peer.PeerInfo

FindByContent returns peers that match a given content hash

func (*Store) FindByFingerprint

func (s *Store) FindByFingerprint(fingerprint string) []*peer.PeerInfo

FindByFingerprint returns peers that are signed by a fingerprint

func (*Store) FindClosest

func (s *Store) FindClosest(q *peer.PeerInfoRequest) []*peer.PeerInfo

FindClosest returns peers that closest resemble the query

Jump to

Keyboard shortcuts

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