wantlist

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: AGPL-3.0 Imports: 3 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

func SortEntries

func SortEntries(es []Entry)

SortEntries sorts the list of entries by priority.

Types

type Entry

type Entry struct {
	Want     auth.Want
	Priority int32
	WantType pb.Message_Wantlist_WantType
}

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

func NewRefEntry

func NewRefEntry(c auth.Want, p int32) Entry

NewRefEntry creates a new reference tracked wantlist entry.

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) Absorb

func (w *Wantlist) Absorb(other *Wantlist)

Absorb all the entries in other into this want list

func (*Wantlist) Add

func (w *Wantlist) Add(c auth.Want, priority int32, wantType pb.Message_Wantlist_WantType) bool

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

func (*Wantlist) Contains

func (w *Wantlist) Contains(c auth.Want) (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 auth.Want) bool

Remove removes the given cid from the wantlist.

func (*Wantlist) RemoveType

func (w *Wantlist) RemoveType(c auth.Want, wantType pb.Message_Wantlist_WantType) bool

Remove removes the given cid from the wantlist, respecting the type: Remove with want-have will not remove an existing want-block.

Jump to

Keyboard shortcuts

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