From 8a21af092af63ef1ea4609ebeb3d60b7c762f3ad Mon Sep 17 00:00:00 2001 From: Jeromy Date: Mon, 15 Sep 2014 06:07:03 +0000 Subject: [PATCH] add basic test for blocks package #59 --- blocks/blocks.go | 3 +-- merkledag/dagreader.go | 12 +++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/blocks/blocks.go b/blocks/blocks.go index b514f85d999..c58ab9f209e 100644 --- a/blocks/blocks.go +++ b/blocks/blocks.go @@ -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 diff --git a/merkledag/dagreader.go b/merkledag/dagreader.go index 5cf4e238ef9..1e8a0c8b9ad 100644 --- a/merkledag/dagreader.go +++ b/merkledag/dagreader.go @@ -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) { @@ -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 @@ -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())