keystore

package
v0.0.0-...-2eef10d Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

README

This the implement of ipfs keystore.

keystore is a module which store the key

we can store key in the mem or disk

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrKeyExists = fmt.Errorf("Key已经存在")
View Source
var ErrNoSuchKey = fmt.Errorf("Key不存在")

Functions

This section is empty.

Types

type FSKeystore

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

FSKeystore 将keystore存储在磁盘文件中

func NewFSKeystore

func NewFSKeystore(dir string) (*FSKeystore, error)

NewFSKeystore 创建FSKeystore文件夹

func (*FSKeystore) Delete

func (ks *FSKeystore) Delete(name string) error

Delete 从keystore当中删除key

func (*FSKeystore) Get

func (ks *FSKeystore) Get(name string) (ci.PrivKey, error)

Get 获取key的内容, 如果不存在,返回不存在错误

func (*FSKeystore) Has

func (ks *FSKeystore) Has(name string) (bool, error)

Has 方法返回key是否存在

func (*FSKeystore) List

func (ks *FSKeystore) List() ([]string, error)

List 返回key列表

func (*FSKeystore) Put

func (ks *FSKeystore) Put(name string, k ci.PrivKey) error

Put 将key存储在keystore当中。如果出现同名的key,则返回已存在错误

type Keystore

type Keystore interface {
	// 判断Key是否存在
	Has(string) (bool, error)
	// 将Key存储到keystore中, 如果已经存在相同名称的key,则返回已存在错误。
	Put(string, ci.PrivKey) error
	// 从keystore中获取key,如果不存在返回不存在错误
	Get(string) (ci.PrivKey, error)
	// 从Keystore中删除key
	Delete(string) error
	// 列出所有的key
	List() ([]string, error)
}

Keystore 提供了一个key管理的接口

type MemKeystore

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

MemKeystore 是内存存储

func NewMemKeystore

func NewMemKeystore() *MemKeystore

NewMemKeystore 创建hash表来存储key值

Jump to

Keyboard shortcuts

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