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
c2cc4b1d
Commit
c2cc4b1d
authored
Aug 29, 2014
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
a little cleanup, ipfs 'works' for basic file adds and cats
parent
691d1b36
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
37 additions
and
33 deletions
+37
-33
cmd/ipfs/add.go
cmd/ipfs/add.go
+5
-4
cmd/ipfs/cat.go
cmd/ipfs/cat.go
+1
-1
cmd/ipfs/ipfs.go
cmd/ipfs/ipfs.go
+2
-2
cmd/ipfs/ls.go
cmd/ipfs/ls.go
+1
-1
cmd/ipfs/mount_unix.go
cmd/ipfs/mount_unix.go
+1
-1
cmd/ipfs/refs.go
cmd/ipfs/refs.go
+1
-1
config/serialize.go
config/serialize.go
+1
-1
core/core.go
core/core.go
+25
-22
No files found.
cmd/ipfs/add.go
View file @
c2cc4b1d
...
...
@@ -2,6 +2,10 @@ package main
import
(
"fmt"
"io/ioutil"
"os"
"path/filepath"
"github.com/gonuts/flag"
"github.com/jbenet/commander"
core
"github.com/jbenet/go-ipfs/core"
...
...
@@ -9,9 +13,6 @@ import (
dag
"github.com/jbenet/go-ipfs/merkledag"
u
"github.com/jbenet/go-ipfs/util"
mh
"github.com/jbenet/go-multihash"
"io/ioutil"
"os"
"path/filepath"
)
// Error indicating the max depth has been exceded.
...
...
@@ -41,7 +42,7 @@ func addCmd(c *commander.Command, inp []string) error {
return
nil
}
n
,
err
:=
localNode
()
n
,
err
:=
localNode
(
false
)
if
err
!=
nil
{
return
err
}
...
...
cmd/ipfs/cat.go
View file @
c2cc4b1d
...
...
@@ -26,7 +26,7 @@ func catCmd(c *commander.Command, inp []string) error {
return
nil
}
n
,
err
:=
localNode
()
n
,
err
:=
localNode
(
false
)
if
err
!=
nil
{
return
err
}
...
...
cmd/ipfs/ipfs.go
View file @
c2cc4b1d
...
...
@@ -67,12 +67,12 @@ func main() {
return
}
func
localNode
()
(
*
core
.
IpfsNode
,
error
)
{
func
localNode
(
online
bool
)
(
*
core
.
IpfsNode
,
error
)
{
//todo implement config file flag
cfg
,
err
:=
config
.
Load
(
""
)
if
err
!=
nil
{
return
nil
,
err
}
return
core
.
NewIpfsNode
(
cfg
)
return
core
.
NewIpfsNode
(
cfg
,
online
)
}
cmd/ipfs/ls.go
View file @
c2cc4b1d
...
...
@@ -27,7 +27,7 @@ func lsCmd(c *commander.Command, inp []string) error {
return
nil
}
n
,
err
:=
localNode
()
n
,
err
:=
localNode
(
false
)
if
err
!=
nil
{
return
err
}
...
...
cmd/ipfs/mount_unix.go
View file @
c2cc4b1d
...
...
@@ -31,7 +31,7 @@ func mountCmd(c *commander.Command, inp []string) error {
return
nil
}
n
,
err
:=
localNode
()
n
,
err
:=
localNode
(
true
)
if
err
!=
nil
{
return
err
}
...
...
cmd/ipfs/refs.go
View file @
c2cc4b1d
...
...
@@ -36,7 +36,7 @@ func refCmd(c *commander.Command, inp []string) error {
return
nil
}
n
,
err
:=
localNode
()
n
,
err
:=
localNode
(
false
)
if
err
!=
nil
{
return
err
}
...
...
config/serialize.go
View file @
c2cc4b1d
...
...
@@ -33,7 +33,7 @@ func WriteConfigFile(filename string, cfg interface{}) error {
// WriteFile writes the buffer at filename
func
WriteFile
(
filename
string
,
buf
[]
byte
)
error
{
err
:=
os
.
MkdirAll
(
filepath
.
Dir
(
filename
),
7
5
5
)
err
:=
os
.
MkdirAll
(
filepath
.
Dir
(
filename
),
07
75
)
if
err
!=
nil
{
return
err
}
...
...
core/core.go
View file @
c2cc4b1d
...
...
@@ -55,7 +55,7 @@ type IpfsNode struct {
}
// NewIpfsNode constructs a new IpfsNode based on the given config.
func
NewIpfsNode
(
cfg
*
config
.
Config
)
(
*
IpfsNode
,
error
)
{
func
NewIpfsNode
(
cfg
*
config
.
Config
,
online
bool
)
(
*
IpfsNode
,
error
)
{
if
cfg
==
nil
{
return
nil
,
fmt
.
Errorf
(
"configuration required"
)
}
...
...
@@ -65,34 +65,37 @@ func NewIpfsNode(cfg *config.Config) (*IpfsNode, error) {
return
nil
,
err
}
maddr
,
err
:=
ma
.
NewMultiaddr
(
"/ip4/127.0.0.1/tcp/4001"
)
if
err
!=
nil
{
return
nil
,
err
}
var
swap
*
bitswap
.
BitSwap
if
online
{
maddr
,
err
:=
ma
.
NewMultiaddr
(
"/ip4/127.0.0.1/tcp/4001"
)
if
err
!=
nil
{
return
nil
,
err
}
local
:=
&
peer
.
Peer
{
ID
:
peer
.
ID
(
cfg
.
Identity
.
PeerID
),
Addresses
:
[]
*
ma
.
Multiaddr
{
maddr
},
}
local
:=
&
peer
.
Peer
{
ID
:
peer
.
ID
(
cfg
.
Identity
.
PeerID
),
Addresses
:
[]
*
ma
.
Multiaddr
{
maddr
},
}
if
len
(
local
.
ID
)
==
0
{
mh
,
err
:=
u
.
Hash
([]
byte
(
"blah blah blah ID"
))
if
len
(
local
.
ID
)
==
0
{
mh
,
err
:=
u
.
Hash
([]
byte
(
"blah blah blah ID"
))
if
err
!=
nil
{
return
nil
,
err
}
local
.
ID
=
peer
.
ID
(
mh
)
}
net
:=
swarm
.
NewSwarm
(
local
)
err
=
net
.
Listen
()
if
err
!=
nil
{
return
nil
,
err
}
local
.
ID
=
peer
.
ID
(
mh
)
}
net
:=
swarm
.
NewSwarm
(
local
)
err
=
net
.
Listen
()
if
err
!=
nil
{
return
nil
,
err
}
route
:=
dht
.
NewDHT
(
local
,
net
,
d
)
route
.
Start
()
route
:=
dht
.
NewDHT
(
local
,
net
,
d
)
route
.
Start
()
swap
:=
bitswap
.
NewBitSwap
(
local
,
net
,
d
,
route
)
swap
=
bitswap
.
NewBitSwap
(
local
,
net
,
d
,
route
)
}
bs
,
err
:=
bserv
.
NewBlockService
(
d
,
swap
)
if
err
!=
nil
{
...
...
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