Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
2ce9415c
Commit
2ce9415c
authored
Oct 03, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
+ fs ds + thread safe
parent
88d804e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
core/core.go
core/core.go
+1
-1
core/datastore.go
core/datastore.go
+14
-3
No files found.
core/core.go
View file @
2ce9415c
...
@@ -43,7 +43,7 @@ type IpfsNode struct {
...
@@ -43,7 +43,7 @@ type IpfsNode struct {
Peerstore
peer
.
Peerstore
Peerstore
peer
.
Peerstore
// the local datastore
// the local datastore
Datastore
ds
.
Datastore
Datastore
ds
.
ThreadSafe
Datastore
// the network message stream
// the network message stream
Network
inet
.
Network
Network
inet
.
Network
...
...
core/datastore.go
View file @
2ce9415c
...
@@ -4,11 +4,13 @@ import (
...
@@ -4,11 +4,13 @@ import (
"fmt"
"fmt"
ds
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go"
ds
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go"
fsds
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go/fs"
lds
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go/leveldb"
lds
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go/leveldb"
syncds
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go/sync"
config
"github.com/jbenet/go-ipfs/config"
config
"github.com/jbenet/go-ipfs/config"
)
)
func
makeDatastore
(
cfg
config
.
Datastore
)
(
ds
.
Datastore
,
error
)
{
func
makeDatastore
(
cfg
config
.
Datastore
)
(
ds
.
ThreadSafe
Datastore
,
error
)
{
if
len
(
cfg
.
Type
)
==
0
{
if
len
(
cfg
.
Type
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"config datastore.type required"
)
return
nil
,
fmt
.
Errorf
(
"config datastore.type required"
)
}
}
...
@@ -16,14 +18,23 @@ func makeDatastore(cfg config.Datastore) (ds.Datastore, error) {
...
@@ -16,14 +18,23 @@ func makeDatastore(cfg config.Datastore) (ds.Datastore, error) {
switch
cfg
.
Type
{
switch
cfg
.
Type
{
case
"leveldb"
:
case
"leveldb"
:
return
makeLevelDBDatastore
(
cfg
)
return
makeLevelDBDatastore
(
cfg
)
case
"memory"
:
case
"memory"
:
return
ds
.
NewMapDatastore
(),
nil
return
syncds
.
MutexWrap
(
ds
.
NewMapDatastore
()),
nil
case
"fs"
:
log
.
Warning
(
"using fs.Datastore at .datastore for testing."
)
d
,
err
:=
fsds
.
NewDatastore
(
".datastore"
)
// for testing!!
if
err
!=
nil
{
return
nil
,
err
}
return
syncds
.
MutexWrap
(
d
),
nil
}
}
return
nil
,
fmt
.
Errorf
(
"Unknown datastore type: %s"
,
cfg
.
Type
)
return
nil
,
fmt
.
Errorf
(
"Unknown datastore type: %s"
,
cfg
.
Type
)
}
}
func
makeLevelDBDatastore
(
cfg
config
.
Datastore
)
(
ds
.
Datastore
,
error
)
{
func
makeLevelDBDatastore
(
cfg
config
.
Datastore
)
(
ds
.
ThreadSafe
Datastore
,
error
)
{
if
len
(
cfg
.
Path
)
==
0
{
if
len
(
cfg
.
Path
)
==
0
{
return
nil
,
fmt
.
Errorf
(
"config datastore.path required for leveldb"
)
return
nil
,
fmt
.
Errorf
(
"config datastore.path required for leveldb"
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment