Skip to content

Commit

Permalink
add basic test for blocks package #59
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping committed Sep 15, 2014
1 parent 3261ce2 commit 8a21af0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
3 changes: 1 addition & 2 deletions blocks/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import (
u "github.com/jbenet/go-ipfs/util"
)

// Block is the ipfs blocks service. It is the way
// to retrieve blocks by the higher level ipfs modules
// Block is a singular block of data in ipfs
type Block struct {
Multihash mh.Multihash
Data []byte
Expand Down
12 changes: 5 additions & 7 deletions merkledag/dagreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ type DagReader struct {
node *Node
position int
buf *bytes.Buffer
thisData []byte
}

func NewDagReader(n *Node, serv *DAGService) (io.Reader, error) {
Expand All @@ -31,10 +30,9 @@ func NewDagReader(n *Node, serv *DAGService) (io.Reader, error) {
return nil, ErrIsDir
case PBData_File:
return &DagReader{
node: n,
thisData: pb.GetData(),
serv: serv,
buf: bytes.NewBuffer(pb.GetData()),
node: n,
serv: serv,
buf: bytes.NewBuffer(pb.GetData()),
}, nil
case PBData_Raw:
return bytes.NewBuffer(pb.GetData()), nil
Expand Down Expand Up @@ -63,12 +61,12 @@ func (dr *DagReader) precalcNextBuf() error {
}
dr.position++

// TODO: dont assume a single layer of indirection
switch pb.GetType() {
case PBData_Directory:
panic("Why is there a directory under a file?")
case PBData_File:
//TODO: maybe have a PBData_Block type for indirect blocks?
//TODO: this *should* work, needs testing first
//return NewDagReader(nxt, dr.serv)
panic("Not yet handling different layers of indirection!")
case PBData_Raw:
dr.buf = bytes.NewBuffer(pb.GetData())
Expand Down

0 comments on commit 8a21af0

Please sign in to comment.