wantlist

package
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: Apache-2.0, MIT 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

This section is empty.

Types

type Entry

type Entry struct {
	Cid      cid.Cid
	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 cid.Cid, 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 cid.Cid, 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 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, sorted by priority.

DO NOT MODIFY. The returned list is cached.

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

func (w *Wantlist) RemoveType(c cid.Cid, 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