finish addressing PR concerns
Jeromy committed
Oct 30, 2014 at 20:50 UTC
09004e498919aa5cb2092d8103f4a8b7c4fa3846
2 files changed
+7
-6
unixfs/io/dagreader.go
+2
-3
@@ -35,12 +35,11 @@ func NewDagReader(n *mdag.Node, serv mdag.DAGService) (io.Reader, error) {
35
// Dont allow reading directories
36
return nil, ErrIsDir
37
case ftpb.Data_File:
38
- dr := &DagReader{
38
+ return &DagReader{
39
node: n,
40
serv: serv,
41
buf: bytes.NewBuffer(pb.GetData()),
42
- }
43
- return dr, nil
42
+ }, nil
43
case ftpb.Data_Raw:
44
// Raw block will just be a single level, return a byte buffer
45
return bytes.NewBuffer(pb.GetData()), nil
util/testutil/gen.go
+5
-3
@@ -9,6 +9,7 @@ import (
9
ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
10
bsrv "github.com/jbenet/go-ipfs/blockservice"
11
dag "github.com/jbenet/go-ipfs/merkledag"
12
+ u "github.com/jbenet/go-ipfs/util"
13
)
14
15
func GetDAGServ(t testing.TB) dag.DAGService {
@@ -21,7 +22,8 @@ func GetDAGServ(t testing.TB) dag.DAGService {
22
}
23
24
func RandPeer() peer.Peer {
24
- id := make(peer.ID, 16)
25
+ id := make([]byte, 16)
26
crand.Read(id)
26
- return peer.WithID(id)
27
-}
\ No newline at end of file
27
+ mhid := u.Hash(id)
28
+ return peer.WithID(peer.ID(mhid))
29
+}