move default hash into ipfs2, committed on freemont troll
Jeromy committed
Nov 15, 2014 at 18:28 UTC
e857a5bc9fd66f94da045f9c69e0aa7e82b87e56
1 file changed
+27
cmd/ipfs2/init.go
+27
@@ -1,6 +1,7 @@
1
package main
2
3
import (
4
+ "bytes"
5
"encoding/base64"
6
"errors"
7
"fmt"
@@ -9,7 +10,10 @@ import (
10
11
cmds "github.com/jbenet/go-ipfs/commands"
12
config "github.com/jbenet/go-ipfs/config"
13
+ core "github.com/jbenet/go-ipfs/core"
14
ci "github.com/jbenet/go-ipfs/crypto"
15
+ imp "github.com/jbenet/go-ipfs/importer"
16
+ chunk "github.com/jbenet/go-ipfs/importer/chunk"
17
peer "github.com/jbenet/go-ipfs/peer"
18
u "github.com/jbenet/go-ipfs/util"
19
)
@@ -114,6 +118,29 @@ func doInit(configRoot string, dspathOverride string, force bool, nBitsForKeypai
118
if err != nil {
119
return err
120
}
121
+
122
+ nd, err := core.NewIpfsNode(&conf, false)
123
+ if err != nil {
124
+ return err
125
+ }
126
+ defer nd.Close()
127
+
128
+ // Set up default file
129
+ msg := `Hello and Welcome to IPFS!
130
+If you're seeing this, that means that you have successfully
131
+installed ipfs and are now interfacing with the wonderful
132
+world of DAGs and hashes!
133
+`
134
+ reader := bytes.NewBufferString(msg)
135
+
136
+ defnd, err := imp.BuildDagFromReader(reader, nd.DAG, nd.Pinning.GetManual(), chunk.DefaultSplitter)
137
+ if err != nil {
138
+ return err
139
+ }
140
+
141
+ k, _ := defnd.Key()
142
+ fmt.Printf("Default file key: %s\n", k)
143
+
144
return nil
145
}
146