graph

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2021 License: MIT Imports: 31 Imported by: 1

Documentation

Overview

Package graph derives trust/block relations by consuming type:contact message and offers lookup APIs between two feeds.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogBuilder

func NewLogBuilder(logger kitlog.Logger, contacts margaret.Log) (*logBuilder, error)

NewLogBuilder is a much nicer abstraction than the direct k:v implementation. most likely terribly slow though. Additionally, we have to unmarshal from stored.Raw again... TODO: actually compare the two with benchmarks if only to compare the 3rd!

Types

type BadgerBuilder added in v0.2.1

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

BadgerBuilder can construct a graph from the badger key-value database it was initialized with.

func NewBuilder

func NewBuilder(log log.Logger, db *badger.DB, hmacSecret *[32]byte) *BadgerBuilder

NewBuilder creates a Builder that is backed by a badger database

func (*BadgerBuilder) Authorizer added in v0.2.1

func (b *BadgerBuilder) Authorizer(from refs.FeedRef, maxHops int) ssb.Authorizer

func (*BadgerBuilder) Build added in v0.2.1

func (b *BadgerBuilder) Build() (*Graph, error)

func (*BadgerBuilder) DeleteAuthor added in v0.2.1

func (b *BadgerBuilder) DeleteAuthor(who refs.FeedRef) error

func (*BadgerBuilder) DumpXMLOverHTTP added in v0.2.1

func (b *BadgerBuilder) DumpXMLOverHTTP(self refs.FeedRef, w http.ResponseWriter, req *http.Request)

func (*BadgerBuilder) Follows added in v0.2.1

func (b *BadgerBuilder) Follows(forRef refs.FeedRef) (*ssb.StrFeedSet, error)

func (*BadgerBuilder) Hops added in v0.2.1

func (b *BadgerBuilder) Hops(from refs.FeedRef, max int) *ssb.StrFeedSet

Hops returns a slice of feed refrences that are in a particulare range of from max == 0: only direct follows of from max == 1: max:0 + follows of friends of from max == 2: max:1 + follows of their friends

func (*BadgerBuilder) OpenContactsIndex added in v0.2.1

func (b *BadgerBuilder) OpenContactsIndex() (librarian.SeqSetterIndex, librarian.SinkIndex)

func (*BadgerBuilder) OpenMetafeedsIndex added in v0.2.1

func (b *BadgerBuilder) OpenMetafeedsIndex() (librarian.SeqSetterIndex, librarian.SinkIndex)

func (*BadgerBuilder) Subfeeds added in v0.2.1

func (b *BadgerBuilder) Subfeeds(forRef refs.FeedRef) (*ssb.StrFeedSet, error)

type Builder

type Builder interface {

	// Build a complete graph of all follow/block relations
	Build() (*Graph, error)

	// Follows returns a set of all people ref follows
	Follows(refs.FeedRef) (*ssb.StrFeedSet, error)

	// TODO: move this into the graph
	Hops(refs.FeedRef, int) *ssb.StrFeedSet

	Authorizer(from refs.FeedRef, maxHops int) ssb.Authorizer

	DeleteAuthor(who refs.FeedRef) error
}

Builder can build a trust graph and answer other questions

type ErrNoSuchFrom

type ErrNoSuchFrom struct {
	Who refs.FeedRef
}

ErrNoSuchFrom should only happen if you reconstruct your existing log from the network

func (ErrNoSuchFrom) Error

func (nsf ErrNoSuchFrom) Error() string

type Graph

type Graph struct {
	sync.Mutex
	*simple.WeightedDirectedGraph
	// contains filtered or unexported fields
}

func NewGraph

func NewGraph() *Graph

func (*Graph) Attributes

func (g *Graph) Attributes() []encoding.Attribute

func (*Graph) BlockedList

func (g *Graph) BlockedList(from refs.FeedRef) *ssb.StrFeedSet

func (*Graph) Blocks

func (g *Graph) Blocks(from, to refs.FeedRef) bool

func (*Graph) Follows

func (g *Graph) Follows(from, to refs.FeedRef) bool

func (*Graph) MakeDijkstra

func (g *Graph) MakeDijkstra(from refs.FeedRef) (*Lookup, error)

func (*Graph) NodeCount

func (g *Graph) NodeCount() int

func (*Graph) RenderSVG

func (g *Graph) RenderSVG(w io.Writer) error

func (*Graph) RenderSVGToFile

func (g *Graph) RenderSVGToFile(path string) error

func (*Graph) Subfeed added in v0.2.1

func (g *Graph) Subfeed(from, to refs.FeedRef) bool

type IndexingBuilder

type IndexingBuilder interface {
	Builder

	OpenIndex() (librarian.SeqSetterIndex, librarian.SinkIndex)
}

type Lookup

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

func (Lookup) Dist

func (l Lookup) Dist(to refs.FeedRef) ([]graph.Node, float64)

Jump to

Keyboard shortcuts

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