Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-merkledag
Commits
b897d7b5
Commit
b897d7b5
authored
Sep 15, 2014
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add basic test for blocks package #59
parent
6d19c80d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
7 deletions
+5
-7
dagreader.go
dagreader.go
+5
-7
No files found.
dagreader.go
View file @
b897d7b5
...
...
@@ -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
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment