add basic test for blocks package #59
Jeromy committed
Sep 15, 2014 at 06:07 UTC
8a21af092af63ef1ea4609ebeb3d60b7c762f3ad
2 files changed
+6
-9
blocks/blocks.go
+1
-2
@@ -5,8 +5,7 @@ import (
5
u "github.com/jbenet/go-ipfs/util"
6
)
7
8
-// Block is the ipfs blocks service. It is the way
9
-// to retrieve blocks by the higher level ipfs modules
8
+// Block is a singular block of data in ipfs
9
type Block struct {
10
Multihash mh.Multihash
11
Data []byte
merkledag/dagreader.go
+5
-7
@@ -17,7 +17,6 @@ type DagReader struct {
17
node *Node
18
position int
19
buf *bytes.Buffer
20
- thisData []byte
20
}
21
22
func NewDagReader(n *Node, serv *DAGService) (io.Reader, error) {
@@ -31,10 +30,9 @@ func NewDagReader(n *Node, serv *DAGService) (io.Reader, error) {
30
return nil, ErrIsDir
31
case PBData_File:
32
return &DagReader{
34
- node: n,
35
- thisData: pb.GetData(),
36
- serv: serv,
37
- buf: bytes.NewBuffer(pb.GetData()),
33
+ node: n,
34
+ serv: serv,
35
+ buf: bytes.NewBuffer(pb.GetData()),
36
}, nil
37
case PBData_Raw:
38
return bytes.NewBuffer(pb.GetData()), nil
@@ -63,12 +61,12 @@ func (dr *DagReader) precalcNextBuf() error {
61
}
62
dr.position++
63
66
- // TODO: dont assume a single layer of indirection
64
switch pb.GetType() {
65
case PBData_Directory:
66
panic("Why is there a directory under a file?")
67
case PBData_File:
71
- //TODO: maybe have a PBData_Block type for indirect blocks?
68
+ //TODO: this *should* work, needs testing first
69
+ //return NewDagReader(nxt, dr.serv)
70
panic("Not yet handling different layers of indirection!")
71
case PBData_Raw:
72
dr.buf = bytes.NewBuffer(pb.GetData())