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
a64e8633
Commit
a64e8633
authored
Sep 24, 2019
by
frrist
Committed by
Frrist
Sep 26, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
define general Store interface replaces Blockstore
- LoadCar accepts Store interface for putting blocks.
parent
2a9f2242
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
car.go
car.go
+6
-3
No files found.
car.go
View file @
a64e8633
...
...
@@ -8,7 +8,6 @@ import (
"github.com/ipfs/go-block-format"
cid
"github.com/ipfs/go-cid"
bstore
"github.com/ipfs/go-ipfs-blockstore"
cbor
"github.com/ipfs/go-ipld-cbor"
format
"github.com/ipfs/go-ipld-format"
dag
"github.com/ipfs/go-merkledag"
...
...
@@ -20,6 +19,10 @@ func init() {
cbor
.
RegisterCborType
(
CarHeader
{})
}
type
Store
interface
{
Put
(
blocks
.
Block
)
error
}
type
CarHeader
struct
{
Roots
[]
cid
.
Cid
Version
uint64
...
...
@@ -135,7 +138,7 @@ func (cr *carReader) Next() (blocks.Block, error) {
return
blocks
.
NewBlockWithCid
(
data
,
c
)
}
func
LoadCar
(
b
s
bstore
.
Blocks
tore
,
r
io
.
Reader
)
(
*
CarHeader
,
error
)
{
func
LoadCar
(
s
S
tore
,
r
io
.
Reader
)
(
*
CarHeader
,
error
)
{
cr
,
err
:=
NewCarReader
(
r
)
if
err
!=
nil
{
return
nil
,
err
...
...
@@ -151,7 +154,7 @@ func LoadCar(bs bstore.Blockstore, r io.Reader) (*CarHeader, error) {
case
nil
:
}
if
err
:=
b
s
.
Put
(
blk
);
err
!=
nil
{
if
err
:=
s
.
Put
(
blk
);
err
!=
nil
{
return
nil
,
err
}
}
...
...
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