tangle

package
v0.0.0-...-bda66fc Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: ISC Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// MinimumWeight for new site.Sites
	MinimumWeight = 1
	// MinimumValidations specifies how many sites must be verified by a new site
	MinimumValidations = 2
	// MaxRecommendations specifies how many sites can be returned by RecommendTips
	MaxRecommendations = 4
)

Variables

View Source
var (
	// ErrWeightTooLow is returned when the weight does not exceed MinimumWeight
	ErrWeightTooLow = errors.New("Weight too low. Has to be > " + strconv.Itoa(MinimumWeight))
	// ErrNotValidating is returned when the site does not validate any current tip
	ErrNotValidating = errors.New("Site does not validate any current tip")
	// ErrTooFewValidations is returned when the site does not validate enough sites
	ErrTooFewValidations = errors.New("Site does not validate enough sites")
)

Functions

This section is empty.

Types

type Object

type Object struct {
	Site *site.Site
	Data datastore.Serializable
}

Object is the exposed site including the content

type Options

type Options struct {
	Store    store.Store
	DataPath string
}

Options are used for initial configuration

type Tangle

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

Tangle stores the relation between different transactions

func New

func New(o Options) (*Tangle, error)

New returns a fresh initialized tangle

func (*Tangle) Add

func (t *Tangle) Add(s *Object) error

Add Validates the site and adds it to the tangle to be valid, a site has to: * Validate at least one tip * Have a weight of at least MinimumWeight

func (*Tangle) Close

func (t *Tangle) Close()

Close closes the underlying store

func (*Tangle) Get

func (t *Tangle) Get(h hash.Hash) *Object

Get retrieves the specified site

func (*Tangle) GetSite

func (t *Tangle) GetSite(h hash.Hash) *site.Site

GetSite returns the site without any data

func (*Tangle) HasTip

func (t *Tangle) HasTip(h hash.Hash) bool

HasTip checks if the specified hash is a tip of the current tangle

func (*Tangle) Hashes

func (t *Tangle) Hashes() []hash.Hash

Hashes returns all stored hashes

func (*Tangle) Init

func (t *Tangle) Init(o Options) error

Init initializes the tangle with two genesis blocks

func (*Tangle) Inject

func (t *Tangle) Inject(s *Object, tip bool) error

Inject adds sites to the tangle without checking for validated tips

func (*Tangle) RecommendTips

func (t *Tangle) RecommendTips() []*site.Site

RecommendTips returns tips to be used

func (*Tangle) Search

func (t *Tangle) Search(s string) []*Object

Search performs a full text search for posts on the tangle

func (*Tangle) Size

func (t *Tangle) Size() int

Size returns the amount of sites in the tangle

func (*Tangle) Tips

func (t *Tangle) Tips() []*site.Site

Tips returns a list of unconfirmed tips

func (*Tangle) Weight

func (t *Tangle) Weight(s *site.Site) int

Weight returns the weight of a specific site inside the tangle

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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