mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-29 17:36:38 +08:00
finish addressing PR concerns
This commit is contained in:
@ -35,12 +35,11 @@ func NewDagReader(n *mdag.Node, serv mdag.DAGService) (io.Reader, error) {
|
|||||||
// Dont allow reading directories
|
// Dont allow reading directories
|
||||||
return nil, ErrIsDir
|
return nil, ErrIsDir
|
||||||
case ftpb.Data_File:
|
case ftpb.Data_File:
|
||||||
dr := &DagReader{
|
return &DagReader{
|
||||||
node: n,
|
node: n,
|
||||||
serv: serv,
|
serv: serv,
|
||||||
buf: bytes.NewBuffer(pb.GetData()),
|
buf: bytes.NewBuffer(pb.GetData()),
|
||||||
}
|
}, nil
|
||||||
return dr, nil
|
|
||||||
case ftpb.Data_Raw:
|
case ftpb.Data_Raw:
|
||||||
// Raw block will just be a single level, return a byte buffer
|
// Raw block will just be a single level, return a byte buffer
|
||||||
return bytes.NewBuffer(pb.GetData()), nil
|
return bytes.NewBuffer(pb.GetData()), nil
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
|
ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
|
||||||
bsrv "github.com/jbenet/go-ipfs/blockservice"
|
bsrv "github.com/jbenet/go-ipfs/blockservice"
|
||||||
dag "github.com/jbenet/go-ipfs/merkledag"
|
dag "github.com/jbenet/go-ipfs/merkledag"
|
||||||
|
u "github.com/jbenet/go-ipfs/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetDAGServ(t testing.TB) dag.DAGService {
|
func GetDAGServ(t testing.TB) dag.DAGService {
|
||||||
@ -21,7 +22,8 @@ func GetDAGServ(t testing.TB) dag.DAGService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func RandPeer() peer.Peer {
|
func RandPeer() peer.Peer {
|
||||||
id := make(peer.ID, 16)
|
id := make([]byte, 16)
|
||||||
crand.Read(id)
|
crand.Read(id)
|
||||||
return peer.WithID(id)
|
mhid := u.Hash(id)
|
||||||
}
|
return peer.WithID(peer.ID(mhid))
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user