Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
e0e856aa
提交
e0e856aa
authored
1月 21, 2018
作者:
Jeromy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
data storage interfaces
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
上级
ce57a766
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
38 行增加
和
1 行删除
+38
-1
blockstore.go
blocks/blockstore/blockstore.go
+7
-0
blockservice.go
blockservice/blockservice.go
+14
-1
repo.go
repo/repo.go
+17
-0
没有找到文件。
blocks/blockstore/blockstore.go
浏览文件 @
e0e856aa
...
...
@@ -40,12 +40,19 @@ type Blockstore interface {
DeleteBlock
(
*
cid
.
Cid
)
error
Has
(
*
cid
.
Cid
)
(
bool
,
error
)
Get
(
*
cid
.
Cid
)
(
blocks
.
Block
,
error
)
// Put puts a given block to the underlying datastore
Put
(
blocks
.
Block
)
error
// PutMany puts a slice of blocks at the same time using batching
// capabilities of the underlying datastore whenever possible.
PutMany
([]
blocks
.
Block
)
error
// AllKeysChan returns a channel from which
// the CIDs in the Blockstore can be read. It should respect
// the given context, closing the channel if it becomes Done.
AllKeysChan
(
ctx
context
.
Context
)
(
<-
chan
*
cid
.
Cid
,
error
)
// HashOnRead specifies if every read block should be
// rehashed to make sure it matches its CID.
HashOnRead
(
enabled
bool
)
...
...
blockservice/blockservice.go
浏览文件 @
e0e856aa
...
...
@@ -25,13 +25,26 @@ var ErrNotFound = errors.New("blockservice: key not found")
// datastore and may retrieve data from a remote Exchange.
// It uses an internal `datastore.Datastore` instance to store values.
type
BlockService
interface
{
// Blockstore returns a reference to the underlying blockstore
Blockstore
()
blockstore
.
Blockstore
// Exchange returns a reference to the underlying exchange (usually bitswap)
Exchange
()
exchange
.
Interface
// AddBlock puts a given block to the underlying datastore
AddBlock
(
o
blocks
.
Block
)
(
*
cid
.
Cid
,
error
)
// AddBlocks adds a slice of blocks at the same time using batching
// capabilities of the underlying datastore whenever possible.
AddBlocks
(
bs
[]
blocks
.
Block
)
([]
*
cid
.
Cid
,
error
)
GetBlock
(
ctx
context
.
Context
,
c
*
cid
.
Cid
)
(
blocks
.
Block
,
error
)
GetBlocks
(
ctx
context
.
Context
,
ks
[]
*
cid
.
Cid
)
<-
chan
blocks
.
Block
DeleteBlock
(
o
blocks
.
Block
)
error
// GetBlocks does a batch request for the given cids, returning blocks as
// they are found, in no particular order.
GetBlocks
(
ctx
context
.
Context
,
ks
[]
*
cid
.
Cid
)
<-
chan
blocks
.
Block
Close
()
error
}
...
...
repo/repo.go
浏览文件 @
e0e856aa
...
...
@@ -16,24 +16,41 @@ var (
ErrApiNotRunning
=
errors
.
New
(
"api not running"
)
)
// Repo represents all persistent data of a given ipfs node.
type
Repo
interface
{
// Config returns the ipfs configuration file from the repo. Changes made
// to the returned config are not automatically persisted.
Config
()
(
*
config
.
Config
,
error
)
// BackupConfig creates a backup of the current configuration file using
// the given prefix for naming.
BackupConfig
(
prefix
string
)
(
string
,
error
)
// SetConfig persists the given configuration struct to storage.
SetConfig
(
*
config
.
Config
)
error
// SetConfigKey sets the given key-value pair within the config and persists it to storage.
SetConfigKey
(
key
string
,
value
interface
{})
error
// GetConfigKey reads the value for the given key from the configuration in storage.
GetConfigKey
(
key
string
)
(
interface
{},
error
)
// Datastore returns a reference to the configured data storage backend.
Datastore
()
Datastore
// GetStorageUsage returns the number of bytes stored.
GetStorageUsage
()
(
uint64
,
error
)
// Keystore returns a reference to the key management interface.
Keystore
()
keystore
.
Keystore
// FileManager returns a reference to the filestore file manager.
FileManager
()
*
filestore
.
FileManager
// SetAPIAddr sets the API address in the repo.
SetAPIAddr
(
addr
ma
.
Multiaddr
)
error
// SwarmKey returns the configured shared symmetric key for the private networks feature.
SwarmKey
()
([]
byte
,
error
)
io
.
Closer
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论