pin

package
v0.0.0-...-9ab2669 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

此源码被清华学神尹成大魔王专业翻译分析并修改 尹成QQ77025077 尹成微信18510341407 尹成所在QQ群721929980 尹成邮箱 yinc13@mails.tsinghua.edu.cn 尹成毕业于清华大学,微软区块链领域全球最有价值专家 https://mvp.microsoft.com/zh-cn/PublicProfile/4033620 package pin实现跟踪的结构和方法 用户希望将哪些对象保存在本地。

此源码被清华学神尹成大魔王专业翻译分析并修改 尹成QQ77025077 尹成微信18510341407 尹成所在QQ群721929980 尹成邮箱 yinc13@mails.tsinghua.edu.cn 尹成毕业于清华大学,微软区块链领域全球最有价值专家 https://mvp.microsoft.com/zh-cn/PublicProfile/4033620

Index

Constants

This section is empty.

Variables

View Source
var ErrNotPinned = fmt.Errorf("not pinned")

尝试取消固定未固定的项目时返回errnotpined。

Functions

func ModeToString

func ModeToString(mode Mode) (string, bool)

modetostring返回模式的可读名称。

Types

type Mode

type Mode int

模式允许指定不同类型的管脚(递归、直接等)。 有关完整列表,请参阅pin模式常量。

const (
	//递归管脚将目标CID与任何可到达的子级固定在一起。
	Recursive Mode = iota

	//直接插脚只是目标CID。
	Direct

	//间接管脚是具有递归固定祖先的CID。
	Indirect

	//内部管脚是用于保持管脚内部状态的CID。
	Internal

	//未被钉住的
	NotPinned

	//any指任何固定的cid
	Any
)

引脚模式

func StringToMode

func StringToMode(s string) (Mode, bool)

StringToMode将modetToString()的结果解析回模式。 它返回一个布尔值,如果模式未知,则设置为false。

type Pinned

type Pinned struct {
	Key  cid.Cid
	Mode Mode
	Via  cid.Cid
}

pinned表示用pinning策略固定的cid。 VIA字段允许在 如果该项不是直接固定的(而是递归固定的) 以某种优势)。

func (Pinned) Pinned

func (p Pinned) Pinned() bool

pinned返回给定的cid是否被pinned

func (Pinned) String

func (p Pinned) String() string

字符串以字符串形式返回pin状态

type Pinner

type Pinner interface {
	//is pinned返回给定的cid是否被固定
	//解释了它为什么会被钉住
	IsPinned(cid.Cid) (string, bool, error)

	//ispinnedwithType返回给定的cid是否与
	//给定的pin类型,以及返回其固定的pin类型。
	IsPinnedWithType(cid.Cid, Mode) (string, bool, error)

	//固定给定节点(可选递归)。
	Pin(ctx context.Context, node ipld.Node, recursive bool) error

	//解锁给定的CID。如果recursive为true,则移除递归或
	//直接销如果recursive为false,则只删除直接pin。
	Unpin(ctx context.Context, cid cid.Cid, recursive bool) error

	//更新将递归pin从一个cid更新到另一个cid
	//这比简单地固定新的和取消固定
	//旧的
	Update(ctx context.Context, from, to cid.Cid, unpin bool) error

	//检查一组键是否固定,是否比
	//为每个键调用ispinned
	CheckIfPinned(cids ...cid.Cid) ([]Pinned, error)

	//pinwithMode用于手动编辑pin结构。使用与
	//小心!如果使用不当,垃圾收集可能不会
	//成功。
	PinWithMode(cid.Cid, Mode)

	//removePinWithMode用于手动编辑销结构。
	//小心使用!如果使用不当,垃圾收集可能不会
	//成功。
	RemovePinWithMode(cid.Cid, Mode)

	//flush将pin状态写入备份数据存储
	Flush() error

	//DirectKeys返回所有直接固定的CID
	DirectKeys() []cid.Cid

	//DirectKeys返回所有递归固定的CID
	RecursiveKeys() []cid.Cid

	//InternalPins返回为
	//佩内尔
	InternalPins() []cid.Cid
}

Pinner提供了跟踪以下节点的必要方法: 本地保存,根据pin模式。在实践中,一个别针在 负责保存本地仓库的物品清单 不要被垃圾收集。

func LoadPinner

func LoadPinner(d ds.Datastore, dserv, internal ipld.DAGService) (Pinner, error)

LoadPinner从给定的数据存储区加载Pinner及其键集

func NewPinner

func NewPinner(dstore ds.Datastore, serv, internal ipld.DAGService) Pinner

NewPinner使用给定的数据存储作为后端创建一个新的Pinner

Directories

Path Synopsis
此源码被清华学神尹成大魔王专业翻译分析并修改 尹成QQ77025077 尹成微信18510341407 尹成所在QQ群721929980 尹成邮箱 yinc13@mails.tsinghua.edu.cn 尹成毕业于清华大学,微软区块链领域全球最有价值专家 https://mvp.microsoft.com/zh-cn/PublicProfile/4033620 包GC为Go IPF提供垃圾收集。
此源码被清华学神尹成大魔王专业翻译分析并修改 尹成QQ77025077 尹成微信18510341407 尹成所在QQ群721929980 尹成邮箱 yinc13@mails.tsinghua.edu.cn 尹成毕业于清华大学,微软区块链领域全球最有价值专家 https://mvp.microsoft.com/zh-cn/PublicProfile/4033620 包GC为Go IPF提供垃圾收集。
internal
pb
此源码被清华学神尹成大魔王专业翻译分析并修改 尹成QQ77025077 尹成微信18510341407 尹成所在QQ群721929980 尹成邮箱 yinc13@mails.tsinghua.edu.cn 尹成毕业于清华大学,微软区块链领域全球最有价值专家 https://mvp.microsoft.com/zh-cn/PublicProfile/4033620
此源码被清华学神尹成大魔王专业翻译分析并修改 尹成QQ77025077 尹成微信18510341407 尹成所在QQ群721929980 尹成邮箱 yinc13@mails.tsinghua.edu.cn 尹成毕业于清华大学,微软区块链领域全球最有价值专家 https://mvp.microsoft.com/zh-cn/PublicProfile/4033620

Jump to

Keyboard shortcuts

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