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
ef65bb1c
Commit
ef65bb1c
authored
10 years ago
by
Brian Tiger Chow
Committed by
Juan Batiz-Benet
10 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revert to debug error
@jbenet License: MIT Signed-off-by:
Brian Tiger Chow
<
brian@perfmode.com
>
parent
bc396610
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
35 additions
and
34 deletions
+35
-34
cmd/ipfs2/daemon.go
cmd/ipfs2/daemon.go
+3
-3
cmd/ipfs2/init.go
cmd/ipfs2/init.go
+9
-9
cmd/ipfs2/main.go
cmd/ipfs2/main.go
+3
-2
config/config.go
config/config.go
+2
-2
core/core.go
core/core.go
+9
-9
core/datastore.go
core/datastore.go
+5
-5
daemon2/daemon.go
daemon2/daemon.go
+2
-2
util/debugerror/debug.go
util/debugerror/debug.go
+2
-2
No files found.
cmd/ipfs2/daemon.go
View file @
ef65bb1c
...
...
@@ -13,7 +13,7 @@ import (
commands
"github.com/jbenet/go-ipfs/core/commands2"
daemon
"github.com/jbenet/go-ipfs/daemon2"
util
"github.com/jbenet/go-ipfs/util"
errors
"github.com/jbenet/go-ipfs/util/error
s
"
"github.com/jbenet/go-ipfs/util/
debug
error"
)
const
(
...
...
@@ -54,14 +54,14 @@ func daemonFunc(req cmds.Request) (interface{}, error) {
if
!
util
.
FileExists
(
req
.
Context
()
.
ConfigRoot
)
{
err
:=
initWithDefaults
(
req
.
Context
()
.
ConfigRoot
)
if
err
!=
nil
{
return
nil
,
error
s
.
Wrap
(
err
)
return
nil
,
debug
error
.
Wrap
(
err
)
}
}
}
lock
,
err
:=
daemon
.
Lock
(
req
.
Context
()
.
ConfigRoot
)
if
err
!=
nil
{
return
nil
,
error
s
.
Errorf
(
"Couldn't obtain lock. Is another daemon already running?"
)
return
nil
,
debug
error
.
Errorf
(
"Couldn't obtain lock. Is another daemon already running?"
)
}
defer
lock
.
Close
()
...
...
This diff is collapsed.
Click to expand it.
cmd/ipfs2/init.go
View file @
ef65bb1c
...
...
@@ -16,7 +16,7 @@ import (
chunk
"github.com/jbenet/go-ipfs/importer/chunk"
peer
"github.com/jbenet/go-ipfs/peer"
u
"github.com/jbenet/go-ipfs/util"
errors
"github.com/jbenet/go-ipfs/util/error
s
"
"github.com/jbenet/go-ipfs/util/
debug
error"
)
const
nBitsForKeypairDefault
=
4096
...
...
@@ -62,7 +62,7 @@ var initCmd = &cmds.Command{
},
}
var
errCannotInitConfigExists
=
error
s
.
New
(
`ipfs configuration file already exists!
var
errCannotInitConfigExists
=
debug
error
.
New
(
`ipfs configuration file already exists!
Reinitializing would overwrite your keys.
(use -f to force overwrite)
`
)
...
...
@@ -84,7 +84,7 @@ For a short demo of what you can do, enter 'ipfs tour'
func
initWithDefaults
(
configRoot
string
)
error
{
_
,
err
:=
doInit
(
configRoot
,
""
,
false
,
nBitsForKeypairDefault
)
return
error
s
.
Wrap
(
err
)
return
debug
error
.
Wrap
(
err
)
}
func
doInit
(
configRoot
string
,
dspathOverride
string
,
force
bool
,
nBitsForKeypair
int
)
(
interface
{},
error
)
{
...
...
@@ -93,7 +93,7 @@ func doInit(configRoot string, dspathOverride string, force bool, nBitsForKeypai
configFilename
,
err
:=
config
.
Filename
(
configRoot
)
if
err
!=
nil
{
return
nil
,
error
s
.
New
(
"Couldn't get home directory path"
)
return
nil
,
debug
error
.
New
(
"Couldn't get home directory path"
)
}
if
u
.
FileExists
(
configFilename
)
&&
!
force
{
...
...
@@ -155,7 +155,7 @@ func datastoreConfig(dspath string) (config.Datastore, error) {
err
:=
initCheckDir
(
dspath
)
if
err
!=
nil
{
return
ds
,
error
s
.
Errorf
(
"datastore: %s"
,
err
)
return
ds
,
debug
error
.
Errorf
(
"datastore: %s"
,
err
)
}
return
ds
,
nil
...
...
@@ -229,7 +229,7 @@ func identityConfig(nbits int, onBegin func(), onSuccess func(config.Identity))
// TODO guard higher up
ident
:=
config
.
Identity
{}
if
nbits
<
1024
{
return
ident
,
error
s
.
New
(
"Bitsize less than 1024 is considered unsafe."
)
return
ident
,
debug
error
.
New
(
"Bitsize less than 1024 is considered unsafe."
)
}
onBegin
()
...
...
@@ -260,13 +260,13 @@ func initLogs(logpath string) (config.Logs, error) {
var
err
error
logpath
,
err
=
config
.
LogsPath
(
""
)
if
err
!=
nil
{
return
config
.
Logs
{},
error
s
.
Wrap
(
err
)
return
config
.
Logs
{},
debug
error
.
Wrap
(
err
)
}
}
err
:=
initCheckDir
(
logpath
)
if
err
!=
nil
{
return
config
.
Logs
{},
error
s
.
Errorf
(
"logs: %s"
,
err
)
return
config
.
Logs
{},
debug
error
.
Errorf
(
"logs: %s"
,
err
)
}
return
config
.
Logs
{
...
...
@@ -285,7 +285,7 @@ func initCheckDir(path string) error {
if
f
,
err
:=
os
.
Create
(
filepath
.
Join
(
path
,
"._check_writeable"
));
err
==
nil
{
os
.
Remove
(
f
.
Name
())
}
else
{
return
error
s
.
New
(
"'"
+
path
+
"' is not writeable"
)
return
debug
error
.
New
(
"'"
+
path
+
"' is not writeable"
)
}
return
nil
}
This diff is collapsed.
Click to expand it.
cmd/ipfs2/main.go
View file @
ef65bb1c
package
main
import
(
"errors"
"fmt"
"io"
"os"
...
...
@@ -21,7 +22,7 @@ import (
daemon
"github.com/jbenet/go-ipfs/daemon2"
updates
"github.com/jbenet/go-ipfs/updates"
u
"github.com/jbenet/go-ipfs/util"
errors
"github.com/jbenet/go-ipfs/util/error
s
"
"github.com/jbenet/go-ipfs/util/
debug
error"
eventlog
"github.com/jbenet/go-ipfs/util/eventlog"
)
...
...
@@ -331,7 +332,7 @@ func commandDetails(path []string, root *cmds.Command) (*cmdDetails, error) {
var
found
bool
cmd
,
found
=
cmd
.
Subcommands
[
cmp
]
if
!
found
{
return
nil
,
error
s
.
Errorf
(
"subcommand %s should be in root"
,
cmp
)
return
nil
,
debug
error
.
Errorf
(
"subcommand %s should be in root"
,
cmp
)
}
if
cmdDetails
,
found
:=
cmdDetailsMap
[
cmd
];
found
{
...
...
This diff is collapsed.
Click to expand it.
config/config.go
View file @
ef65bb1c
...
...
@@ -9,7 +9,7 @@ import (
"path/filepath"
u
"github.com/jbenet/go-ipfs/util"
errors
"github.com/jbenet/go-ipfs/util/error
s
"
"github.com/jbenet/go-ipfs/util/
debug
error"
)
var
log
=
u
.
Logger
(
"config"
)
...
...
@@ -147,7 +147,7 @@ func (i *Identity) DecodePrivateKey(passphrase string) (crypto.PrivateKey, error
func
Load
(
filename
string
)
(
*
Config
,
error
)
{
// if nothing is there, fail. User must run 'ipfs init'
if
_
,
err
:=
os
.
Stat
(
filename
);
os
.
IsNotExist
(
err
)
{
return
nil
,
error
s
.
New
(
"ipfs not initialized, please run 'ipfs init'"
)
return
nil
,
debug
error
.
New
(
"ipfs not initialized, please run 'ipfs init'"
)
}
var
cfg
Config
...
...
This diff is collapsed.
Click to expand it.
core/core.go
View file @
ef65bb1c
...
...
@@ -27,7 +27,7 @@ import (
dht
"github.com/jbenet/go-ipfs/routing/dht"
u
"github.com/jbenet/go-ipfs/util"
ctxc
"github.com/jbenet/go-ipfs/util/ctxcloser"
"github.com/jbenet/go-ipfs/util/error
s
"
"github.com/jbenet/go-ipfs/util/
debug
error"
)
const
IpnsValidatorTag
=
"ipns"
...
...
@@ -102,7 +102,7 @@ func NewIpfsNode(cfg *config.Config, online bool) (n *IpfsNode, err error) {
}()
if
cfg
==
nil
{
return
nil
,
error
s
.
Errorf
(
"configuration required"
)
return
nil
,
debug
error
.
Errorf
(
"configuration required"
)
}
// derive this from a higher context.
...
...
@@ -115,14 +115,14 @@ func NewIpfsNode(cfg *config.Config, online bool) (n *IpfsNode, err error) {
// setup datastore.
if
n
.
Datastore
,
err
=
makeDatastore
(
cfg
.
Datastore
);
err
!=
nil
{
return
nil
,
error
s
.
Wrap
(
err
)
return
nil
,
debug
error
.
Wrap
(
err
)
}
// setup peerstore + local peer identity
n
.
Peerstore
=
peer
.
NewPeerstore
()
n
.
Identity
,
err
=
initIdentity
(
&
n
.
Config
.
Identity
,
n
.
Peerstore
,
online
)
if
err
!=
nil
{
return
nil
,
error
s
.
Wrap
(
err
)
return
nil
,
debug
error
.
Wrap
(
err
)
}
// setup online services
...
...
@@ -142,12 +142,12 @@ func NewIpfsNode(cfg *config.Config, online bool) (n *IpfsNode, err error) {
// setup the network
listenAddrs
,
err
:=
listenAddresses
(
cfg
)
if
err
!=
nil
{
return
nil
,
error
s
.
Wrap
(
err
)
return
nil
,
debug
error
.
Wrap
(
err
)
}
n
.
Network
,
err
=
inet
.
NewIpfsNetwork
(
ctx
,
listenAddrs
,
n
.
Identity
,
n
.
Peerstore
,
muxMap
)
if
err
!=
nil
{
return
nil
,
error
s
.
Wrap
(
err
)
return
nil
,
debug
error
.
Wrap
(
err
)
}
n
.
AddCloserChild
(
n
.
Network
)
...
...
@@ -176,7 +176,7 @@ func NewIpfsNode(cfg *config.Config, online bool) (n *IpfsNode, err error) {
// session that simply doesn't return blocks
n
.
Blocks
,
err
=
bserv
.
NewBlockService
(
n
.
Datastore
,
n
.
Exchange
)
if
err
!=
nil
{
return
nil
,
error
s
.
Wrap
(
err
)
return
nil
,
debug
error
.
Wrap
(
err
)
}
n
.
DAG
=
merkledag
.
NewDAGService
(
n
.
Blocks
)
...
...
@@ -202,11 +202,11 @@ func (n *IpfsNode) OnlineMode() bool {
func
initIdentity
(
cfg
*
config
.
Identity
,
peers
peer
.
Peerstore
,
online
bool
)
(
peer
.
Peer
,
error
)
{
if
cfg
.
PeerID
==
""
{
return
nil
,
error
s
.
New
(
"Identity was not set in config (was ipfs init run?)"
)
return
nil
,
debug
error
.
New
(
"Identity was not set in config (was ipfs init run?)"
)
}
if
len
(
cfg
.
PeerID
)
==
0
{
return
nil
,
error
s
.
New
(
"No peer ID in config! (was ipfs init run?)"
)
return
nil
,
debug
error
.
New
(
"No peer ID in config! (was ipfs init run?)"
)
}
// get peer from peerstore (so it is constructed there)
...
...
This diff is collapsed.
Click to expand it.
core/datastore.go
View file @
ef65bb1c
...
...
@@ -10,12 +10,12 @@ import (
config
"github.com/jbenet/go-ipfs/config"
u
"github.com/jbenet/go-ipfs/util"
"github.com/jbenet/go-ipfs/util/error
s
"
"github.com/jbenet/go-ipfs/util/
debug
error"
)
func
makeDatastore
(
cfg
config
.
Datastore
)
(
u
.
ThreadSafeDatastoreCloser
,
error
)
{
if
len
(
cfg
.
Type
)
==
0
{
return
nil
,
error
s
.
Errorf
(
"config datastore.type required"
)
return
nil
,
debug
error
.
Errorf
(
"config datastore.type required"
)
}
switch
cfg
.
Type
{
...
...
@@ -35,17 +35,17 @@ func makeDatastore(cfg config.Datastore) (u.ThreadSafeDatastoreCloser, error) {
return
u
.
CloserWrap
(
syncds
.
MutexWrap
(
ktd
)),
nil
}
return
nil
,
error
s
.
Errorf
(
"Unknown datastore type: %s"
,
cfg
.
Type
)
return
nil
,
debug
error
.
Errorf
(
"Unknown datastore type: %s"
,
cfg
.
Type
)
}
func
makeLevelDBDatastore
(
cfg
config
.
Datastore
)
(
u
.
ThreadSafeDatastoreCloser
,
error
)
{
if
len
(
cfg
.
Path
)
==
0
{
return
nil
,
error
s
.
Errorf
(
"config datastore.path required for leveldb"
)
return
nil
,
debug
error
.
Errorf
(
"config datastore.path required for leveldb"
)
}
ds
,
err
:=
lds
.
NewDatastore
(
cfg
.
Path
,
&
lds
.
Options
{
// TODO don't import ldbopts. Get from go-datastore.leveldb
Compression
:
ldbopts
.
NoCompression
,
})
return
ds
,
error
s
.
Wrap
(
err
)
return
ds
,
debug
error
.
Wrap
(
err
)
}
This diff is collapsed.
Click to expand it.
daemon2/daemon.go
View file @
ef65bb1c
...
...
@@ -6,7 +6,7 @@ import (
lock
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/camlistore/lock"
"github.com/jbenet/go-ipfs/util"
"github.com/jbenet/go-ipfs/util/error
s
"
"github.com/jbenet/go-ipfs/util/
debug
error"
)
// LockFile is the filename of the daemon lock, relative to config dir
...
...
@@ -14,7 +14,7 @@ const LockFile = "daemon.lock"
func
Lock
(
confdir
string
)
(
io
.
Closer
,
error
)
{
c
,
err
:=
lock
.
Lock
(
path
.
Join
(
confdir
,
LockFile
))
return
c
,
error
s
.
Wrap
(
err
)
return
c
,
debug
error
.
Wrap
(
err
)
}
func
Locked
(
confdir
string
)
bool
{
...
...
This diff is collapsed.
Click to expand it.
util/error
s
/debug.go
→
util/
debug
error/debug.go
View file @
ef65bb1c
// package error
s
provides ways to augment errors with additional
// package
debug
error provides ways to augment errors with additional
// information to allow for easier debugging.
package
error
s
package
debug
error
import
(
"errors"
...
...
This diff is collapsed.
Click to expand it.
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