wantlist

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package wantlist implements an object for bitswap that contains the keys that a given peer wants.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Cid      cid.Cid
	Priority int
}

Entry is an entry in a want list, consisting of a cid and its priority

func NewRefEntry

func NewRefEntry(c cid.Cid, p int) Entry

NewRefEntry creates a new reference tracked wantlist entry.

type SessionTrackedWantlist

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

SessionTrackedWantlist is a list of wants that also track which bitswap sessions have requested them

func NewSessionTrackedWantlist

func NewSessionTrackedWantlist() *SessionTrackedWantlist

NewSessionTrackedWantlist generates a new SessionTrackedWantList.

func (*SessionTrackedWantlist) Add

func (w *SessionTrackedWantlist) Add(c cid.Cid, priority int, ses uint64) bool

Add adds the given cid to the wantlist with the specified priority, governed by the session ID 'ses'. if a cid is added under multiple session IDs, then it must be removed by each of those sessions before it is no longer 'in the wantlist'. Calls to Add are idempotent given the same arguments. Subsequent calls with different values for priority will not update the priority. TODO: think through priority changes here Add returns true if the cid did not exist in the wantlist before this call (even if it was under a different session).

func (*SessionTrackedWantlist) AddEntry

func (w *SessionTrackedWantlist) AddEntry(e Entry, ses uint64) bool

AddEntry adds given Entry to the wantlist. For more information see Add method.

func (*SessionTrackedWantlist) Contains

func (w *SessionTrackedWantlist) Contains(k cid.Cid) (Entry, bool)

Contains returns true if the given cid is in the wantlist tracked by one or more sessions.

func (*SessionTrackedWantlist) CopyWants

CopyWants copies all wants from one SessionTrackWantlist to another (along with the session data)

func (*SessionTrackedWantlist) Entries

func (w *SessionTrackedWantlist) Entries() []Entry

Entries returns all wantlist entries for a given session tracked want list.

func (*SessionTrackedWantlist) Len

func (w *SessionTrackedWantlist) Len() int

Len returns the number of entries in a wantlist.

func (*SessionTrackedWantlist) Remove

func (w *SessionTrackedWantlist) Remove(c cid.Cid, ses uint64) bool

Remove removes the given cid from being tracked by the given session. 'true' is returned if this call to Remove removed the final session ID tracking the cid. (meaning true will be returned iff this call caused the value of 'Contains(c)' to change from true to false)

func (*SessionTrackedWantlist) SortedEntries

func (w *SessionTrackedWantlist) SortedEntries() []Entry

SortedEntries returns wantlist entries ordered by priority.

type Wantlist

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

Wantlist is a raw list of wanted blocks and their priorities

func New

func New() *Wantlist

New generates a new raw Wantlist

func (*Wantlist) Add

func (w *Wantlist) Add(c cid.Cid, priority int) bool

Add adds an entry in a wantlist from CID & Priority, if not already present.

func (*Wantlist) AddEntry

func (w *Wantlist) AddEntry(e Entry) bool

AddEntry adds an entry to a wantlist if not already present.

func (*Wantlist) Contains

func (w *Wantlist) Contains(c cid.Cid) (Entry, bool)

Contains returns the entry, if present, for the given CID, plus whether it was present.

func (*Wantlist) Entries

func (w *Wantlist) Entries() []Entry

Entries returns all wantlist entries for a want list.

func (*Wantlist) Len

func (w *Wantlist) Len() int

Len returns the number of entries in a wantlist.

func (*Wantlist) Remove

func (w *Wantlist) Remove(c cid.Cid) bool

Remove removes the given cid from the wantlist.

func (*Wantlist) SortedEntries

func (w *Wantlist) SortedEntries() []Entry

SortedEntries returns wantlist entries ordered by priority.

Jump to

Keyboard shortcuts

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