Commit a64e8633 authored by frrist's avatar frrist Committed by Frrist

define general Store interface replaces Blockstore

- LoadCar accepts Store interface for putting blocks.
parent 2a9f2242
......@@ -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(bs bstore.Blockstore, r io.Reader) (*CarHeader, error) {
func LoadCar(s Store, 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 := bs.Put(blk); err != nil {
if err := s.Put(blk); err != nil {
return nil, err
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment