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
ld
go-car
Commits
28226cb4
Unverified
Commit
28226cb4
authored
Mar 04, 2020
by
Steven Allen
Committed by
GitHub
Mar 04, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #25 from ipld/fix/no-private-types
don't use private types in public functions
parents
da36c369
7ff5726c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
14 deletions
+6
-14
car.go
car.go
+6
-14
No files found.
car.go
View file @
28226cb4
...
...
@@ -105,12 +105,12 @@ func (cw *carWriter) writeNode(ctx context.Context, nd format.Node) error {
return
util
.
LdWrite
(
cw
.
w
,
nd
.
Cid
()
.
Bytes
(),
nd
.
RawData
())
}
type
c
arReader
struct
{
type
C
arReader
struct
{
br
*
bufio
.
Reader
Header
*
CarHeader
}
func
NewCarReader
(
r
io
.
Reader
)
(
*
c
arReader
,
error
)
{
func
NewCarReader
(
r
io
.
Reader
)
(
*
C
arReader
,
error
)
{
br
:=
bufio
.
NewReader
(
r
)
ch
,
err
:=
ReadHeader
(
br
)
if
err
!=
nil
{
...
...
@@ -125,13 +125,13 @@ func NewCarReader(r io.Reader) (*carReader, error) {
return
nil
,
fmt
.
Errorf
(
"invalid car version: %d"
,
ch
.
Version
)
}
return
&
c
arReader
{
return
&
C
arReader
{
br
:
br
,
Header
:
ch
,
},
nil
}
func
(
cr
*
c
arReader
)
Next
()
(
blocks
.
Block
,
error
)
{
func
(
cr
*
C
arReader
)
Next
()
(
blocks
.
Block
,
error
)
{
c
,
data
,
err
:=
util
.
ReadNode
(
cr
.
br
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -166,7 +166,7 @@ func LoadCar(s Store, r io.Reader) (*CarHeader, error) {
return
loadCarSlow
(
s
,
cr
)
}
func
loadCarFast
(
s
batchStore
,
cr
*
c
arReader
)
(
*
CarHeader
,
error
)
{
func
loadCarFast
(
s
batchStore
,
cr
*
C
arReader
)
(
*
CarHeader
,
error
)
{
var
buf
[]
blocks
.
Block
for
{
blk
,
err
:=
cr
.
Next
()
...
...
@@ -192,17 +192,9 @@ func loadCarFast(s batchStore, cr *carReader) (*CarHeader, error) {
buf
=
buf
[
:
0
]
}
}
if
len
(
buf
)
>
0
{
if
err
:=
s
.
PutMany
(
buf
);
err
!=
nil
{
return
nil
,
err
}
}
return
cr
.
Header
,
nil
}
func
loadCarSlow
(
s
Store
,
cr
*
c
arReader
)
(
*
CarHeader
,
error
)
{
func
loadCarSlow
(
s
Store
,
cr
*
C
arReader
)
(
*
CarHeader
,
error
)
{
for
{
blk
,
err
:=
cr
.
Next
()
...
...
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