Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
45d4b1a8
提交
45d4b1a8
authored
7月 16, 2015
作者:
Jeromy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixup datastore interfaces
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
上级
3ffebd94
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
26 行增加
和
40 行删除
+26
-40
Godeps.json
Godeps/Godeps.json
+4
-0
blockstore.go
blocks/blockstore/blockstore.go
+2
-4
core.go
core/core.go
+2
-3
core.go
core/corerouting/core.go
+3
-2
defaultds.go
repo/fsrepo/defaultds.go
+8
-27
repo.go
repo/repo.go
+1
-2
none_client.go
routing/none/none_client.go
+2
-2
datastore.go
thirdparty/s3-datastore/datastore.go
+4
-0
没有找到文件。
Godeps/Godeps.json
浏览文件 @
45d4b1a8
...
...
@@ -166,7 +166,11 @@
},
{
"ImportPath"
:
"github.com/jbenet/go-datastore"
,
<<<<<<<
HEAD
"Rev"
:
"c835c30f206c1e97172e428f052e225adab9abde"
=======
"Rev"
:
"47af23f2ad09237ccc09c586c118048e2b39b358"
>>>>>>>
fixup
datastore
interfaces
},
{
"ImportPath"
:
"github.com/jbenet/go-detect-race"
,
...
...
blocks/blockstore/blockstore.go
浏览文件 @
45d4b1a8
...
...
@@ -25,7 +25,7 @@ var ValueTypeMismatch = errors.New("The retrieved value is not a Block")
var
ErrNotFound
=
errors
.
New
(
"blockstore: block not found"
)
// Blockstore wraps a
ThreadSafe
Datastore
// Blockstore wraps a Datastore
type
Blockstore
interface
{
DeleteBlock
(
key
.
Key
)
error
Has
(
key
.
Key
)
(
bool
,
error
)
...
...
@@ -51,7 +51,7 @@ type GCBlockstore interface {
PinLock
()
func
()
}
func
NewBlockstore
(
d
ds
.
Datastore
)
*
blockstore
{
func
NewBlockstore
(
d
ds
.
Batching
)
*
blockstore
{
dd
:=
dsns
.
Wrap
(
d
,
BlockPrefix
)
return
&
blockstore
{
datastore
:
dd
,
...
...
@@ -60,8 +60,6 @@ func NewBlockstore(d ds.Datastore) *blockstore {
type
blockstore
struct
{
datastore
ds
.
Batching
// cant be ThreadSafeDatastore cause namespace.Datastore doesnt support it.
// we do check it on `NewBlockstore` though.
lk
sync
.
RWMutex
}
...
...
core/core.go
浏览文件 @
45d4b1a8
...
...
@@ -17,7 +17,6 @@ import (
"time"
b58
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
ds
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
ma
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
goprocess
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
mamask
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/whyrusleeping/multiaddr-filter"
...
...
@@ -570,14 +569,14 @@ func startListening(ctx context.Context, host p2phost.Host, cfg *config.Config)
return
nil
}
func
constructDHTRouting
(
ctx
context
.
Context
,
host
p2phost
.
Host
,
dstore
ds
.
Datastore
)
(
routing
.
IpfsRouting
,
error
)
{
func
constructDHTRouting
(
ctx
context
.
Context
,
host
p2phost
.
Host
,
dstore
repo
.
Datastore
)
(
routing
.
IpfsRouting
,
error
)
{
dhtRouting
:=
dht
.
NewDHT
(
ctx
,
host
,
dstore
)
dhtRouting
.
Validator
[
IpnsValidatorTag
]
=
namesys
.
IpnsRecordValidator
dhtRouting
.
Selector
[
IpnsValidatorTag
]
=
namesys
.
IpnsSelectorFunc
return
dhtRouting
,
nil
}
type
RoutingOption
func
(
context
.
Context
,
p2phost
.
Host
,
ds
.
Datastore
)
(
routing
.
IpfsRouting
,
error
)
type
RoutingOption
func
(
context
.
Context
,
p2phost
.
Host
,
repo
.
Datastore
)
(
routing
.
IpfsRouting
,
error
)
type
DiscoveryOption
func
(
p2phost
.
Host
)
(
discovery
.
Service
,
error
)
...
...
core/corerouting/core.go
浏览文件 @
45d4b1a8
...
...
@@ -8,6 +8,7 @@ import (
core
"github.com/ipfs/go-ipfs/core"
"github.com/ipfs/go-ipfs/p2p/host"
"github.com/ipfs/go-ipfs/p2p/peer"
repo
"github.com/ipfs/go-ipfs/repo"
routing
"github.com/ipfs/go-ipfs/routing"
supernode
"github.com/ipfs/go-ipfs/routing/supernode"
gcproxy
"github.com/ipfs/go-ipfs/routing/supernode/proxy"
...
...
@@ -28,7 +29,7 @@ var (
// routing records to the provided datastore. Only routing records are store in
// the datastore.
func
SupernodeServer
(
recordSource
ds
.
ThreadSafeDatastore
)
core
.
RoutingOption
{
return
func
(
ctx
context
.
Context
,
ph
host
.
Host
,
dstore
ds
.
Datastore
)
(
routing
.
IpfsRouting
,
error
)
{
return
func
(
ctx
context
.
Context
,
ph
host
.
Host
,
dstore
repo
.
Datastore
)
(
routing
.
IpfsRouting
,
error
)
{
server
,
err
:=
supernode
.
NewServer
(
recordSource
,
ph
.
Peerstore
(),
ph
.
ID
())
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -44,7 +45,7 @@ func SupernodeServer(recordSource ds.ThreadSafeDatastore) core.RoutingOption {
// TODO doc
func
SupernodeClient
(
remotes
...
peer
.
PeerInfo
)
core
.
RoutingOption
{
return
func
(
ctx
context
.
Context
,
ph
host
.
Host
,
dstore
ds
.
Datastore
)
(
routing
.
IpfsRouting
,
error
)
{
return
func
(
ctx
context
.
Context
,
ph
host
.
Host
,
dstore
repo
.
Datastore
)
(
routing
.
IpfsRouting
,
error
)
{
if
len
(
remotes
)
<
1
{
return
nil
,
errServersMissing
}
...
...
repo/fsrepo/defaultds.go
浏览文件 @
45d4b1a8
...
...
@@ -8,7 +8,7 @@ import (
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/flatfs"
levelds
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/leveldb"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/measure"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/
mount"
mount
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync
mount"
ldbopts
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt"
repo
"github.com/ipfs/go-ipfs/repo"
config
"github.com/ipfs/go-ipfs/repo/config"
...
...
@@ -20,22 +20,11 @@ const (
flatfsDirectory
=
"blocks"
)
type
defaultDatastore
struct
{
repo
.
Datastore
// tracked separately for use in Close; do not use directly.
leveldbDS
repo
.
Datastore
metricsBlocks
repo
.
Datastore
metricsLevelDB
repo
.
Datastore
}
func
openDefaultDatastore
(
r
*
FSRepo
)
(
repo
.
Datastore
,
error
)
{
d
:=
&
defaultDatastore
{}
leveldbPath
:=
path
.
Join
(
r
.
path
,
leveldbDirectory
)
var
err
error
// save leveldb reference so it can be neatly closed afterward
d
.
leveldbDS
,
err
=
levelds
.
NewDatastore
(
leveldbPath
,
&
levelds
.
Options
{
leveldbDS
,
err
:
=
levelds
.
NewDatastore
(
leveldbPath
,
&
levelds
.
Options
{
Compression
:
ldbopts
.
NoCompression
,
})
if
err
!=
nil
{
...
...
@@ -65,26 +54,20 @@ func openDefaultDatastore(r *FSRepo) (repo.Datastore, error) {
id
=
fmt
.
Sprintf
(
"uninitialized_%p"
,
r
)
}
prefix
:=
"fsrepo."
+
id
+
".datastore."
d
.
metricsBlocks
=
measure
.
New
(
prefix
+
"blocks"
,
blocksDS
)
d
.
metricsLevelDB
=
measure
.
New
(
prefix
+
"leveldb"
,
d
.
leveldbDS
)
metricsBlocks
:
=
measure
.
New
(
prefix
+
"blocks"
,
blocksDS
)
metricsLevelDB
:=
measure
.
New
(
prefix
+
"leveldb"
,
leveldbDS
)
mountDS
:=
mount
.
New
([]
mount
.
Mount
{
{
Prefix
:
ds
.
NewKey
(
"/blocks"
),
Datastore
:
d
.
metricsBlocks
,
Datastore
:
metricsBlocks
,
},
{
Prefix
:
ds
.
NewKey
(
"/"
),
Datastore
:
d
.
metricsLevelDB
,
Datastore
:
metricsLevelDB
,
},
})
// Make sure it's ok to claim the virtual datastore from mount as
// threadsafe. There's no clean way to make mount itself provide
// this information without copy-pasting the code into two
// variants. This is the same dilemma as the `[].byte` attempt at
// introducing const types to Go.
d
.
Datastore
=
mountDS
return
d
,
nil
return
mountDS
,
nil
}
func
initDefaultDatastore
(
repoPath
string
,
conf
*
config
.
Config
)
error
{
...
...
@@ -101,5 +84,3 @@ func initDefaultDatastore(repoPath string, conf *config.Config) error {
}
return
nil
}
var
_
repo
.
Datastore
=
(
*
defaultDatastore
)(
nil
)
repo/repo.go
浏览文件 @
45d4b1a8
...
...
@@ -5,7 +5,6 @@ import (
"io"
ds
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
config
"github.com/ipfs/go-ipfs/repo/config"
)
...
...
@@ -32,6 +31,6 @@ type Repo interface {
// Datastore is the interface required from a datastore to be
// acceptable to FSRepo.
type
Datastore
interface
{
ds
.
Datastore
// should be threadsafe, just be careful
ds
.
Batching
// should be threadsafe, just be careful
io
.
Closer
}
routing/none/none_client.go
浏览文件 @
45d4b1a8
...
...
@@ -3,11 +3,11 @@ package nilrouting
import
(
"errors"
ds
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
context
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
key
"github.com/ipfs/go-ipfs/blocks/key"
p2phost
"github.com/ipfs/go-ipfs/p2p/host"
peer
"github.com/ipfs/go-ipfs/p2p/peer"
repo
"github.com/ipfs/go-ipfs/repo"
routing
"github.com/ipfs/go-ipfs/routing"
logging
"github.com/ipfs/go-ipfs/vendor/QmQg1J6vikuXF9oDvm4wpdeAUvvkVEKW1EYDw9HhTMnP2b/go-log"
)
...
...
@@ -47,7 +47,7 @@ func (c *nilclient) Bootstrap(_ context.Context) error {
return
nil
}
func
ConstructNilRouting
(
_
context
.
Context
,
_
p2phost
.
Host
,
_
ds
.
Datastore
)
(
routing
.
IpfsRouting
,
error
)
{
func
ConstructNilRouting
(
_
context
.
Context
,
_
p2phost
.
Host
,
_
repo
.
Datastore
)
(
routing
.
IpfsRouting
,
error
)
{
return
&
nilclient
{},
nil
}
...
...
thirdparty/s3-datastore/datastore.go
浏览文件 @
45d4b1a8
...
...
@@ -71,4 +71,8 @@ func (ds *S3Datastore) Close() error {
return
nil
}
func
(
ds
*
S3Datastore
)
Batch
()
(
datastore
.
Batch
,
error
)
{
return
datastore
.
NewBasicBatch
(
ds
),
nil
}
func
(
ds
*
S3Datastore
)
IsThreadSafe
()
{}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论